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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
234,200
|
awurth/SlimHelpers
|
Command/RoutesCommand.php
|
RoutesCommand.text
|
public function text(InputInterface $input, OutputInterface $output)
{
foreach ($this->router->getRoutes() as $route) {
if (!empty($route->getName())) {
$output->writeln('<fg=cyan;options=bold>'.$route->getName().'</>');
$output->writeln(' '.implode(', ', $route->getMethods()));
$output->writeln(' '.$route->getPattern());
if (is_string($route->getCallable())) {
$output->writeln(' '.$route->getCallable());
}
$output->writeln('');
}
}
}
|
php
|
public function text(InputInterface $input, OutputInterface $output)
{
foreach ($this->router->getRoutes() as $route) {
if (!empty($route->getName())) {
$output->writeln('<fg=cyan;options=bold>'.$route->getName().'</>');
$output->writeln(' '.implode(', ', $route->getMethods()));
$output->writeln(' '.$route->getPattern());
if (is_string($route->getCallable())) {
$output->writeln(' '.$route->getCallable());
}
$output->writeln('');
}
}
}
|
[
"public",
"function",
"text",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"router",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<fg=cyan;options=bold>'",
".",
"$",
"route",
"->",
"getName",
"(",
")",
".",
"'</>'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"' '",
".",
"implode",
"(",
"', '",
",",
"$",
"route",
"->",
"getMethods",
"(",
")",
")",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"' '",
".",
"$",
"route",
"->",
"getPattern",
"(",
")",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"route",
"->",
"getCallable",
"(",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"' '",
".",
"$",
"route",
"->",
"getCallable",
"(",
")",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}",
"}",
"}"
] |
Displays routes in plain text.
@param InputInterface $input
@param OutputInterface $output
|
[
"Displays",
"routes",
"in",
"plain",
"text",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Command/RoutesCommand.php#L74-L88
|
234,201
|
awurth/SlimHelpers
|
Command/RoutesCommand.php
|
RoutesCommand.markdown
|
public function markdown(InputInterface $input, OutputInterface $output)
{
$output->writeln('# Routes');
$output->writeln('');
$url = rtrim($this->options['url'], '/');
foreach ($this->router->getRoutes() as $route) {
$output->writeln(sprintf('### `%s` [%s](%s)',
implode(', ', $route->getMethods()),
$route->getPattern(),
$url.$route->getPattern()
));
if (is_string($route->getCallable())) {
$output->writeln('##### '.$route->getCallable());
}
if (!empty($route->getName())) {
$output->writeln('###### '.$route->getName());
}
$output->writeln('');
}
}
|
php
|
public function markdown(InputInterface $input, OutputInterface $output)
{
$output->writeln('# Routes');
$output->writeln('');
$url = rtrim($this->options['url'], '/');
foreach ($this->router->getRoutes() as $route) {
$output->writeln(sprintf('### `%s` [%s](%s)',
implode(', ', $route->getMethods()),
$route->getPattern(),
$url.$route->getPattern()
));
if (is_string($route->getCallable())) {
$output->writeln('##### '.$route->getCallable());
}
if (!empty($route->getName())) {
$output->writeln('###### '.$route->getName());
}
$output->writeln('');
}
}
|
[
"public",
"function",
"markdown",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'# Routes'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"$",
"url",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"options",
"[",
"'url'",
"]",
",",
"'/'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"router",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'### `%s` [%s](%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"route",
"->",
"getMethods",
"(",
")",
")",
",",
"$",
"route",
"->",
"getPattern",
"(",
")",
",",
"$",
"url",
".",
"$",
"route",
"->",
"getPattern",
"(",
")",
")",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"route",
"->",
"getCallable",
"(",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'##### '",
".",
"$",
"route",
"->",
"getCallable",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'###### '",
".",
"$",
"route",
"->",
"getName",
"(",
")",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}",
"}"
] |
Displays routes in markdown format.
@param InputInterface $input
@param OutputInterface $output
|
[
"Displays",
"routes",
"in",
"markdown",
"format",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Command/RoutesCommand.php#L96-L118
|
234,202
|
phpmath/bignumber
|
src/Utils.php
|
Utils.convertToBase10
|
public static function convertToBase10($number, $fromBase)
{
$number = (string)ceil(static::getPlainNumber($number));
if ($fromBase == 10) {
return $number;
} elseif ($fromBase < 2 || $fromBase > 32) {
throw new InvalidArgumentException(sprintf(
'Base %d is unsupported, should be between 2 and 32.',
$fromBase
));
}
$result = '0';
$chars = self::BASE32_ALPHABET;
for ($i = 0, $len = strlen($number); $i < $len; $i++) {
$index = strpos($chars, $number[$i]);
if ($index >= $fromBase) {
throw new RuntimeException(sprintf(
'The digit %s in the number %s is an invalid digit for base-%s.',
$chars[$index],
$number,
$fromBase
));
}
$result = bcmul($result, $fromBase);
$result = bcadd($result, strpos($chars, $number[$i]));
}
return $result;
}
|
php
|
public static function convertToBase10($number, $fromBase)
{
$number = (string)ceil(static::getPlainNumber($number));
if ($fromBase == 10) {
return $number;
} elseif ($fromBase < 2 || $fromBase > 32) {
throw new InvalidArgumentException(sprintf(
'Base %d is unsupported, should be between 2 and 32.',
$fromBase
));
}
$result = '0';
$chars = self::BASE32_ALPHABET;
for ($i = 0, $len = strlen($number); $i < $len; $i++) {
$index = strpos($chars, $number[$i]);
if ($index >= $fromBase) {
throw new RuntimeException(sprintf(
'The digit %s in the number %s is an invalid digit for base-%s.',
$chars[$index],
$number,
$fromBase
));
}
$result = bcmul($result, $fromBase);
$result = bcadd($result, strpos($chars, $number[$i]));
}
return $result;
}
|
[
"public",
"static",
"function",
"convertToBase10",
"(",
"$",
"number",
",",
"$",
"fromBase",
")",
"{",
"$",
"number",
"=",
"(",
"string",
")",
"ceil",
"(",
"static",
"::",
"getPlainNumber",
"(",
"$",
"number",
")",
")",
";",
"if",
"(",
"$",
"fromBase",
"==",
"10",
")",
"{",
"return",
"$",
"number",
";",
"}",
"elseif",
"(",
"$",
"fromBase",
"<",
"2",
"||",
"$",
"fromBase",
">",
"32",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Base %d is unsupported, should be between 2 and 32.'",
",",
"$",
"fromBase",
")",
")",
";",
"}",
"$",
"result",
"=",
"'0'",
";",
"$",
"chars",
"=",
"self",
"::",
"BASE32_ALPHABET",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"len",
"=",
"strlen",
"(",
"$",
"number",
")",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"index",
"=",
"strpos",
"(",
"$",
"chars",
",",
"$",
"number",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"index",
">=",
"$",
"fromBase",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The digit %s in the number %s is an invalid digit for base-%s.'",
",",
"$",
"chars",
"[",
"$",
"index",
"]",
",",
"$",
"number",
",",
"$",
"fromBase",
")",
")",
";",
"}",
"$",
"result",
"=",
"bcmul",
"(",
"$",
"result",
",",
"$",
"fromBase",
")",
";",
"$",
"result",
"=",
"bcadd",
"(",
"$",
"result",
",",
"strpos",
"(",
"$",
"chars",
",",
"$",
"number",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Converts the provided number from an arbitrary base to to a base 10 number.
@param string|int|BigNumber $number The number to convert.
@param int $fromBase The base to convert the number from.
@return string
@throws InvalidArgumentException Thrown when the base is out of reach.
|
[
"Converts",
"the",
"provided",
"number",
"from",
"an",
"arbitrary",
"base",
"to",
"to",
"a",
"base",
"10",
"number",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/Utils.php#L45-L78
|
234,203
|
phpmath/bignumber
|
src/Utils.php
|
Utils.convertExponentialToString
|
public static function convertExponentialToString($value)
{
if (!is_float($value)) {
return $value;
}
$result = explode('E', strtoupper($value));
if (count($result) === 1) {
return $result[0];
}
$dotSplitted = explode('.', $result[0]);
return '0.' . str_repeat('0', abs($result[1]) - 1) . $dotSplitted[0];
}
|
php
|
public static function convertExponentialToString($value)
{
if (!is_float($value)) {
return $value;
}
$result = explode('E', strtoupper($value));
if (count($result) === 1) {
return $result[0];
}
$dotSplitted = explode('.', $result[0]);
return '0.' . str_repeat('0', abs($result[1]) - 1) . $dotSplitted[0];
}
|
[
"public",
"static",
"function",
"convertExponentialToString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"result",
"=",
"explode",
"(",
"'E'",
",",
"strtoupper",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"===",
"1",
")",
"{",
"return",
"$",
"result",
"[",
"0",
"]",
";",
"}",
"$",
"dotSplitted",
"=",
"explode",
"(",
"'.'",
",",
"$",
"result",
"[",
"0",
"]",
")",
";",
"return",
"'0.'",
".",
"str_repeat",
"(",
"'0'",
",",
"abs",
"(",
"$",
"result",
"[",
"1",
"]",
")",
"-",
"1",
")",
".",
"$",
"dotSplitted",
"[",
"0",
"]",
";",
"}"
] |
Converts the given exponential value to a string.
@param float|string $value The exponential value to convert.
@return string
|
[
"Converts",
"the",
"given",
"exponential",
"value",
"to",
"a",
"string",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/Utils.php#L140-L155
|
234,204
|
phpmath/bignumber
|
src/Utils.php
|
Utils.multiply
|
public static function multiply(BigNumber $lft, BigNumber $rgt, $scale = 10, $mutable = true)
{
$bigNumber = new BigNumber($lft, $scale, $mutable);
return $bigNumber->multiply($rgt);
}
|
php
|
public static function multiply(BigNumber $lft, BigNumber $rgt, $scale = 10, $mutable = true)
{
$bigNumber = new BigNumber($lft, $scale, $mutable);
return $bigNumber->multiply($rgt);
}
|
[
"public",
"static",
"function",
"multiply",
"(",
"BigNumber",
"$",
"lft",
",",
"BigNumber",
"$",
"rgt",
",",
"$",
"scale",
"=",
"10",
",",
"$",
"mutable",
"=",
"true",
")",
"{",
"$",
"bigNumber",
"=",
"new",
"BigNumber",
"(",
"$",
"lft",
",",
"$",
"scale",
",",
"$",
"mutable",
")",
";",
"return",
"$",
"bigNumber",
"->",
"multiply",
"(",
"$",
"rgt",
")",
";",
"}"
] |
Multiplies the two given numbers.
@param BigNumber $lft The left number.
@param BigNumber $rgt The right number.
@param int $scale The scale of the calculated number.
@param bool $mutable Whether or not the result is mutable.
@return BigNumber
|
[
"Multiplies",
"the",
"two",
"given",
"numbers",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/Utils.php#L166-L171
|
234,205
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php
|
Zend_Validate_File_ImageSize.setImageMax
|
public function setImageMax($maxwidth, $maxheight)
{
if ($maxwidth === null) {
$tempwidth = null;
} else if (($this->_minwidth !== null) and ($maxwidth < $this->_minwidth)) {
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum image width must be greater than or equal to the "
. "minimum image width, but {$maxwidth} < {$this->_minwidth}"
);
} else {
$tempwidth = (integer) $maxwidth;
}
if ($maxheight === null) {
$tempheight = null;
} else if (($this->_minheight !== null) and ($maxheight < $this->_minheight)) {
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum image height must be greater than or equal to the "
. "minimum image height, but {$maxheight} < {$this->_minwidth}"
);
} else {
$tempheight = (integer) $maxheight;
}
$this->_maxwidth = $tempwidth;
$this->_maxheight = $tempheight;
return $this;
}
|
php
|
public function setImageMax($maxwidth, $maxheight)
{
if ($maxwidth === null) {
$tempwidth = null;
} else if (($this->_minwidth !== null) and ($maxwidth < $this->_minwidth)) {
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum image width must be greater than or equal to the "
. "minimum image width, but {$maxwidth} < {$this->_minwidth}"
);
} else {
$tempwidth = (integer) $maxwidth;
}
if ($maxheight === null) {
$tempheight = null;
} else if (($this->_minheight !== null) and ($maxheight < $this->_minheight)) {
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum image height must be greater than or equal to the "
. "minimum image height, but {$maxheight} < {$this->_minwidth}"
);
} else {
$tempheight = (integer) $maxheight;
}
$this->_maxwidth = $tempwidth;
$this->_maxheight = $tempheight;
return $this;
}
|
[
"public",
"function",
"setImageMax",
"(",
"$",
"maxwidth",
",",
"$",
"maxheight",
")",
"{",
"if",
"(",
"$",
"maxwidth",
"===",
"null",
")",
"{",
"$",
"tempwidth",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"this",
"->",
"_minwidth",
"!==",
"null",
")",
"and",
"(",
"$",
"maxwidth",
"<",
"$",
"this",
"->",
"_minwidth",
")",
")",
"{",
"include_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The maximum image width must be greater than or equal to the \"",
".",
"\"minimum image width, but {$maxwidth} < {$this->_minwidth}\"",
")",
";",
"}",
"else",
"{",
"$",
"tempwidth",
"=",
"(",
"integer",
")",
"$",
"maxwidth",
";",
"}",
"if",
"(",
"$",
"maxheight",
"===",
"null",
")",
"{",
"$",
"tempheight",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"this",
"->",
"_minheight",
"!==",
"null",
")",
"and",
"(",
"$",
"maxheight",
"<",
"$",
"this",
"->",
"_minheight",
")",
")",
"{",
"include_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The maximum image height must be greater than or equal to the \"",
".",
"\"minimum image height, but {$maxheight} < {$this->_minwidth}\"",
")",
";",
"}",
"else",
"{",
"$",
"tempheight",
"=",
"(",
"integer",
")",
"$",
"maxheight",
";",
"}",
"$",
"this",
"->",
"_maxwidth",
"=",
"$",
"tempwidth",
";",
"$",
"this",
"->",
"_maxheight",
"=",
"$",
"tempheight",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the maximum image size
@param integer $maxwidth The maximum image width
@param integer $maxheight The maximum image height
@throws Zend_Validate_Exception When maxwidth is smaller than minwidth
@throws Zend_Validate_Exception When maxheight is smaller than minheight
@return Zend_Validate_StringLength Provides a fluent interface
|
[
"Sets",
"the",
"maximum",
"image",
"size"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php#L219-L248
|
234,206
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php
|
Zend_Validate_File_ImageSize.setImageWidth
|
public function setImageWidth($minwidth, $maxwidth)
{
$this->setImageMin($minwidth, $this->_minheight);
$this->setImageMax($maxwidth, $this->_maxheight);
return $this;
}
|
php
|
public function setImageWidth($minwidth, $maxwidth)
{
$this->setImageMin($minwidth, $this->_minheight);
$this->setImageMax($maxwidth, $this->_maxheight);
return $this;
}
|
[
"public",
"function",
"setImageWidth",
"(",
"$",
"minwidth",
",",
"$",
"maxwidth",
")",
"{",
"$",
"this",
"->",
"setImageMin",
"(",
"$",
"minwidth",
",",
"$",
"this",
"->",
"_minheight",
")",
";",
"$",
"this",
"->",
"setImageMax",
"(",
"$",
"maxwidth",
",",
"$",
"this",
"->",
"_maxheight",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the mimimum and maximum image width
@param integer $minwidth The minimum image width
@param integer $maxwidth The maximum image width
@return Zend_Validate_File_ImageSize Provides a fluent interface
|
[
"Sets",
"the",
"mimimum",
"and",
"maximum",
"image",
"width"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php#L257-L262
|
234,207
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php
|
Zend_Validate_File_ImageSize.setImageHeight
|
public function setImageHeight($minheight, $maxheight)
{
$this->setImageMin($this->_minwidth, $minheight);
$this->setImageMax($this->_maxwidth, $maxheight);
return $this;
}
|
php
|
public function setImageHeight($minheight, $maxheight)
{
$this->setImageMin($this->_minwidth, $minheight);
$this->setImageMax($this->_maxwidth, $maxheight);
return $this;
}
|
[
"public",
"function",
"setImageHeight",
"(",
"$",
"minheight",
",",
"$",
"maxheight",
")",
"{",
"$",
"this",
"->",
"setImageMin",
"(",
"$",
"this",
"->",
"_minwidth",
",",
"$",
"minheight",
")",
";",
"$",
"this",
"->",
"setImageMax",
"(",
"$",
"this",
"->",
"_maxwidth",
",",
"$",
"maxheight",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the mimimum and maximum image height
@param integer $minheight The minimum image height
@param integer $maxheight The maximum image height
@return Zend_Validate_File_ImageSize Provides a fluent interface
|
[
"Sets",
"the",
"mimimum",
"and",
"maximum",
"image",
"height"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/ImageSize.php#L271-L276
|
234,208
|
txj123/zilf
|
src/Zilf/Db/base/Module.php
|
Module.getInstance
|
public static function getInstance()
{
$class = get_called_class();
return isset(Zilf::$app->loadedModules[$class]) ? Zilf::$app->loadedModules[$class] : null;
}
|
php
|
public static function getInstance()
{
$class = get_called_class();
return isset(Zilf::$app->loadedModules[$class]) ? Zilf::$app->loadedModules[$class] : null;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"return",
"isset",
"(",
"Zilf",
"::",
"$",
"app",
"->",
"loadedModules",
"[",
"$",
"class",
"]",
")",
"?",
"Zilf",
"::",
"$",
"app",
"->",
"loadedModules",
"[",
"$",
"class",
"]",
":",
"null",
";",
"}"
] |
Returns the currently requested instance of this module class.
If the module class is not currently requested, `null` will be returned.
This method is provided so that you access the module instance from anywhere within the module.
@return static|null the currently requested instance of this module class, or `null` if the module class is not requested.
|
[
"Returns",
"the",
"currently",
"requested",
"instance",
"of",
"this",
"module",
"class",
".",
"If",
"the",
"module",
"class",
"is",
"not",
"currently",
"requested",
"null",
"will",
"be",
"returned",
".",
"This",
"method",
"is",
"provided",
"so",
"that",
"you",
"access",
"the",
"module",
"instance",
"from",
"anywhere",
"within",
"the",
"module",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Module.php#L170-L174
|
234,209
|
kiwiz/esquery
|
src/Result.php
|
Result.execute
|
public function execute() {
if(is_null($this->client)) {
$this->client = $this->getConnection();
}
if(is_null($this->query)) {
throw new Exception('No query');
}
list($query_data, $meta) = $this->constructQuery($this->source, $this->query, $this->aggs, $this->post_query, $this->settings);
$results_set = $this->query($query_data, $meta);
$results = $this->processResults($results_set, $meta);
$results = $this->postProcessResults($this->post_query, $results, $meta);
return $results;
}
|
php
|
public function execute() {
if(is_null($this->client)) {
$this->client = $this->getConnection();
}
if(is_null($this->query)) {
throw new Exception('No query');
}
list($query_data, $meta) = $this->constructQuery($this->source, $this->query, $this->aggs, $this->post_query, $this->settings);
$results_set = $this->query($query_data, $meta);
$results = $this->processResults($results_set, $meta);
$results = $this->postProcessResults($this->post_query, $results, $meta);
return $results;
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"client",
")",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"query",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No query'",
")",
";",
"}",
"list",
"(",
"$",
"query_data",
",",
"$",
"meta",
")",
"=",
"$",
"this",
"->",
"constructQuery",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"aggs",
",",
"$",
"this",
"->",
"post_query",
",",
"$",
"this",
"->",
"settings",
")",
";",
"$",
"results_set",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"query_data",
",",
"$",
"meta",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"processResults",
"(",
"$",
"results_set",
",",
"$",
"meta",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"postProcessResults",
"(",
"$",
"this",
"->",
"post_query",
",",
"$",
"results",
",",
"$",
"meta",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Process the query and return the results.
|
[
"Process",
"the",
"query",
"and",
"return",
"the",
"results",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Result.php#L86-L101
|
234,210
|
kiwiz/esquery
|
src/Result.php
|
Result.jsonSerialize
|
public function jsonSerialize() {
list($query_data, $meta) = $this->constructQuery($this->source, $this->query, $this->aggs, $this->post_query, $this->settings);
return $query_data;
}
|
php
|
public function jsonSerialize() {
list($query_data, $meta) = $this->constructQuery($this->source, $this->query, $this->aggs, $this->post_query, $this->settings);
return $query_data;
}
|
[
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"list",
"(",
"$",
"query_data",
",",
"$",
"meta",
")",
"=",
"$",
"this",
"->",
"constructQuery",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"aggs",
",",
"$",
"this",
"->",
"post_query",
",",
"$",
"this",
"->",
"settings",
")",
";",
"return",
"$",
"query_data",
";",
"}"
] |
Output the query as a json string.
|
[
"Output",
"the",
"query",
"as",
"a",
"json",
"string",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Result.php#L137-L141
|
234,211
|
kiwiz/esquery
|
src/Result.php
|
Result.constructSettings
|
private function constructSettings($settings) {
$ret = [];
if(array_key_exists('fields', $settings)) {
$ret['_source'] = ['include' => $settings['fields']];
}
if(array_key_exists('sort', $settings)) {
$ret['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $settings['sort']);
}
$valid_keys = ['size'];
foreach($valid_keys as $key) {
if(array_key_exists($key, $settings)) {
$ret[$key] = $settings[$key];
}
}
return $ret;
}
|
php
|
private function constructSettings($settings) {
$ret = [];
if(array_key_exists('fields', $settings)) {
$ret['_source'] = ['include' => $settings['fields']];
}
if(array_key_exists('sort', $settings)) {
$ret['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $settings['sort']);
}
$valid_keys = ['size'];
foreach($valid_keys as $key) {
if(array_key_exists($key, $settings)) {
$ret[$key] = $settings[$key];
}
}
return $ret;
}
|
[
"private",
"function",
"constructSettings",
"(",
"$",
"settings",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'fields'",
",",
"$",
"settings",
")",
")",
"{",
"$",
"ret",
"[",
"'_source'",
"]",
"=",
"[",
"'include'",
"=>",
"$",
"settings",
"[",
"'fields'",
"]",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'sort'",
",",
"$",
"settings",
")",
")",
"{",
"$",
"ret",
"[",
"'sort'",
"]",
"=",
"array_map",
"(",
"function",
"(",
"$",
"x",
")",
"{",
"return",
"[",
"$",
"x",
"[",
"0",
"]",
"=>",
"[",
"'order'",
"=>",
"$",
"x",
"[",
"1",
"]",
"?",
"'asc'",
":",
"'desc'",
"]",
"]",
";",
"}",
",",
"$",
"settings",
"[",
"'sort'",
"]",
")",
";",
"}",
"$",
"valid_keys",
"=",
"[",
"'size'",
"]",
";",
"foreach",
"(",
"$",
"valid_keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"settings",
")",
")",
"{",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"$",
"settings",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Construct settings for the request body.
|
[
"Construct",
"settings",
"for",
"the",
"request",
"body",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Result.php#L487-L506
|
234,212
|
kiwiz/esquery
|
src/Result.php
|
Result.processHitResultsRecurse
|
private function processHitResultsRecurse($results, $prefix=null) {
if(!is_array($results)) {
return [$prefix => $results];
}
$ret = [];
foreach($results as $key=>$result) {
// Flatten arrays.
$sub_prefix = is_null($prefix) ? $key:"$prefix.$key";
$ret = array_merge($ret, $this->processHitResultsRecurse($result, $sub_prefix));
}
return $ret;
}
|
php
|
private function processHitResultsRecurse($results, $prefix=null) {
if(!is_array($results)) {
return [$prefix => $results];
}
$ret = [];
foreach($results as $key=>$result) {
// Flatten arrays.
$sub_prefix = is_null($prefix) ? $key:"$prefix.$key";
$ret = array_merge($ret, $this->processHitResultsRecurse($result, $sub_prefix));
}
return $ret;
}
|
[
"private",
"function",
"processHitResultsRecurse",
"(",
"$",
"results",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"results",
")",
")",
"{",
"return",
"[",
"$",
"prefix",
"=>",
"$",
"results",
"]",
";",
"}",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"key",
"=>",
"$",
"result",
")",
"{",
"// Flatten arrays.",
"$",
"sub_prefix",
"=",
"is_null",
"(",
"$",
"prefix",
")",
"?",
"$",
"key",
":",
"\"$prefix.$key\"",
";",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"this",
"->",
"processHitResultsRecurse",
"(",
"$",
"result",
",",
"$",
"sub_prefix",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Process any hit results recursively.
|
[
"Process",
"any",
"hit",
"results",
"recursively",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Result.php#L582-L594
|
234,213
|
kiwiz/esquery
|
src/Result.php
|
Result.postProcessResults
|
private function postProcessResults($post_query, $results, $meta) {
if(is_null($post_query)) {
return $results;
}
$ret = [];
switch($post_query[0]) {
// Join up all results with a given key:value.
case Token::C_TRANS:
$key = $post_query[1];
$ret_map = [];
foreach($results as $result) {
if(!array_key_exists($key, $result)) {
continue;
}
$value = $result[$key];
if(!array_key_exists($value, $ret_map)) {
$ret_map[$value] = [];
}
$ret_map[$value] = array_merge($ret_map[$value], $result);
}
$ret = array_values($ret_map);
break;
default:
throw new Exception('Unexpected command');
}
// If we wanted a count, generate it now.
if($meta['count']) {
$ret = ['count' => count($ret)];
}
return $ret;
}
|
php
|
private function postProcessResults($post_query, $results, $meta) {
if(is_null($post_query)) {
return $results;
}
$ret = [];
switch($post_query[0]) {
// Join up all results with a given key:value.
case Token::C_TRANS:
$key = $post_query[1];
$ret_map = [];
foreach($results as $result) {
if(!array_key_exists($key, $result)) {
continue;
}
$value = $result[$key];
if(!array_key_exists($value, $ret_map)) {
$ret_map[$value] = [];
}
$ret_map[$value] = array_merge($ret_map[$value], $result);
}
$ret = array_values($ret_map);
break;
default:
throw new Exception('Unexpected command');
}
// If we wanted a count, generate it now.
if($meta['count']) {
$ret = ['count' => count($ret)];
}
return $ret;
}
|
[
"private",
"function",
"postProcessResults",
"(",
"$",
"post_query",
",",
"$",
"results",
",",
"$",
"meta",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"post_query",
")",
")",
"{",
"return",
"$",
"results",
";",
"}",
"$",
"ret",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"post_query",
"[",
"0",
"]",
")",
"{",
"// Join up all results with a given key:value.",
"case",
"Token",
"::",
"C_TRANS",
":",
"$",
"key",
"=",
"$",
"post_query",
"[",
"1",
"]",
";",
"$",
"ret_map",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"result",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"result",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"ret_map",
")",
")",
"{",
"$",
"ret_map",
"[",
"$",
"value",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"ret_map",
"[",
"$",
"value",
"]",
"=",
"array_merge",
"(",
"$",
"ret_map",
"[",
"$",
"value",
"]",
",",
"$",
"result",
")",
";",
"}",
"$",
"ret",
"=",
"array_values",
"(",
"$",
"ret_map",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Unexpected command'",
")",
";",
"}",
"// If we wanted a count, generate it now.",
"if",
"(",
"$",
"meta",
"[",
"'count'",
"]",
")",
"{",
"$",
"ret",
"=",
"[",
"'count'",
"=>",
"count",
"(",
"$",
"ret",
")",
"]",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Run any post-processing steps on the results.
|
[
"Run",
"any",
"post",
"-",
"processing",
"steps",
"on",
"the",
"results",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Result.php#L631-L667
|
234,214
|
awurth/SlimHelpers
|
Controller/RouterTrait.php
|
RouterTrait.path
|
protected function path($route, array $params = [], array $queryParams = [])
{
return $this->container['router']->pathFor($route, $params, $queryParams);
}
|
php
|
protected function path($route, array $params = [], array $queryParams = [])
{
return $this->container['router']->pathFor($route, $params, $queryParams);
}
|
[
"protected",
"function",
"path",
"(",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"'router'",
"]",
"->",
"pathFor",
"(",
"$",
"route",
",",
"$",
"params",
",",
"$",
"queryParams",
")",
";",
"}"
] |
Generates a URL from a route.
@param string $route
@param array $params
@param array $queryParams
@return string
|
[
"Generates",
"a",
"URL",
"from",
"a",
"route",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/RouterTrait.php#L18-L21
|
234,215
|
awurth/SlimHelpers
|
Controller/RouterTrait.php
|
RouterTrait.relativePath
|
protected function relativePath($route, array $params = [], array $queryParams = [])
{
return $this->container['router']->relativePathFor($route, $params, $queryParams);
}
|
php
|
protected function relativePath($route, array $params = [], array $queryParams = [])
{
return $this->container['router']->relativePathFor($route, $params, $queryParams);
}
|
[
"protected",
"function",
"relativePath",
"(",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"'router'",
"]",
"->",
"relativePathFor",
"(",
"$",
"route",
",",
"$",
"params",
",",
"$",
"queryParams",
")",
";",
"}"
] |
Generates a relative URL from a route.
@param string $route
@param array $params
@param array $queryParams
@return string
|
[
"Generates",
"a",
"relative",
"URL",
"from",
"a",
"route",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/RouterTrait.php#L32-L35
|
234,216
|
awurth/SlimHelpers
|
Controller/RouterTrait.php
|
RouterTrait.redirect
|
protected function redirect(Response $response, $route, array $params = [])
{
return $response->withRedirect($this->container['router']->pathFor($route, $params));
}
|
php
|
protected function redirect(Response $response, $route, array $params = [])
{
return $response->withRedirect($this->container['router']->pathFor($route, $params));
}
|
[
"protected",
"function",
"redirect",
"(",
"Response",
"$",
"response",
",",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"response",
"->",
"withRedirect",
"(",
"$",
"this",
"->",
"container",
"[",
"'router'",
"]",
"->",
"pathFor",
"(",
"$",
"route",
",",
"$",
"params",
")",
")",
";",
"}"
] |
Redirects to a route.
@param Response $response
@param string $route
@param array $params
@return Response
|
[
"Redirects",
"to",
"a",
"route",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/RouterTrait.php#L46-L49
|
234,217
|
geocoder-php/maxmind-provider
|
MaxMind.php
|
MaxMind.fieldsForService
|
private function fieldsForService(string $service): array
{
switch ($service) {
case self::CITY_EXTENDED_SERVICE:
return [
'countryCode',
'regionCode',
'locality',
'postalCode',
'latitude',
'longitude',
'metroCode',
'areaCode',
'isp',
'organization',
];
case self::OMNI_SERVICE:
return [
'countryCode',
'countryName',
'regionCode',
'region',
'locality',
'latitude',
'longitude',
'metroCode',
'areaCode',
'timezone',
'continentCode',
'postalCode',
'isp',
'organization',
'domain',
'asNumber',
'netspeed',
'userType',
'accuracyRadius',
'countryConfidence',
'cityConfidence',
'regionConfidence',
'postalConfidence',
'error',
];
default:
throw new UnsupportedOperation(sprintf('Unknown MaxMind service %s', $service));
}
}
|
php
|
private function fieldsForService(string $service): array
{
switch ($service) {
case self::CITY_EXTENDED_SERVICE:
return [
'countryCode',
'regionCode',
'locality',
'postalCode',
'latitude',
'longitude',
'metroCode',
'areaCode',
'isp',
'organization',
];
case self::OMNI_SERVICE:
return [
'countryCode',
'countryName',
'regionCode',
'region',
'locality',
'latitude',
'longitude',
'metroCode',
'areaCode',
'timezone',
'continentCode',
'postalCode',
'isp',
'organization',
'domain',
'asNumber',
'netspeed',
'userType',
'accuracyRadius',
'countryConfidence',
'cityConfidence',
'regionConfidence',
'postalConfidence',
'error',
];
default:
throw new UnsupportedOperation(sprintf('Unknown MaxMind service %s', $service));
}
}
|
[
"private",
"function",
"fieldsForService",
"(",
"string",
"$",
"service",
")",
":",
"array",
"{",
"switch",
"(",
"$",
"service",
")",
"{",
"case",
"self",
"::",
"CITY_EXTENDED_SERVICE",
":",
"return",
"[",
"'countryCode'",
",",
"'regionCode'",
",",
"'locality'",
",",
"'postalCode'",
",",
"'latitude'",
",",
"'longitude'",
",",
"'metroCode'",
",",
"'areaCode'",
",",
"'isp'",
",",
"'organization'",
",",
"]",
";",
"case",
"self",
"::",
"OMNI_SERVICE",
":",
"return",
"[",
"'countryCode'",
",",
"'countryName'",
",",
"'regionCode'",
",",
"'region'",
",",
"'locality'",
",",
"'latitude'",
",",
"'longitude'",
",",
"'metroCode'",
",",
"'areaCode'",
",",
"'timezone'",
",",
"'continentCode'",
",",
"'postalCode'",
",",
"'isp'",
",",
"'organization'",
",",
"'domain'",
",",
"'asNumber'",
",",
"'netspeed'",
",",
"'userType'",
",",
"'accuracyRadius'",
",",
"'countryConfidence'",
",",
"'cityConfidence'",
",",
"'regionConfidence'",
",",
"'postalConfidence'",
",",
"'error'",
",",
"]",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperation",
"(",
"sprintf",
"(",
"'Unknown MaxMind service %s'",
",",
"$",
"service",
")",
")",
";",
"}",
"}"
] |
We do not support Country and City services because they do not return much fields.
@see http://dev.maxmind.com/geoip/web-services
@param string $service
@return string[]
|
[
"We",
"do",
"not",
"support",
"Country",
"and",
"City",
"services",
"because",
"they",
"do",
"not",
"return",
"much",
"fields",
"."
] |
eddb07f690036fc95dd411de42158a68fb114cd8
|
https://github.com/geocoder-php/maxmind-provider/blob/eddb07f690036fc95dd411de42158a68fb114cd8/MaxMind.php#L180-L226
|
234,218
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Cookie.php
|
Zend_Http_Cookie.isExpired
|
public function isExpired($now = null)
{
if ($now === null) { $now = time();
}
if (is_int($this->expires) && $this->expires < $now) {
return true;
} else {
return false;
}
}
|
php
|
public function isExpired($now = null)
{
if ($now === null) { $now = time();
}
if (is_int($this->expires) && $this->expires < $now) {
return true;
} else {
return false;
}
}
|
[
"public",
"function",
"isExpired",
"(",
"$",
"now",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"now",
"===",
"null",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"this",
"->",
"expires",
")",
"&&",
"$",
"this",
"->",
"expires",
"<",
"$",
"now",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Check whether the cookie has expired
Always returns false if the cookie is a session cookie (has no expiry time)
@param int $now Timestamp to consider as "now"
@return boolean
|
[
"Check",
"whether",
"the",
"cookie",
"has",
"expired"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Cookie.php#L189-L198
|
234,219
|
mcustiel/php-simple-di
|
src/Dependency.php
|
Dependency.get
|
public function get()
{
if (! $this->singleton) {
return call_user_func($this->loader);
}
if ($this->object === null) {
$this->object = call_user_func($this->loader);
}
return $this->object;
}
|
php
|
public function get()
{
if (! $this->singleton) {
return call_user_func($this->loader);
}
if ($this->object === null) {
$this->object = call_user_func($this->loader);
}
return $this->object;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"singleton",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"loader",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"object",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"object",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"loader",
")",
";",
"}",
"return",
"$",
"this",
"->",
"object",
";",
"}"
] |
Returns the specific dependency instance.
@return mixed
|
[
"Returns",
"the",
"specific",
"dependency",
"instance",
"."
] |
da0116625d9704185c4a9f01210469266970b265
|
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/Dependency.php#L47-L57
|
234,220
|
txj123/zilf
|
src/Zilf/Queue/RedisQueue.php
|
RedisQueue.blockingPop
|
protected function blockingPop($queue)
{
$rawBody = $this->getConnection()->blpop($queue, $this->blockFor);
if (! empty($rawBody)) {
$payload = json_decode($rawBody[1], true);
$payload['attempts']++;
$reserved = json_encode($payload);
$this->getConnection()->zadd(
$queue.':reserved', [
$reserved => $this->availableAt($this->retryAfter),
]
);
return [$rawBody[1], $reserved];
}
return [null, null];
}
|
php
|
protected function blockingPop($queue)
{
$rawBody = $this->getConnection()->blpop($queue, $this->blockFor);
if (! empty($rawBody)) {
$payload = json_decode($rawBody[1], true);
$payload['attempts']++;
$reserved = json_encode($payload);
$this->getConnection()->zadd(
$queue.':reserved', [
$reserved => $this->availableAt($this->retryAfter),
]
);
return [$rawBody[1], $reserved];
}
return [null, null];
}
|
[
"protected",
"function",
"blockingPop",
"(",
"$",
"queue",
")",
"{",
"$",
"rawBody",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"blpop",
"(",
"$",
"queue",
",",
"$",
"this",
"->",
"blockFor",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rawBody",
")",
")",
"{",
"$",
"payload",
"=",
"json_decode",
"(",
"$",
"rawBody",
"[",
"1",
"]",
",",
"true",
")",
";",
"$",
"payload",
"[",
"'attempts'",
"]",
"++",
";",
"$",
"reserved",
"=",
"json_encode",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"zadd",
"(",
"$",
"queue",
".",
"':reserved'",
",",
"[",
"$",
"reserved",
"=>",
"$",
"this",
"->",
"availableAt",
"(",
"$",
"this",
"->",
"retryAfter",
")",
",",
"]",
")",
";",
"return",
"[",
"$",
"rawBody",
"[",
"1",
"]",
",",
"$",
"reserved",
"]",
";",
"}",
"return",
"[",
"null",
",",
"null",
"]",
";",
"}"
] |
Retrieve the next job by blocking-pop.
@param string $queue
@return array
|
[
"Retrieve",
"the",
"next",
"job",
"by",
"blocking",
"-",
"pop",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Queue/RedisQueue.php#L234-L255
|
234,221
|
txj123/zilf
|
src/Zilf/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php
|
MongoDbSessionHandler.createDateTime
|
private function createDateTime($seconds = null)
{
if (null === $seconds) {
$seconds = time();
}
if ($this->mongo instanceof \MongoDB\Client) {
return new \MongoDB\BSON\UTCDateTime($seconds * 1000);
}
return new \MongoDate($seconds);
}
|
php
|
private function createDateTime($seconds = null)
{
if (null === $seconds) {
$seconds = time();
}
if ($this->mongo instanceof \MongoDB\Client) {
return new \MongoDB\BSON\UTCDateTime($seconds * 1000);
}
return new \MongoDate($seconds);
}
|
[
"private",
"function",
"createDateTime",
"(",
"$",
"seconds",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"seconds",
")",
"{",
"$",
"seconds",
"=",
"time",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mongo",
"instanceof",
"\\",
"MongoDB",
"\\",
"Client",
")",
"{",
"return",
"new",
"\\",
"MongoDB",
"\\",
"BSON",
"\\",
"UTCDateTime",
"(",
"$",
"seconds",
"*",
"1000",
")",
";",
"}",
"return",
"new",
"\\",
"MongoDate",
"(",
"$",
"seconds",
")",
";",
"}"
] |
Create a date object using the class appropriate for the current mongo connection.
Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime
@param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now.
|
[
"Create",
"a",
"date",
"object",
"using",
"the",
"class",
"appropriate",
"for",
"the",
"current",
"mongo",
"connection",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php#L226-L237
|
234,222
|
txj123/zilf
|
src/Zilf/Db/Command.php
|
Command.logQuery
|
protected function logQuery($category)
{
if ($this->db->enableLogging) {
$rawSql = $this->getRawSql();
//Zilf::info($rawSql, $category);
}
if (!$this->db->enableProfiling) {
return [false, isset($rawSql) ? $rawSql : null];
}
return [true, isset($rawSql) ? $rawSql : $this->getRawSql()];
}
|
php
|
protected function logQuery($category)
{
if ($this->db->enableLogging) {
$rawSql = $this->getRawSql();
//Zilf::info($rawSql, $category);
}
if (!$this->db->enableProfiling) {
return [false, isset($rawSql) ? $rawSql : null];
}
return [true, isset($rawSql) ? $rawSql : $this->getRawSql()];
}
|
[
"protected",
"function",
"logQuery",
"(",
"$",
"category",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"enableLogging",
")",
"{",
"$",
"rawSql",
"=",
"$",
"this",
"->",
"getRawSql",
"(",
")",
";",
"//Zilf::info($rawSql, $category);",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
"->",
"enableProfiling",
")",
"{",
"return",
"[",
"false",
",",
"isset",
"(",
"$",
"rawSql",
")",
"?",
"$",
"rawSql",
":",
"null",
"]",
";",
"}",
"return",
"[",
"true",
",",
"isset",
"(",
"$",
"rawSql",
")",
"?",
"$",
"rawSql",
":",
"$",
"this",
"->",
"getRawSql",
"(",
")",
"]",
";",
"}"
] |
Logs the current database query if query logging is enabled and returns
the profiling token if profiling is enabled.
@param string $category the log category.
@return array array of two elements, the first is boolean of whether profiling is enabled or not.
The second is the rawSql if it has been created.
|
[
"Logs",
"the",
"current",
"database",
"query",
"if",
"query",
"logging",
"is",
"enabled",
"and",
"returns",
"the",
"profiling",
"token",
"if",
"profiling",
"is",
"enabled",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/Command.php#L1162-L1173
|
234,223
|
oxygen-cms/core
|
src/Html/Toolbar/Toolbar.php
|
Toolbar.setOrder
|
public function setOrder(array $keys) {
$this->itemsOrdered = [];
foreach($keys as $label => $value) {
if($value === 'spacer' || $value === '|') {
$this->itemsOrdered[] = $this->spacer;
} elseif(is_array($value)) {
$parts = explode(',', $label);
if($this->hasItem($parts[0])) {
$dropdown = new DropdownToolbarItem($parts[1]);
$dropdown->button = $this->getItem($parts[0]);
} else {
$dropdown = new DropdownToolbarItem($parts[0]);
}
foreach($value as $dropdownItem) {
$dropdown->addItem($this->getItem($dropdownItem));
}
$this->itemsOrdered[] = $dropdown;
} else {
$this->itemsOrdered[] = $this->getItem($value);
}
}
}
|
php
|
public function setOrder(array $keys) {
$this->itemsOrdered = [];
foreach($keys as $label => $value) {
if($value === 'spacer' || $value === '|') {
$this->itemsOrdered[] = $this->spacer;
} elseif(is_array($value)) {
$parts = explode(',', $label);
if($this->hasItem($parts[0])) {
$dropdown = new DropdownToolbarItem($parts[1]);
$dropdown->button = $this->getItem($parts[0]);
} else {
$dropdown = new DropdownToolbarItem($parts[0]);
}
foreach($value as $dropdownItem) {
$dropdown->addItem($this->getItem($dropdownItem));
}
$this->itemsOrdered[] = $dropdown;
} else {
$this->itemsOrdered[] = $this->getItem($value);
}
}
}
|
[
"public",
"function",
"setOrder",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"this",
"->",
"itemsOrdered",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"label",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'spacer'",
"||",
"$",
"value",
"===",
"'|'",
")",
"{",
"$",
"this",
"->",
"itemsOrdered",
"[",
"]",
"=",
"$",
"this",
"->",
"spacer",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"','",
",",
"$",
"label",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasItem",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
")",
"{",
"$",
"dropdown",
"=",
"new",
"DropdownToolbarItem",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"$",
"dropdown",
"->",
"button",
"=",
"$",
"this",
"->",
"getItem",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"$",
"dropdown",
"=",
"new",
"DropdownToolbarItem",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"value",
"as",
"$",
"dropdownItem",
")",
"{",
"$",
"dropdown",
"->",
"addItem",
"(",
"$",
"this",
"->",
"getItem",
"(",
"$",
"dropdownItem",
")",
")",
";",
"}",
"$",
"this",
"->",
"itemsOrdered",
"[",
"]",
"=",
"$",
"dropdown",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"itemsOrdered",
"[",
"]",
"=",
"$",
"this",
"->",
"getItem",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] |
Sets the order of items on the toolbar.
@param array $keys
@return void
|
[
"Sets",
"the",
"order",
"of",
"items",
"on",
"the",
"toolbar",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/Toolbar.php#L122-L145
|
234,224
|
oxygen-cms/core
|
src/Html/Toolbar/Toolbar.php
|
Toolbar.hasItem
|
public function hasItem($identifier) {
return isset($this->itemsPool[$this->prefix . '.' . $identifier]) || isset($this->itemsPool[$identifier]);
}
|
php
|
public function hasItem($identifier) {
return isset($this->itemsPool[$this->prefix . '.' . $identifier]) || isset($this->itemsPool[$identifier]);
}
|
[
"public",
"function",
"hasItem",
"(",
"$",
"identifier",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"itemsPool",
"[",
"$",
"this",
"->",
"prefix",
".",
"'.'",
".",
"$",
"identifier",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"itemsPool",
"[",
"$",
"identifier",
"]",
")",
";",
"}"
] |
Determines a ToolbarItem exists.
@param string $identifier
@return boolean
|
[
"Determines",
"a",
"ToolbarItem",
"exists",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/Toolbar.php#L153-L155
|
234,225
|
oxygen-cms/core
|
src/Html/Toolbar/Toolbar.php
|
Toolbar.getItem
|
public function getItem($identifier) {
if(!isset($this->itemsPool[$identifier]) && $this->prefix !== null) {
return $this->itemsPool[$this->prefix . '.' . $identifier];
}
return $this->itemsPool[$identifier];
}
|
php
|
public function getItem($identifier) {
if(!isset($this->itemsPool[$identifier]) && $this->prefix !== null) {
return $this->itemsPool[$this->prefix . '.' . $identifier];
}
return $this->itemsPool[$identifier];
}
|
[
"public",
"function",
"getItem",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"itemsPool",
"[",
"$",
"identifier",
"]",
")",
"&&",
"$",
"this",
"->",
"prefix",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"itemsPool",
"[",
"$",
"this",
"->",
"prefix",
".",
"'.'",
".",
"$",
"identifier",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"itemsPool",
"[",
"$",
"identifier",
"]",
";",
"}"
] |
Get a ToolbarItem.
@param string $identifier
@return ToolbarItem
|
[
"Get",
"a",
"ToolbarItem",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/Toolbar.php#L163-L169
|
234,226
|
jcchavezs/dd-trace-php
|
src/DdTrace/Tracer.php
|
Tracer.flushTraces
|
public function flushTraces()
{
$spans = $this->buffer->pop();
$spansCount = $spans->count();
if ($this->debugLoggingEnabled) {
$this->logger->debug(sprintf("Sending %d spans", $spansCount));
foreach($spans as $span) {
$this->logger->debug(sprintf("SPAN:\n%s", $span->__toString()));
}
}
if (!$this->isEnabled() || !$this->hasTransport() || $spansCount == 0) {
return;
}
$traceBuffer = TracesBuffer::fromSpanCollection($spans);
$this->transport->sendTraces($traceBuffer);
}
|
php
|
public function flushTraces()
{
$spans = $this->buffer->pop();
$spansCount = $spans->count();
if ($this->debugLoggingEnabled) {
$this->logger->debug(sprintf("Sending %d spans", $spansCount));
foreach($spans as $span) {
$this->logger->debug(sprintf("SPAN:\n%s", $span->__toString()));
}
}
if (!$this->isEnabled() || !$this->hasTransport() || $spansCount == 0) {
return;
}
$traceBuffer = TracesBuffer::fromSpanCollection($spans);
$this->transport->sendTraces($traceBuffer);
}
|
[
"public",
"function",
"flushTraces",
"(",
")",
"{",
"$",
"spans",
"=",
"$",
"this",
"->",
"buffer",
"->",
"pop",
"(",
")",
";",
"$",
"spansCount",
"=",
"$",
"spans",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debugLoggingEnabled",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"\"Sending %d spans\"",
",",
"$",
"spansCount",
")",
")",
";",
"foreach",
"(",
"$",
"spans",
"as",
"$",
"span",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"\"SPAN:\\n%s\"",
",",
"$",
"span",
"->",
"__toString",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"hasTransport",
"(",
")",
"||",
"$",
"spansCount",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"traceBuffer",
"=",
"TracesBuffer",
"::",
"fromSpanCollection",
"(",
"$",
"spans",
")",
";",
"$",
"this",
"->",
"transport",
"->",
"sendTraces",
"(",
"$",
"traceBuffer",
")",
";",
"}"
] |
FlushTraces will push any currently buffered traces to the server.
XXX Note that it is currently exported because some tests use it. They
really should not.
|
[
"FlushTraces",
"will",
"push",
"any",
"currently",
"buffered",
"traces",
"to",
"the",
"server",
".",
"XXX",
"Note",
"that",
"it",
"is",
"currently",
"exported",
"because",
"some",
"tests",
"use",
"it",
".",
"They",
"really",
"should",
"not",
"."
] |
d10be51fc63cb5bfc4de19c1880fe7b5397a8b0d
|
https://github.com/jcchavezs/dd-trace-php/blob/d10be51fc63cb5bfc4de19c1880fe7b5397a8b0d/src/DdTrace/Tracer.php#L74-L94
|
234,227
|
txj123/zilf
|
src/Zilf/Log/LogManager.php
|
LogManager.createSlackDriver
|
protected function createSlackDriver(array $config)
{
return new Monolog(
$this->parseChannel($config), [
$this->prepareHandler(
new SlackWebhookHandler(
$config['url'],
$config['channel'] ?? null,
$config['username'] ?? 'zilf',
$config['attachment'] ?? true,
$config['emoji'] ?? ':boom:',
$config['short'] ?? false,
$config['context'] ?? true,
$this->level($config)
)
),
]
);
}
|
php
|
protected function createSlackDriver(array $config)
{
return new Monolog(
$this->parseChannel($config), [
$this->prepareHandler(
new SlackWebhookHandler(
$config['url'],
$config['channel'] ?? null,
$config['username'] ?? 'zilf',
$config['attachment'] ?? true,
$config['emoji'] ?? ':boom:',
$config['short'] ?? false,
$config['context'] ?? true,
$this->level($config)
)
),
]
);
}
|
[
"protected",
"function",
"createSlackDriver",
"(",
"array",
"$",
"config",
")",
"{",
"return",
"new",
"Monolog",
"(",
"$",
"this",
"->",
"parseChannel",
"(",
"$",
"config",
")",
",",
"[",
"$",
"this",
"->",
"prepareHandler",
"(",
"new",
"SlackWebhookHandler",
"(",
"$",
"config",
"[",
"'url'",
"]",
",",
"$",
"config",
"[",
"'channel'",
"]",
"??",
"null",
",",
"$",
"config",
"[",
"'username'",
"]",
"??",
"'zilf'",
",",
"$",
"config",
"[",
"'attachment'",
"]",
"??",
"true",
",",
"$",
"config",
"[",
"'emoji'",
"]",
"??",
"':boom:'",
",",
"$",
"config",
"[",
"'short'",
"]",
"??",
"false",
",",
"$",
"config",
"[",
"'context'",
"]",
"??",
"true",
",",
"$",
"this",
"->",
"level",
"(",
"$",
"config",
")",
")",
")",
",",
"]",
")",
";",
"}"
] |
Create an instance of the Slack log driver.
@param array $config
@return \Psr\Log\LoggerInterface
|
[
"Create",
"an",
"instance",
"of",
"the",
"Slack",
"log",
"driver",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Log/LogManager.php#L296-L314
|
234,228
|
txj123/zilf
|
src/Zilf/Log/LogManager.php
|
LogManager.createSyslogDriver
|
protected function createSyslogDriver(array $config)
{
return new Monolog(
$this->parseChannel($config), [
$this->prepareHandler(
new SyslogHandler(
$this->app['config']['app.name'], $config['facility'] ?? LOG_USER, $this->level($config)
)
),
]
);
}
|
php
|
protected function createSyslogDriver(array $config)
{
return new Monolog(
$this->parseChannel($config), [
$this->prepareHandler(
new SyslogHandler(
$this->app['config']['app.name'], $config['facility'] ?? LOG_USER, $this->level($config)
)
),
]
);
}
|
[
"protected",
"function",
"createSyslogDriver",
"(",
"array",
"$",
"config",
")",
"{",
"return",
"new",
"Monolog",
"(",
"$",
"this",
"->",
"parseChannel",
"(",
"$",
"config",
")",
",",
"[",
"$",
"this",
"->",
"prepareHandler",
"(",
"new",
"SyslogHandler",
"(",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"[",
"'app.name'",
"]",
",",
"$",
"config",
"[",
"'facility'",
"]",
"??",
"LOG_USER",
",",
"$",
"this",
"->",
"level",
"(",
"$",
"config",
")",
")",
")",
",",
"]",
")",
";",
"}"
] |
Create an instance of the syslog log driver.
@param array $config
@return \Psr\Log\LoggerInterface
|
[
"Create",
"an",
"instance",
"of",
"the",
"syslog",
"log",
"driver",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Log/LogManager.php#L322-L333
|
234,229
|
txj123/zilf
|
src/Zilf/Log/LogManager.php
|
LogManager.createMonologDriver
|
protected function createMonologDriver(array $config)
{
if (!is_a($config['handler'], HandlerInterface::class, true)) {
throw new InvalidArgumentException(
$config['handler'] . ' must be an instance of ' . HandlerInterface::class
);
}
return new Monolog(
$this->parseChannel($config), [$this->prepareHandler(
$this->app->make($config['handler'], $config['with'] ?? []), $config
)]
);
}
|
php
|
protected function createMonologDriver(array $config)
{
if (!is_a($config['handler'], HandlerInterface::class, true)) {
throw new InvalidArgumentException(
$config['handler'] . ' must be an instance of ' . HandlerInterface::class
);
}
return new Monolog(
$this->parseChannel($config), [$this->prepareHandler(
$this->app->make($config['handler'], $config['with'] ?? []), $config
)]
);
}
|
[
"protected",
"function",
"createMonologDriver",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"config",
"[",
"'handler'",
"]",
",",
"HandlerInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"config",
"[",
"'handler'",
"]",
".",
"' must be an instance of '",
".",
"HandlerInterface",
"::",
"class",
")",
";",
"}",
"return",
"new",
"Monolog",
"(",
"$",
"this",
"->",
"parseChannel",
"(",
"$",
"config",
")",
",",
"[",
"$",
"this",
"->",
"prepareHandler",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"config",
"[",
"'handler'",
"]",
",",
"$",
"config",
"[",
"'with'",
"]",
"??",
"[",
"]",
")",
",",
"$",
"config",
")",
"]",
")",
";",
"}"
] |
Create an instance of any handler available in Monolog.
@param array $config
@return \Psr\Log\LoggerInterface
@throws \InvalidArgumentException
@throws \Illuminate\Contracts\Container\BindingResolutionException
|
[
"Create",
"an",
"instance",
"of",
"any",
"handler",
"available",
"in",
"Monolog",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Log/LogManager.php#L363-L376
|
234,230
|
oxygen-cms/core
|
src/View/StringView.php
|
StringView.gatherInfo
|
protected function gatherInfo() {
$info = new stdClass();
$info->contents = $this->contents;
$info->path = $this->path;
$info->lastModified = $this->lastModified;
return $info;
}
|
php
|
protected function gatherInfo() {
$info = new stdClass();
$info->contents = $this->contents;
$info->path = $this->path;
$info->lastModified = $this->lastModified;
return $info;
}
|
[
"protected",
"function",
"gatherInfo",
"(",
")",
"{",
"$",
"info",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"info",
"->",
"contents",
"=",
"$",
"this",
"->",
"contents",
";",
"$",
"info",
"->",
"path",
"=",
"$",
"this",
"->",
"path",
";",
"$",
"info",
"->",
"lastModified",
"=",
"$",
"this",
"->",
"lastModified",
";",
"return",
"$",
"info",
";",
"}"
] |
Gathers the information about the view.
@return \stdClass
|
[
"Gathers",
"the",
"information",
"about",
"the",
"view",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/StringView.php#L110-L117
|
234,231
|
railken/search-query
|
src/Languages/BoomTree/Resolvers/ValueResolver.php
|
ValueResolver.parseValue
|
public function parseValue($value)
{
if (strlen($value) === 0) {
return $value;
}
if ($value[0] === '"' || $value[0] === "'") {
$value = substr($value, 1, -1);
}
$value = stripslashes($value);
return $value;
}
|
php
|
public function parseValue($value)
{
if (strlen($value) === 0) {
return $value;
}
if ($value[0] === '"' || $value[0] === "'") {
$value = substr($value, 1, -1);
}
$value = stripslashes($value);
return $value;
}
|
[
"public",
"function",
"parseValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"===",
"0",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"[",
"0",
"]",
"===",
"'\"'",
"||",
"$",
"value",
"[",
"0",
"]",
"===",
"\"'\"",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"$",
"value",
"=",
"stripslashes",
"(",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}"
] |
Parse the value before adding to the node.
@param mixed $value
@return mixed
|
[
"Parse",
"the",
"value",
"before",
"adding",
"to",
"the",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/ValueResolver.php#L35-L48
|
234,232
|
oxygen-cms/core
|
src/Html/Form/EditableField.php
|
EditableField.getValue
|
public function getValue() {
if($this->input->old($this->getMeta()->name)) {
return $this->getMeta()->getType()->transformInput($this->getMeta(), $this->input->old($this->getMeta()->name));
} else {
if($this->value !== null) {
return parent::getValue();
} else {
return null;
}
}
}
|
php
|
public function getValue() {
if($this->input->old($this->getMeta()->name)) {
return $this->getMeta()->getType()->transformInput($this->getMeta(), $this->input->old($this->getMeta()->name));
} else {
if($this->value !== null) {
return parent::getValue();
} else {
return null;
}
}
}
|
[
"public",
"function",
"getValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"input",
"->",
"old",
"(",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"getType",
"(",
")",
"->",
"transformInput",
"(",
"$",
"this",
"->",
"getMeta",
"(",
")",
",",
"$",
"this",
"->",
"input",
"->",
"old",
"(",
"$",
"this",
"->",
"getMeta",
"(",
")",
"->",
"name",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"!==",
"null",
")",
"{",
"return",
"parent",
"::",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}"
] |
Get the value of the field.
@return mixed
|
[
"Get",
"the",
"value",
"of",
"the",
"field",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Form/EditableField.php#L49-L59
|
234,233
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Mapper/ScopeMapper.php
|
ScopeMapper.scope
|
public function scope($scope)
{
$scope = (new Scope())->scope($scope);
$this->scopes[] = $scope;
return $scope;
}
|
php
|
public function scope($scope)
{
$scope = (new Scope())->scope($scope);
$this->scopes[] = $scope;
return $scope;
}
|
[
"public",
"function",
"scope",
"(",
"$",
"scope",
")",
"{",
"$",
"scope",
"=",
"(",
"new",
"Scope",
"(",
")",
")",
"->",
"scope",
"(",
"$",
"scope",
")",
";",
"$",
"this",
"->",
"scopes",
"[",
"]",
"=",
"$",
"scope",
";",
"return",
"$",
"scope",
";",
"}"
] |
Add a scope.
@param string $scope
@access public
@return ScopeMapper
|
[
"Add",
"a",
"scope",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/ScopeMapper.php#L38-L44
|
234,234
|
awurth/SlimHelpers
|
Controller/RestTrait.php
|
RestTrait.created
|
protected function created(Response $response, $route, array $params = [])
{
return $this->redirect($response, $route, $params)->withStatus(201);
}
|
php
|
protected function created(Response $response, $route, array $params = [])
{
return $this->redirect($response, $route, $params)->withStatus(201);
}
|
[
"protected",
"function",
"created",
"(",
"Response",
"$",
"response",
",",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"response",
",",
"$",
"route",
",",
"$",
"params",
")",
"->",
"withStatus",
"(",
"201",
")",
";",
"}"
] |
Returns a "201 Created" response with a location header.
@param Response $response
@param string $route
@param array $params
@return Response
|
[
"Returns",
"a",
"201",
"Created",
"response",
"with",
"a",
"location",
"header",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/RestTrait.php#L33-L36
|
234,235
|
schmunk42/p3extensions
|
components/image/drivers/Image_ImageMagick_Driver.php
|
Image_ImageMagick_Driver.process
|
public function process($image, $actions, $dir, $file, $render = FALSE)
{
// We only need the filename
$image = $image['file'];
// Unique temporary filename
$this->tmp_image = $dir.'k2img--'.sha1(time().$dir.$file).substr($file, strrpos($file, '.'));
// Copy the image to the temporary file
copy($image, $this->tmp_image);
// Quality change is done last
if(isset ($actions['quality'])) {
$quality = $actions['quality'];
unset($actions['quality']);
}
// Use 95 for the default quality
empty($quality) and $quality = 95;
// All calls to these will need to be escaped, so do it now
$this->cmd_image = escapeshellarg($this->tmp_image);
$this->new_image = ($render)? $this->cmd_image : escapeshellarg($dir.$file);
if ($status = $this->execute($actions))
{
// Use convert to change the image into its final version. This is
// done to allow the file type to change correctly, and to handle
// the quality conversion in the most effective way possible.
if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -quality '.$quality.'% '.$this->cmd_image.' '.$this->new_image))
{
$this->errors[] = $error;
}
else
{
// Output the image directly to the browser
if ($render !== FALSE)
{
$contents = file_get_contents($this->tmp_image);
switch (substr($file, strrpos($file, '.') + 1))
{
case 'jpg':
case 'jpeg':
header('Content-Type: image/jpeg');
break;
case 'gif':
header('Content-Type: image/gif');
break;
case 'png':
header('Content-Type: image/png');
break;
}
echo $contents;
}
}
}
// Remove the temporary image
unlink($this->tmp_image);
$this->tmp_image = '';
return $status;
}
|
php
|
public function process($image, $actions, $dir, $file, $render = FALSE)
{
// We only need the filename
$image = $image['file'];
// Unique temporary filename
$this->tmp_image = $dir.'k2img--'.sha1(time().$dir.$file).substr($file, strrpos($file, '.'));
// Copy the image to the temporary file
copy($image, $this->tmp_image);
// Quality change is done last
if(isset ($actions['quality'])) {
$quality = $actions['quality'];
unset($actions['quality']);
}
// Use 95 for the default quality
empty($quality) and $quality = 95;
// All calls to these will need to be escaped, so do it now
$this->cmd_image = escapeshellarg($this->tmp_image);
$this->new_image = ($render)? $this->cmd_image : escapeshellarg($dir.$file);
if ($status = $this->execute($actions))
{
// Use convert to change the image into its final version. This is
// done to allow the file type to change correctly, and to handle
// the quality conversion in the most effective way possible.
if ($error = exec(escapeshellcmd($this->dir.'convert'.$this->ext).' -quality '.$quality.'% '.$this->cmd_image.' '.$this->new_image))
{
$this->errors[] = $error;
}
else
{
// Output the image directly to the browser
if ($render !== FALSE)
{
$contents = file_get_contents($this->tmp_image);
switch (substr($file, strrpos($file, '.') + 1))
{
case 'jpg':
case 'jpeg':
header('Content-Type: image/jpeg');
break;
case 'gif':
header('Content-Type: image/gif');
break;
case 'png':
header('Content-Type: image/png');
break;
}
echo $contents;
}
}
}
// Remove the temporary image
unlink($this->tmp_image);
$this->tmp_image = '';
return $status;
}
|
[
"public",
"function",
"process",
"(",
"$",
"image",
",",
"$",
"actions",
",",
"$",
"dir",
",",
"$",
"file",
",",
"$",
"render",
"=",
"FALSE",
")",
"{",
"// We only need the filename",
"$",
"image",
"=",
"$",
"image",
"[",
"'file'",
"]",
";",
"// Unique temporary filename",
"$",
"this",
"->",
"tmp_image",
"=",
"$",
"dir",
".",
"'k2img--'",
".",
"sha1",
"(",
"time",
"(",
")",
".",
"$",
"dir",
".",
"$",
"file",
")",
".",
"substr",
"(",
"$",
"file",
",",
"strrpos",
"(",
"$",
"file",
",",
"'.'",
")",
")",
";",
"// Copy the image to the temporary file",
"copy",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"tmp_image",
")",
";",
"// Quality change is done last",
"if",
"(",
"isset",
"(",
"$",
"actions",
"[",
"'quality'",
"]",
")",
")",
"{",
"$",
"quality",
"=",
"$",
"actions",
"[",
"'quality'",
"]",
";",
"unset",
"(",
"$",
"actions",
"[",
"'quality'",
"]",
")",
";",
"}",
"// Use 95 for the default quality",
"empty",
"(",
"$",
"quality",
")",
"and",
"$",
"quality",
"=",
"95",
";",
"// All calls to these will need to be escaped, so do it now",
"$",
"this",
"->",
"cmd_image",
"=",
"escapeshellarg",
"(",
"$",
"this",
"->",
"tmp_image",
")",
";",
"$",
"this",
"->",
"new_image",
"=",
"(",
"$",
"render",
")",
"?",
"$",
"this",
"->",
"cmd_image",
":",
"escapeshellarg",
"(",
"$",
"dir",
".",
"$",
"file",
")",
";",
"if",
"(",
"$",
"status",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"actions",
")",
")",
"{",
"// Use convert to change the image into its final version. This is",
"// done to allow the file type to change correctly, and to handle",
"// the quality conversion in the most effective way possible.",
"if",
"(",
"$",
"error",
"=",
"exec",
"(",
"escapeshellcmd",
"(",
"$",
"this",
"->",
"dir",
".",
"'convert'",
".",
"$",
"this",
"->",
"ext",
")",
".",
"' -quality '",
".",
"$",
"quality",
".",
"'% '",
".",
"$",
"this",
"->",
"cmd_image",
".",
"' '",
".",
"$",
"this",
"->",
"new_image",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"else",
"{",
"// Output the image directly to the browser",
"if",
"(",
"$",
"render",
"!==",
"FALSE",
")",
"{",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"tmp_image",
")",
";",
"switch",
"(",
"substr",
"(",
"$",
"file",
",",
"strrpos",
"(",
"$",
"file",
",",
"'.'",
")",
"+",
"1",
")",
")",
"{",
"case",
"'jpg'",
":",
"case",
"'jpeg'",
":",
"header",
"(",
"'Content-Type: image/jpeg'",
")",
";",
"break",
";",
"case",
"'gif'",
":",
"header",
"(",
"'Content-Type: image/gif'",
")",
";",
"break",
";",
"case",
"'png'",
":",
"header",
"(",
"'Content-Type: image/png'",
")",
";",
"break",
";",
"}",
"echo",
"$",
"contents",
";",
"}",
"}",
"}",
"// Remove the temporary image",
"unlink",
"(",
"$",
"this",
"->",
"tmp_image",
")",
";",
"$",
"this",
"->",
"tmp_image",
"=",
"''",
";",
"return",
"$",
"status",
";",
"}"
] |
Creates a temporary image and executes the given actions. By creating a
temporary copy of the image before manipulating it, this process is atomic.
|
[
"Creates",
"a",
"temporary",
"image",
"and",
"executes",
"the",
"given",
"actions",
".",
"By",
"creating",
"a",
"temporary",
"copy",
"of",
"the",
"image",
"before",
"manipulating",
"it",
"this",
"process",
"is",
"atomic",
"."
] |
93999c06fc8e3eadd83983d001df231e46b06838
|
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/image/drivers/Image_ImageMagick_Driver.php#L57-L119
|
234,236
|
oxygen-cms/core
|
src/Routing/BlueprintRegistrar.php
|
BlueprintRegistrar.blueprint
|
public function blueprint(Blueprint $blueprint) {
foreach($blueprint->getActions() as $action) {
$this->action($action);
}
}
|
php
|
public function blueprint(Blueprint $blueprint) {
foreach($blueprint->getActions() as $action) {
$this->action($action);
}
}
|
[
"public",
"function",
"blueprint",
"(",
"Blueprint",
"$",
"blueprint",
")",
"{",
"foreach",
"(",
"$",
"blueprint",
"->",
"getActions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"action",
"(",
"$",
"action",
")",
";",
"}",
"}"
] |
Generates a Route from a \Oxygen\Core\Blueprint\Blueprint
@param \Oxygen\Core\Blueprint\Blueprint $blueprint
|
[
"Generates",
"a",
"Route",
"from",
"a",
"\\",
"Oxygen",
"\\",
"Core",
"\\",
"Blueprint",
"\\",
"Blueprint"
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Routing/BlueprintRegistrar.php#L36-L40
|
234,237
|
oxygen-cms/core
|
src/Routing/BlueprintRegistrar.php
|
BlueprintRegistrar.action
|
public function action(Action $action) {
if($action->register === Action::REGISTER_AT_END) {
$this->registerActionsLast[] = $action;
} else {
if($action->register) {
$this->registerAction($action);
}
}
}
|
php
|
public function action(Action $action) {
if($action->register === Action::REGISTER_AT_END) {
$this->registerActionsLast[] = $action;
} else {
if($action->register) {
$this->registerAction($action);
}
}
}
|
[
"public",
"function",
"action",
"(",
"Action",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"->",
"register",
"===",
"Action",
"::",
"REGISTER_AT_END",
")",
"{",
"$",
"this",
"->",
"registerActionsLast",
"[",
"]",
"=",
"$",
"action",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"action",
"->",
"register",
")",
"{",
"$",
"this",
"->",
"registerAction",
"(",
"$",
"action",
")",
";",
"}",
"}",
"}"
] |
Generates a Route from a Oxygen\Core\Action\Action
@param \Oxygen\Core\Action\Action $action
|
[
"Generates",
"a",
"Route",
"from",
"a",
"Oxygen",
"\\",
"Core",
"\\",
"Action",
"\\",
"Action"
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Routing/BlueprintRegistrar.php#L47-L55
|
234,238
|
txj123/zilf
|
src/Zilf/HttpFoundation/Request.php
|
Request.isMethodSafe
|
public function isMethodSafe(/* $andCacheable = true */)
{
if (!func_num_args() || func_get_arg(0)) {
// This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)
// then setting $andCacheable to false should be deprecated in 4.1
@trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);
return in_array($this->getMethod(), array('GET', 'HEAD'));
}
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
}
|
php
|
public function isMethodSafe(/* $andCacheable = true */)
{
if (!func_num_args() || func_get_arg(0)) {
// This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)
// then setting $andCacheable to false should be deprecated in 4.1
@trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);
return in_array($this->getMethod(), array('GET', 'HEAD'));
}
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
}
|
[
"public",
"function",
"isMethodSafe",
"(",
"/* $andCacheable = true */",
")",
"{",
"if",
"(",
"!",
"func_num_args",
"(",
")",
"||",
"func_get_arg",
"(",
"0",
")",
")",
"{",
"// This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)",
"// then setting $andCacheable to false should be deprecated in 4.1",
"@",
"trigger_error",
"(",
"'Checking only for cacheable HTTP methods with Symfony\\Component\\HttpFoundation\\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.'",
",",
"E_USER_DEPRECATED",
")",
";",
"return",
"in_array",
"(",
"$",
"this",
"->",
"getMethod",
"(",
")",
",",
"array",
"(",
"'GET'",
",",
"'HEAD'",
")",
")",
";",
"}",
"return",
"in_array",
"(",
"$",
"this",
"->",
"getMethod",
"(",
")",
",",
"array",
"(",
"'GET'",
",",
"'HEAD'",
",",
"'OPTIONS'",
",",
"'TRACE'",
")",
")",
";",
"}"
] |
Checks whether or not the method is safe.
@see https://tools.ietf.org/html/rfc7231#section-4.2.1
@param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default.
@return bool
|
[
"Checks",
"whether",
"or",
"not",
"the",
"method",
"is",
"safe",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Request.php#L1546-L1557
|
234,239
|
txj123/zilf
|
src/Zilf/Cache/MemcachedConnector.php
|
MemcachedConnector.validateConnection
|
protected function validateConnection($memcached)
{
$status = $memcached->getVersion();
if (! is_array($status)) {
throw new RuntimeException('No Memcached servers added.');
}
if (in_array('255.255.255', $status) && count(array_unique($status)) === 1) {
throw new RuntimeException('Could not establish Memcached connection.');
}
return $memcached;
}
|
php
|
protected function validateConnection($memcached)
{
$status = $memcached->getVersion();
if (! is_array($status)) {
throw new RuntimeException('No Memcached servers added.');
}
if (in_array('255.255.255', $status) && count(array_unique($status)) === 1) {
throw new RuntimeException('Could not establish Memcached connection.');
}
return $memcached;
}
|
[
"protected",
"function",
"validateConnection",
"(",
"$",
"memcached",
")",
"{",
"$",
"status",
"=",
"$",
"memcached",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"status",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No Memcached servers added.'",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"'255.255.255'",
",",
"$",
"status",
")",
"&&",
"count",
"(",
"array_unique",
"(",
"$",
"status",
")",
")",
"===",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Could not establish Memcached connection.'",
")",
";",
"}",
"return",
"$",
"memcached",
";",
"}"
] |
Validate the given Memcached connection.
@param \Memcached $memcached
@return \Memcached
|
[
"Validate",
"the",
"given",
"Memcached",
"connection",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/MemcachedConnector.php#L97-L110
|
234,240
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php
|
Zend_Validate_StringLength.setMin
|
public function setMin($min)
{
if (null !== $this->_max && $min > $this->_max) {
/**
* @see Zend_Validate_Exception
*/
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The minimum must be less than or equal to the maximum length, but $min >"
. " $this->_max"
);
}
$this->_min = max(0, (integer) $min);
return $this;
}
|
php
|
public function setMin($min)
{
if (null !== $this->_max && $min > $this->_max) {
/**
* @see Zend_Validate_Exception
*/
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The minimum must be less than or equal to the maximum length, but $min >"
. " $this->_max"
);
}
$this->_min = max(0, (integer) $min);
return $this;
}
|
[
"public",
"function",
"setMin",
"(",
"$",
"min",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"_max",
"&&",
"$",
"min",
">",
"$",
"this",
"->",
"_max",
")",
"{",
"/**\n * @see Zend_Validate_Exception\n */",
"include_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The minimum must be less than or equal to the maximum length, but $min >\"",
".",
"\" $this->_max\"",
")",
";",
"}",
"$",
"this",
"->",
"_min",
"=",
"max",
"(",
"0",
",",
"(",
"integer",
")",
"$",
"min",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the min option
@param integer $min
@throws Zend_Validate_Exception
@return Zend_Validate_StringLength Provides a fluent interface
|
[
"Sets",
"the",
"min",
"option"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php#L104-L118
|
234,241
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php
|
Zend_Validate_StringLength.setMax
|
public function setMax($max)
{
if (null === $max) {
$this->_max = null;
} else if ($max < $this->_min) {
/**
* @see Zend_Validate_Exception
*/
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum must be greater than or equal to the minimum length, but "
. "$max < $this->_min"
);
} else {
$this->_max = (integer) $max;
}
return $this;
}
|
php
|
public function setMax($max)
{
if (null === $max) {
$this->_max = null;
} else if ($max < $this->_min) {
/**
* @see Zend_Validate_Exception
*/
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception(
"The maximum must be greater than or equal to the minimum length, but "
. "$max < $this->_min"
);
} else {
$this->_max = (integer) $max;
}
return $this;
}
|
[
"public",
"function",
"setMax",
"(",
"$",
"max",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"max",
")",
"{",
"$",
"this",
"->",
"_max",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"$",
"max",
"<",
"$",
"this",
"->",
"_min",
")",
"{",
"/**\n * @see Zend_Validate_Exception\n */",
"include_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The maximum must be greater than or equal to the minimum length, but \"",
".",
"\"$max < $this->_min\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_max",
"=",
"(",
"integer",
")",
"$",
"max",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the max option
@param integer|null $max
@throws Zend_Validate_Exception
@return Zend_Validate_StringLength Provides a fluent interface
|
[
"Sets",
"the",
"max",
"option"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/StringLength.php#L137-L155
|
234,242
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Builder/FilterBuilder.php
|
FilterBuilder.build
|
public function build()
{
$filterMapper = $this->getMapper();
$input = Input::all();
$result = new FilterResult();
foreach ($filterMapper->getFields() as $field) {
$clone = clone $field;
$name = $clone->getName();
if (Input::has($name)) {
$clone->setValue($input[$name]);
}
$clone->setContext(BaseField::CONTEXT_FILTER);
$result->addField($name, $clone);
}
$this->setResult($result);
}
|
php
|
public function build()
{
$filterMapper = $this->getMapper();
$input = Input::all();
$result = new FilterResult();
foreach ($filterMapper->getFields() as $field) {
$clone = clone $field;
$name = $clone->getName();
if (Input::has($name)) {
$clone->setValue($input[$name]);
}
$clone->setContext(BaseField::CONTEXT_FILTER);
$result->addField($name, $clone);
}
$this->setResult($result);
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"filterMapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"result",
"=",
"new",
"FilterResult",
"(",
")",
";",
"foreach",
"(",
"$",
"filterMapper",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"field",
";",
"$",
"name",
"=",
"$",
"clone",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"Input",
"::",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"clone",
"->",
"setValue",
"(",
"$",
"input",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"clone",
"->",
"setContext",
"(",
"BaseField",
"::",
"CONTEXT_FILTER",
")",
";",
"$",
"result",
"->",
"addField",
"(",
"$",
"name",
",",
"$",
"clone",
")",
";",
"}",
"$",
"this",
"->",
"setResult",
"(",
"$",
"result",
")",
";",
"}"
] |
Build the filter data.
@return mixed|void
|
[
"Build",
"the",
"filter",
"data",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Builder/FilterBuilder.php#L35-L54
|
234,243
|
oxygen-cms/core
|
src/View/ViewServiceProvider.php
|
ViewServiceProvider.registerBladeStringEngine
|
public function registerBladeStringEngine($resolver) {
$app = $this->app;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Blade compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$app->singleton('blade.string.compiler', function ($app) {
$cache = $app['config']['view.compiled'];
return new BladeStringCompiler($app['files'], $app['blade.compiler'], $cache);
});
$resolver->register('blade.string', function () use ($app) {
return new CompilerEngine($app['blade.string.compiler'], $app['files']);
});
}
|
php
|
public function registerBladeStringEngine($resolver) {
$app = $this->app;
// The Compiler engine requires an instance of the CompilerInterface, which in
// this case will be the Blade compiler, so we'll first create the compiler
// instance to pass into the engine so it can compile the views properly.
$app->singleton('blade.string.compiler', function ($app) {
$cache = $app['config']['view.compiled'];
return new BladeStringCompiler($app['files'], $app['blade.compiler'], $cache);
});
$resolver->register('blade.string', function () use ($app) {
return new CompilerEngine($app['blade.string.compiler'], $app['files']);
});
}
|
[
"public",
"function",
"registerBladeStringEngine",
"(",
"$",
"resolver",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"// The Compiler engine requires an instance of the CompilerInterface, which in",
"// this case will be the Blade compiler, so we'll first create the compiler",
"// instance to pass into the engine so it can compile the views properly.",
"$",
"app",
"->",
"singleton",
"(",
"'blade.string.compiler'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"cache",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'view.compiled'",
"]",
";",
"return",
"new",
"BladeStringCompiler",
"(",
"$",
"app",
"[",
"'files'",
"]",
",",
"$",
"app",
"[",
"'blade.compiler'",
"]",
",",
"$",
"cache",
")",
";",
"}",
")",
";",
"$",
"resolver",
"->",
"register",
"(",
"'blade.string'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"CompilerEngine",
"(",
"$",
"app",
"[",
"'blade.string.compiler'",
"]",
",",
"$",
"app",
"[",
"'files'",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Register the StringBladeCompiler implementation.
@param \Illuminate\View\Engines\EngineResolver $resolver
@return void
|
[
"Register",
"the",
"StringBladeCompiler",
"implementation",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/ViewServiceProvider.php#L87-L103
|
234,244
|
superrbstudio/async
|
src/Superrb/Async/Handler.php
|
Handler.run
|
public function run(...$args): bool
{
$this->channel = new Channel($this->messageBuffer);
$this->pid = pcntl_fork();
// If $pid is set, we are in the parent process
if ($this->pid) {
// If we want the process to run asynchronously,
// we can just store the PID and abandon it
if ($this->async) {
// Store the communication channel for the process
$this->asyncChannels[$this->pid] = $this->channel;
return true;
}
// Wait for the child process to complete before continuing
return $this->wait();
}
// If $pid is not set, we are in the child process
if (!$this->pid) {
// Bind the channel as the $this argument within the handler
$handler = $this->handler;
$handler = $handler->bindTo($this->channel);
// Call the handler
$successful = $handler(...$args);
// Capture the return value from the function and use
// it to set the exit status for the process
$status = $successful ? 0 : 1;
// Exit the child process
exit($status);
}
// We shouldn't ever get this far, so if we do
// something went wrong
return false;
}
|
php
|
public function run(...$args): bool
{
$this->channel = new Channel($this->messageBuffer);
$this->pid = pcntl_fork();
// If $pid is set, we are in the parent process
if ($this->pid) {
// If we want the process to run asynchronously,
// we can just store the PID and abandon it
if ($this->async) {
// Store the communication channel for the process
$this->asyncChannels[$this->pid] = $this->channel;
return true;
}
// Wait for the child process to complete before continuing
return $this->wait();
}
// If $pid is not set, we are in the child process
if (!$this->pid) {
// Bind the channel as the $this argument within the handler
$handler = $this->handler;
$handler = $handler->bindTo($this->channel);
// Call the handler
$successful = $handler(...$args);
// Capture the return value from the function and use
// it to set the exit status for the process
$status = $successful ? 0 : 1;
// Exit the child process
exit($status);
}
// We shouldn't ever get this far, so if we do
// something went wrong
return false;
}
|
[
"public",
"function",
"run",
"(",
"...",
"$",
"args",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"channel",
"=",
"new",
"Channel",
"(",
"$",
"this",
"->",
"messageBuffer",
")",
";",
"$",
"this",
"->",
"pid",
"=",
"pcntl_fork",
"(",
")",
";",
"// If $pid is set, we are in the parent process",
"if",
"(",
"$",
"this",
"->",
"pid",
")",
"{",
"// If we want the process to run asynchronously,",
"// we can just store the PID and abandon it",
"if",
"(",
"$",
"this",
"->",
"async",
")",
"{",
"// Store the communication channel for the process",
"$",
"this",
"->",
"asyncChannels",
"[",
"$",
"this",
"->",
"pid",
"]",
"=",
"$",
"this",
"->",
"channel",
";",
"return",
"true",
";",
"}",
"// Wait for the child process to complete before continuing",
"return",
"$",
"this",
"->",
"wait",
"(",
")",
";",
"}",
"// If $pid is not set, we are in the child process",
"if",
"(",
"!",
"$",
"this",
"->",
"pid",
")",
"{",
"// Bind the channel as the $this argument within the handler",
"$",
"handler",
"=",
"$",
"this",
"->",
"handler",
";",
"$",
"handler",
"=",
"$",
"handler",
"->",
"bindTo",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"// Call the handler",
"$",
"successful",
"=",
"$",
"handler",
"(",
"...",
"$",
"args",
")",
";",
"// Capture the return value from the function and use",
"// it to set the exit status for the process",
"$",
"status",
"=",
"$",
"successful",
"?",
"0",
":",
"1",
";",
"// Exit the child process",
"exit",
"(",
"$",
"status",
")",
";",
"}",
"// We shouldn't ever get this far, so if we do",
"// something went wrong",
"return",
"false",
";",
"}"
] |
Run the forked process.
@param ... $args
@return bool
|
[
"Run",
"the",
"forked",
"process",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L117-L158
|
234,245
|
superrbstudio/async
|
src/Superrb/Async/Handler.php
|
Handler.wait
|
public function wait(): bool
{
if (!$this->pid) {
throw new BadMethodCallException('wait can only be called from the parent of a forked process');
}
// Cascade the call to waitAll for asynchronous processes
if ($this->async) {
return $this->waitAll();
}
// Wait for the process to complete
pcntl_waitpid($this->pid, $status);
// Capture any messages returned by the child process
if ($msg = $this->channel->receive()) {
$this->messages[] = $msg;
}
// If the process did not exit gracefully, mark it as failed
if (!pcntl_wifexited($status)) {
return false;
}
// If the process exited gracefully, check the exit code
return pcntl_wexitstatus($status) === 0;
}
|
php
|
public function wait(): bool
{
if (!$this->pid) {
throw new BadMethodCallException('wait can only be called from the parent of a forked process');
}
// Cascade the call to waitAll for asynchronous processes
if ($this->async) {
return $this->waitAll();
}
// Wait for the process to complete
pcntl_waitpid($this->pid, $status);
// Capture any messages returned by the child process
if ($msg = $this->channel->receive()) {
$this->messages[] = $msg;
}
// If the process did not exit gracefully, mark it as failed
if (!pcntl_wifexited($status)) {
return false;
}
// If the process exited gracefully, check the exit code
return pcntl_wexitstatus($status) === 0;
}
|
[
"public",
"function",
"wait",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pid",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'wait can only be called from the parent of a forked process'",
")",
";",
"}",
"// Cascade the call to waitAll for asynchronous processes",
"if",
"(",
"$",
"this",
"->",
"async",
")",
"{",
"return",
"$",
"this",
"->",
"waitAll",
"(",
")",
";",
"}",
"// Wait for the process to complete",
"pcntl_waitpid",
"(",
"$",
"this",
"->",
"pid",
",",
"$",
"status",
")",
";",
"// Capture any messages returned by the child process",
"if",
"(",
"$",
"msg",
"=",
"$",
"this",
"->",
"channel",
"->",
"receive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"$",
"msg",
";",
"}",
"// If the process did not exit gracefully, mark it as failed",
"if",
"(",
"!",
"pcntl_wifexited",
"(",
"$",
"status",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If the process exited gracefully, check the exit code",
"return",
"pcntl_wexitstatus",
"(",
"$",
"status",
")",
"===",
"0",
";",
"}"
] |
Wait for a child process to complete.
@throws BadMethodCallException
@return bool
|
[
"Wait",
"for",
"a",
"child",
"process",
"to",
"complete",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L167-L193
|
234,246
|
superrbstudio/async
|
src/Superrb/Async/Handler.php
|
Handler.waitAll
|
public function waitAll(): bool
{
if (!$this->pid) {
throw new BadMethodCallException('waitAll can only be called from the parent of a forked process');
}
if (!$this->async) {
throw new BadMethodCallException('waitAll can only be used with asynchronous forked processes');
}
$statuses = [];
$this->messages = [];
// We loop through each of the async channels in turn.
// Although this means the loop will check each process in
// the order it was launched, rather than in the order they
// complete, it allows us to keep track of the PIDs of each
// of the child processes and receive messages
foreach ($this->asyncChannels as $pid => $channel) {
// Wait for a process exit signal for the PID
pcntl_waitpid($pid, $status);
// Capture any messages returned by the child process
if ($msg = $channel->receive()) {
$this->messages[] = $msg;
}
// If the process exited gracefully, report success/failure
// base on the exit status
if (pcntl_wifexited($status)) {
$statuses[$pid] = (pcntl_wexitstatus($status) === 0);
continue;
}
// In all other cases, the process failed for another reason,
// so we mark it as failed
$statuses[$pid] = false;
}
// Filter the array of statuses, and check whether the count
// of failed processes is greater than zero
return count(array_filter($statuses, function (int $status) {
return $status !== 0;
})) === 0;
}
|
php
|
public function waitAll(): bool
{
if (!$this->pid) {
throw new BadMethodCallException('waitAll can only be called from the parent of a forked process');
}
if (!$this->async) {
throw new BadMethodCallException('waitAll can only be used with asynchronous forked processes');
}
$statuses = [];
$this->messages = [];
// We loop through each of the async channels in turn.
// Although this means the loop will check each process in
// the order it was launched, rather than in the order they
// complete, it allows us to keep track of the PIDs of each
// of the child processes and receive messages
foreach ($this->asyncChannels as $pid => $channel) {
// Wait for a process exit signal for the PID
pcntl_waitpid($pid, $status);
// Capture any messages returned by the child process
if ($msg = $channel->receive()) {
$this->messages[] = $msg;
}
// If the process exited gracefully, report success/failure
// base on the exit status
if (pcntl_wifexited($status)) {
$statuses[$pid] = (pcntl_wexitstatus($status) === 0);
continue;
}
// In all other cases, the process failed for another reason,
// so we mark it as failed
$statuses[$pid] = false;
}
// Filter the array of statuses, and check whether the count
// of failed processes is greater than zero
return count(array_filter($statuses, function (int $status) {
return $status !== 0;
})) === 0;
}
|
[
"public",
"function",
"waitAll",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pid",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'waitAll can only be called from the parent of a forked process'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"async",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'waitAll can only be used with asynchronous forked processes'",
")",
";",
"}",
"$",
"statuses",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"messages",
"=",
"[",
"]",
";",
"// We loop through each of the async channels in turn.",
"// Although this means the loop will check each process in",
"// the order it was launched, rather than in the order they",
"// complete, it allows us to keep track of the PIDs of each",
"// of the child processes and receive messages",
"foreach",
"(",
"$",
"this",
"->",
"asyncChannels",
"as",
"$",
"pid",
"=>",
"$",
"channel",
")",
"{",
"// Wait for a process exit signal for the PID",
"pcntl_waitpid",
"(",
"$",
"pid",
",",
"$",
"status",
")",
";",
"// Capture any messages returned by the child process",
"if",
"(",
"$",
"msg",
"=",
"$",
"channel",
"->",
"receive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"$",
"msg",
";",
"}",
"// If the process exited gracefully, report success/failure",
"// base on the exit status",
"if",
"(",
"pcntl_wifexited",
"(",
"$",
"status",
")",
")",
"{",
"$",
"statuses",
"[",
"$",
"pid",
"]",
"=",
"(",
"pcntl_wexitstatus",
"(",
"$",
"status",
")",
"===",
"0",
")",
";",
"continue",
";",
"}",
"// In all other cases, the process failed for another reason,",
"// so we mark it as failed",
"$",
"statuses",
"[",
"$",
"pid",
"]",
"=",
"false",
";",
"}",
"// Filter the array of statuses, and check whether the count",
"// of failed processes is greater than zero",
"return",
"count",
"(",
"array_filter",
"(",
"$",
"statuses",
",",
"function",
"(",
"int",
"$",
"status",
")",
"{",
"return",
"$",
"status",
"!==",
"0",
";",
"}",
")",
")",
"===",
"0",
";",
"}"
] |
Wait for all child processes to complete.
@throws BadMethodCallException
@return bool Whether ANY of the child processes failed
|
[
"Wait",
"for",
"all",
"child",
"processes",
"to",
"complete",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L202-L246
|
234,247
|
superrbstudio/async
|
src/Superrb/Async/Handler.php
|
Handler.getMessages
|
public function getMessages(): Generator
{
if (!$this->pid) {
throw new BadMethodCallException('getMessages can only be called from the parent of a forked process');
}
// Loop through the messages and yield each item in the collection
foreach ($this->messages as $message) {
yield $message;
}
}
|
php
|
public function getMessages(): Generator
{
if (!$this->pid) {
throw new BadMethodCallException('getMessages can only be called from the parent of a forked process');
}
// Loop through the messages and yield each item in the collection
foreach ($this->messages as $message) {
yield $message;
}
}
|
[
"public",
"function",
"getMessages",
"(",
")",
":",
"Generator",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pid",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'getMessages can only be called from the parent of a forked process'",
")",
";",
"}",
"// Loop through the messages and yield each item in the collection",
"foreach",
"(",
"$",
"this",
"->",
"messages",
"as",
"$",
"message",
")",
"{",
"yield",
"$",
"message",
";",
"}",
"}"
] |
Get any messages received from child processes.
@return Generator
|
[
"Get",
"any",
"messages",
"received",
"from",
"child",
"processes",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Handler.php#L263-L273
|
234,248
|
txj123/zilf
|
src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php
|
RecursiveDirectoryIterator.rewind
|
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
// @see https://bugs.php.net/68557
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
parent::next();
}
parent::rewind();
}
|
php
|
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
// @see https://bugs.php.net/68557
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
parent::next();
}
parent::rewind();
}
|
[
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isRewindable",
"(",
")",
")",
"{",
"return",
";",
"}",
"// @see https://bugs.php.net/68557",
"if",
"(",
"PHP_VERSION_ID",
"<",
"50523",
"||",
"PHP_VERSION_ID",
">=",
"50600",
"&&",
"PHP_VERSION_ID",
"<",
"50607",
")",
"{",
"parent",
"::",
"next",
"(",
")",
";",
"}",
"parent",
"::",
"rewind",
"(",
")",
";",
"}"
] |
Do nothing for non rewindable stream.
|
[
"Do",
"nothing",
"for",
"non",
"rewindable",
"stream",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php#L115-L127
|
234,249
|
txj123/zilf
|
src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php
|
RecursiveDirectoryIterator.isRewindable
|
public function isRewindable()
{
if (null !== $this->rewindable) {
return $this->rewindable;
}
// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed
if ('' === $this->getPath()) {
return $this->rewindable = false;
}
if (false !== $stream = @opendir($this->getPath())) {
$infos = stream_get_meta_data($stream);
closedir($stream);
if ($infos['seekable']) {
return $this->rewindable = true;
}
}
return $this->rewindable = false;
}
|
php
|
public function isRewindable()
{
if (null !== $this->rewindable) {
return $this->rewindable;
}
// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed
if ('' === $this->getPath()) {
return $this->rewindable = false;
}
if (false !== $stream = @opendir($this->getPath())) {
$infos = stream_get_meta_data($stream);
closedir($stream);
if ($infos['seekable']) {
return $this->rewindable = true;
}
}
return $this->rewindable = false;
}
|
[
"public",
"function",
"isRewindable",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"rewindable",
")",
"{",
"return",
"$",
"this",
"->",
"rewindable",
";",
"}",
"// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed",
"if",
"(",
"''",
"===",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"rewindable",
"=",
"false",
";",
"}",
"if",
"(",
"false",
"!==",
"$",
"stream",
"=",
"@",
"opendir",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
")",
"{",
"$",
"infos",
"=",
"stream_get_meta_data",
"(",
"$",
"stream",
")",
";",
"closedir",
"(",
"$",
"stream",
")",
";",
"if",
"(",
"$",
"infos",
"[",
"'seekable'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"rewindable",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"rewindable",
"=",
"false",
";",
"}"
] |
Checks if the stream is rewindable.
@return bool true when the stream is rewindable, false otherwise
|
[
"Checks",
"if",
"the",
"stream",
"is",
"rewindable",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/RecursiveDirectoryIterator.php#L134-L155
|
234,250
|
txj123/zilf
|
src/Zilf/HttpFoundation/File/UploadedFile.php
|
UploadedFile.guessClientExtension
|
public function guessClientExtension()
{
$type = $this->getClientMimeType();
$guesser = ExtensionGuesser::getInstance();
return $guesser->guess($type);
}
|
php
|
public function guessClientExtension()
{
$type = $this->getClientMimeType();
$guesser = ExtensionGuesser::getInstance();
return $guesser->guess($type);
}
|
[
"public",
"function",
"guessClientExtension",
"(",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getClientMimeType",
"(",
")",
";",
"$",
"guesser",
"=",
"ExtensionGuesser",
"::",
"getInstance",
"(",
")",
";",
"return",
"$",
"guesser",
"->",
"guess",
"(",
"$",
"type",
")",
";",
"}"
] |
Returns the extension based on the client mime type.
If the mime type is unknown, returns null.
This method uses the mime type as guessed by getClientMimeType()
to guess the file extension. As such, the extension returned
by this method cannot be trusted.
For a trusted extension, use guessExtension() instead (which guesses
the extension based on the guessed mime type for the file).
@return string|null The guessed extension or null if it cannot be guessed
@see guessExtension()
@see getClientMimeType()
|
[
"Returns",
"the",
"extension",
"based",
"on",
"the",
"client",
"mime",
"type",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/UploadedFile.php#L160-L166
|
234,251
|
txj123/zilf
|
src/Zilf/HttpFoundation/File/UploadedFile.php
|
UploadedFile.isValid
|
public function isValid()
{
$isOk = $this->error === UPLOAD_ERR_OK;
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
}
|
php
|
public function isValid()
{
$isOk = $this->error === UPLOAD_ERR_OK;
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
}
|
[
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"isOk",
"=",
"$",
"this",
"->",
"error",
"===",
"UPLOAD_ERR_OK",
";",
"return",
"$",
"this",
"->",
"test",
"?",
"$",
"isOk",
":",
"$",
"isOk",
"&&",
"is_uploaded_file",
"(",
"$",
"this",
"->",
"getPathname",
"(",
")",
")",
";",
"}"
] |
Returns whether the file was uploaded successfully.
@return bool True if the file has been uploaded with HTTP and no error occurred
|
[
"Returns",
"whether",
"the",
"file",
"was",
"uploaded",
"successfully",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/File/UploadedFile.php#L199-L204
|
234,252
|
txj123/zilf
|
src/Zilf/Db/mssql/QueryBuilder.php
|
QueryBuilder.getAllColumnNames
|
protected function getAllColumnNames($modelClass = null)
{
if (!$modelClass) {
return null;
}
/* @var $modelClass \Zilf\Db\ActiveRecord */
$schema = $modelClass::getTableSchema();
return array_keys($schema->columns);
}
|
php
|
protected function getAllColumnNames($modelClass = null)
{
if (!$modelClass) {
return null;
}
/* @var $modelClass \Zilf\Db\ActiveRecord */
$schema = $modelClass::getTableSchema();
return array_keys($schema->columns);
}
|
[
"protected",
"function",
"getAllColumnNames",
"(",
"$",
"modelClass",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"modelClass",
")",
"{",
"return",
"null",
";",
"}",
"/* @var $modelClass \\Zilf\\Db\\ActiveRecord */",
"$",
"schema",
"=",
"$",
"modelClass",
"::",
"getTableSchema",
"(",
")",
";",
"return",
"array_keys",
"(",
"$",
"schema",
"->",
"columns",
")",
";",
"}"
] |
Returns an array of column names given model name.
@param string $modelClass name of the model class
@return array|null array of column names
|
[
"Returns",
"an",
"array",
"of",
"column",
"names",
"given",
"model",
"name",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/mssql/QueryBuilder.php#L309-L317
|
234,253
|
txj123/zilf
|
src/Zilf/Db/mssql/QueryBuilder.php
|
QueryBuilder.normalizeTableRowData
|
private function normalizeTableRowData($table, $columns, &$params)
{
if (($tableSchema = $this->db->getSchema()->getTableSchema($table)) !== null) {
$columnSchemas = $tableSchema->columns;
foreach ($columns as $name => $value) {
// @see https://github.com/Zilfsoft/Zilf2/issues/12599
if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && (is_string($value) || $value === null)) {
$exParams = [];
$phName = $this->bindParam($value, $exParams);
$columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams);
}
}
}
return $columns;
}
|
php
|
private function normalizeTableRowData($table, $columns, &$params)
{
if (($tableSchema = $this->db->getSchema()->getTableSchema($table)) !== null) {
$columnSchemas = $tableSchema->columns;
foreach ($columns as $name => $value) {
// @see https://github.com/Zilfsoft/Zilf2/issues/12599
if (isset($columnSchemas[$name]) && $columnSchemas[$name]->type === Schema::TYPE_BINARY && $columnSchemas[$name]->dbType === 'varbinary' && (is_string($value) || $value === null)) {
$exParams = [];
$phName = $this->bindParam($value, $exParams);
$columns[$name] = new Expression("CONVERT(VARBINARY, $phName)", $exParams);
}
}
}
return $columns;
}
|
[
"private",
"function",
"normalizeTableRowData",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"&",
"$",
"params",
")",
"{",
"if",
"(",
"(",
"$",
"tableSchema",
"=",
"$",
"this",
"->",
"db",
"->",
"getSchema",
"(",
")",
"->",
"getTableSchema",
"(",
"$",
"table",
")",
")",
"!==",
"null",
")",
"{",
"$",
"columnSchemas",
"=",
"$",
"tableSchema",
"->",
"columns",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"// @see https://github.com/Zilfsoft/Zilf2/issues/12599",
"if",
"(",
"isset",
"(",
"$",
"columnSchemas",
"[",
"$",
"name",
"]",
")",
"&&",
"$",
"columnSchemas",
"[",
"$",
"name",
"]",
"->",
"type",
"===",
"Schema",
"::",
"TYPE_BINARY",
"&&",
"$",
"columnSchemas",
"[",
"$",
"name",
"]",
"->",
"dbType",
"===",
"'varbinary'",
"&&",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"===",
"null",
")",
")",
"{",
"$",
"exParams",
"=",
"[",
"]",
";",
"$",
"phName",
"=",
"$",
"this",
"->",
"bindParam",
"(",
"$",
"value",
",",
"$",
"exParams",
")",
";",
"$",
"columns",
"[",
"$",
"name",
"]",
"=",
"new",
"Expression",
"(",
"\"CONVERT(VARBINARY, $phName)\"",
",",
"$",
"exParams",
")",
";",
"}",
"}",
"}",
"return",
"$",
"columns",
";",
"}"
] |
Normalizes data to be saved into the table, performing extra preparations and type converting, if necessary.
@param string $table the table that data will be saved into.
@param array $columns the column data (name => value) to be saved into the table.
@return array normalized columns
|
[
"Normalizes",
"data",
"to",
"be",
"saved",
"into",
"the",
"table",
"performing",
"extra",
"preparations",
"and",
"type",
"converting",
"if",
"necessary",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/mssql/QueryBuilder.php#L347-L362
|
234,254
|
crysalead/sql-dialect
|
src/Statement/Insert.php
|
Insert._buildValues
|
protected function _buildValues()
{
$states = $this->_schema ? ['schema' => $this->_schema] : [];
$parts = [];
foreach ($this->_parts['values'] as $values) {
$data = [];
foreach ($values as $key => $value) {
$states['name'] = $key;
$data[] = $this->dialect()->value($value, $states);
}
$parts[] = '(' . join(', ', $data) . ')';
}
return ' VALUES ' . join(', ',$parts);
}
|
php
|
protected function _buildValues()
{
$states = $this->_schema ? ['schema' => $this->_schema] : [];
$parts = [];
foreach ($this->_parts['values'] as $values) {
$data = [];
foreach ($values as $key => $value) {
$states['name'] = $key;
$data[] = $this->dialect()->value($value, $states);
}
$parts[] = '(' . join(', ', $data) . ')';
}
return ' VALUES ' . join(', ',$parts);
}
|
[
"protected",
"function",
"_buildValues",
"(",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"_schema",
"?",
"[",
"'schema'",
"=>",
"$",
"this",
"->",
"_schema",
"]",
":",
"[",
"]",
";",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'values'",
"]",
"as",
"$",
"values",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"states",
"[",
"'name'",
"]",
"=",
"$",
"key",
";",
"$",
"data",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"value",
"(",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"$",
"parts",
"[",
"]",
"=",
"'('",
".",
"join",
"(",
"', '",
",",
"$",
"data",
")",
".",
"')'",
";",
"}",
"return",
"' VALUES '",
".",
"join",
"(",
"', '",
",",
"$",
"parts",
")",
";",
"}"
] |
Build `VALUES` clause.
@return string Returns the `VALUES` clause.
|
[
"Build",
"VALUES",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Insert.php#L99-L112
|
234,255
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifier.php
|
CommentNotifier.onAfterPostComment
|
public function onAfterPostComment(Comment $comment)
{
$parent = $comment->Parent();
if (!$parent || !$parent->hasMethod('notificationRecipients')) {
return;
}
// Ask parent to submit all recipients
$recipients = $parent->notificationRecipients($comment);
foreach ($recipients as $recipient) {
$this->notifyCommentRecipient($comment, $parent, $recipient);
}
}
|
php
|
public function onAfterPostComment(Comment $comment)
{
$parent = $comment->Parent();
if (!$parent || !$parent->hasMethod('notificationRecipients')) {
return;
}
// Ask parent to submit all recipients
$recipients = $parent->notificationRecipients($comment);
foreach ($recipients as $recipient) {
$this->notifyCommentRecipient($comment, $parent, $recipient);
}
}
|
[
"public",
"function",
"onAfterPostComment",
"(",
"Comment",
"$",
"comment",
")",
"{",
"$",
"parent",
"=",
"$",
"comment",
"->",
"Parent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"parent",
"||",
"!",
"$",
"parent",
"->",
"hasMethod",
"(",
"'notificationRecipients'",
")",
")",
"{",
"return",
";",
"}",
"// Ask parent to submit all recipients",
"$",
"recipients",
"=",
"$",
"parent",
"->",
"notificationRecipients",
"(",
"$",
"comment",
")",
";",
"foreach",
"(",
"$",
"recipients",
"as",
"$",
"recipient",
")",
"{",
"$",
"this",
"->",
"notifyCommentRecipient",
"(",
"$",
"comment",
",",
"$",
"parent",
",",
"$",
"recipient",
")",
";",
"}",
"}"
] |
Notify Members of the post there is a new comment.
@param Comment $comment
|
[
"Notify",
"Members",
"of",
"the",
"post",
"there",
"is",
"a",
"new",
"comment",
"."
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifier.php#L23-L37
|
234,256
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifier.php
|
CommentNotifier.notifyCommentRecipient
|
public function notifyCommentRecipient($comment, $parent, $recipient)
{
$subject = $parent->notificationSubject($comment, $recipient);
$sender = $parent->notificationSender($comment, $recipient);
$template = $parent->notificationTemplate($comment, $recipient);
// Validate email
// Important in case of the owner being a default-admin or a username with no contact email
$to = ($recipient instanceof Member) ? $recipient->Email : $recipient;
if (!Email::is_valid_address($to)) {
return;
}
// Prepare the email
$email = Email::create();
$email->setSubject($subject);
$email->setFrom($sender);
$email->setTo($to);
$email->setHTMLTemplate($template);
if ($recipient instanceof Member) {
$email->setData([
'Parent' => $parent,
'Comment' => $comment,
'Recipient' => $recipient,
'ApproveLink' => $comment->ApproveLink($recipient),
'HamLink' => $comment->HamLink($recipient),
'SpamLink' => $comment->SpamLink($recipient),
'DeleteLink' => $comment->DeleteLink($recipient),
]);
} else {
$email->setData([
'Parent' => $parent,
'Comment' => $comment,
'ApproveLink' => false,
'SpamLink' => false,
'DeleteLink' => false,
'HamLink' => false,
'Recipient' => $recipient
]);
}
$this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient);
return $email->send();
}
|
php
|
public function notifyCommentRecipient($comment, $parent, $recipient)
{
$subject = $parent->notificationSubject($comment, $recipient);
$sender = $parent->notificationSender($comment, $recipient);
$template = $parent->notificationTemplate($comment, $recipient);
// Validate email
// Important in case of the owner being a default-admin or a username with no contact email
$to = ($recipient instanceof Member) ? $recipient->Email : $recipient;
if (!Email::is_valid_address($to)) {
return;
}
// Prepare the email
$email = Email::create();
$email->setSubject($subject);
$email->setFrom($sender);
$email->setTo($to);
$email->setHTMLTemplate($template);
if ($recipient instanceof Member) {
$email->setData([
'Parent' => $parent,
'Comment' => $comment,
'Recipient' => $recipient,
'ApproveLink' => $comment->ApproveLink($recipient),
'HamLink' => $comment->HamLink($recipient),
'SpamLink' => $comment->SpamLink($recipient),
'DeleteLink' => $comment->DeleteLink($recipient),
]);
} else {
$email->setData([
'Parent' => $parent,
'Comment' => $comment,
'ApproveLink' => false,
'SpamLink' => false,
'DeleteLink' => false,
'HamLink' => false,
'Recipient' => $recipient
]);
}
$this->owner->invokeWithExtensions('updateCommentNotification', $email, $comment, $recipient);
return $email->send();
}
|
[
"public",
"function",
"notifyCommentRecipient",
"(",
"$",
"comment",
",",
"$",
"parent",
",",
"$",
"recipient",
")",
"{",
"$",
"subject",
"=",
"$",
"parent",
"->",
"notificationSubject",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"$",
"sender",
"=",
"$",
"parent",
"->",
"notificationSender",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"$",
"template",
"=",
"$",
"parent",
"->",
"notificationTemplate",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"// Validate email",
"// Important in case of the owner being a default-admin or a username with no contact email",
"$",
"to",
"=",
"(",
"$",
"recipient",
"instanceof",
"Member",
")",
"?",
"$",
"recipient",
"->",
"Email",
":",
"$",
"recipient",
";",
"if",
"(",
"!",
"Email",
"::",
"is_valid_address",
"(",
"$",
"to",
")",
")",
"{",
"return",
";",
"}",
"// Prepare the email",
"$",
"email",
"=",
"Email",
"::",
"create",
"(",
")",
";",
"$",
"email",
"->",
"setSubject",
"(",
"$",
"subject",
")",
";",
"$",
"email",
"->",
"setFrom",
"(",
"$",
"sender",
")",
";",
"$",
"email",
"->",
"setTo",
"(",
"$",
"to",
")",
";",
"$",
"email",
"->",
"setHTMLTemplate",
"(",
"$",
"template",
")",
";",
"if",
"(",
"$",
"recipient",
"instanceof",
"Member",
")",
"{",
"$",
"email",
"->",
"setData",
"(",
"[",
"'Parent'",
"=>",
"$",
"parent",
",",
"'Comment'",
"=>",
"$",
"comment",
",",
"'Recipient'",
"=>",
"$",
"recipient",
",",
"'ApproveLink'",
"=>",
"$",
"comment",
"->",
"ApproveLink",
"(",
"$",
"recipient",
")",
",",
"'HamLink'",
"=>",
"$",
"comment",
"->",
"HamLink",
"(",
"$",
"recipient",
")",
",",
"'SpamLink'",
"=>",
"$",
"comment",
"->",
"SpamLink",
"(",
"$",
"recipient",
")",
",",
"'DeleteLink'",
"=>",
"$",
"comment",
"->",
"DeleteLink",
"(",
"$",
"recipient",
")",
",",
"]",
")",
";",
"}",
"else",
"{",
"$",
"email",
"->",
"setData",
"(",
"[",
"'Parent'",
"=>",
"$",
"parent",
",",
"'Comment'",
"=>",
"$",
"comment",
",",
"'ApproveLink'",
"=>",
"false",
",",
"'SpamLink'",
"=>",
"false",
",",
"'DeleteLink'",
"=>",
"false",
",",
"'HamLink'",
"=>",
"false",
",",
"'Recipient'",
"=>",
"$",
"recipient",
"]",
")",
";",
"}",
"$",
"this",
"->",
"owner",
"->",
"invokeWithExtensions",
"(",
"'updateCommentNotification'",
",",
"$",
"email",
",",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"return",
"$",
"email",
"->",
"send",
"(",
")",
";",
"}"
] |
Send comment notification to a given recipient
@param Comment $comment
@param DataObject $parent Object with the {@see CommentNotifiable} extension applied
@param Member|string $recipient Either a member object or an email address to which notifications should be sent
|
[
"Send",
"comment",
"notification",
"to",
"a",
"given",
"recipient"
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifier.php#L46-L92
|
234,257
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
|
Zend_Uri_Http.fromString
|
public static function fromString($uri)
{
if (is_string($uri) === false) {
throw new InvalidArgumentException('$uri is not a string');
}
$uri = explode(':', $uri, 2);
$scheme = strtolower($uri[0]);
$schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
if (in_array($scheme, array('http', 'https')) === false) {
throw new Zend_Uri_Exception("Invalid scheme: '$scheme'");
}
$schemeHandler = new Zend_Uri_Http($scheme, $schemeSpecific);
return $schemeHandler;
}
|
php
|
public static function fromString($uri)
{
if (is_string($uri) === false) {
throw new InvalidArgumentException('$uri is not a string');
}
$uri = explode(':', $uri, 2);
$scheme = strtolower($uri[0]);
$schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
if (in_array($scheme, array('http', 'https')) === false) {
throw new Zend_Uri_Exception("Invalid scheme: '$scheme'");
}
$schemeHandler = new Zend_Uri_Http($scheme, $schemeSpecific);
return $schemeHandler;
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"uri",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'$uri is not a string'",
")",
";",
"}",
"$",
"uri",
"=",
"explode",
"(",
"':'",
",",
"$",
"uri",
",",
"2",
")",
";",
"$",
"scheme",
"=",
"strtolower",
"(",
"$",
"uri",
"[",
"0",
"]",
")",
";",
"$",
"schemeSpecific",
"=",
"isset",
"(",
"$",
"uri",
"[",
"1",
"]",
")",
"===",
"true",
"?",
"$",
"uri",
"[",
"1",
"]",
":",
"''",
";",
"if",
"(",
"in_array",
"(",
"$",
"scheme",
",",
"array",
"(",
"'http'",
",",
"'https'",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"\"Invalid scheme: '$scheme'\"",
")",
";",
"}",
"$",
"schemeHandler",
"=",
"new",
"Zend_Uri_Http",
"(",
"$",
"scheme",
",",
"$",
"schemeSpecific",
")",
";",
"return",
"$",
"schemeHandler",
";",
"}"
] |
Creates a Zend_Uri_Http from the given string
@param string $uri String to create URI from, must start with
'http://' or 'https://'
@throws InvalidArgumentException When the given $uri is not a string or
does not start with http:// or https://
@throws Zend_Uri_Exception When the given $uri is invalid
@return Zend_Uri_Http
|
[
"Creates",
"a",
"Zend_Uri_Http",
"from",
"the",
"given",
"string"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L150-L166
|
234,258
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
|
Zend_Uri_Http.validatePassword
|
public function validatePassword($password = null)
{
if ($password === null) {
$password = $this->_password;
}
// If the password is empty, then it is considered valid
if (strlen($password) === 0) {
return true;
}
// If the password is nonempty, but there is no username, then it is considered invalid
if (strlen($password) > 0 and strlen($this->_username) === 0) {
return false;
}
// Check the password against the allowed values
$status = @preg_match(
'/^(' . $this->_regex['alphanum'] . '|' . $this->_regex['mark'] . '|'
. $this->_regex['escaped'] . '|[;:&=+$,])+$/', $password
);
if ($status === false) {
include_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: password validation failed.');
}
return $status == 1;
}
|
php
|
public function validatePassword($password = null)
{
if ($password === null) {
$password = $this->_password;
}
// If the password is empty, then it is considered valid
if (strlen($password) === 0) {
return true;
}
// If the password is nonempty, but there is no username, then it is considered invalid
if (strlen($password) > 0 and strlen($this->_username) === 0) {
return false;
}
// Check the password against the allowed values
$status = @preg_match(
'/^(' . $this->_regex['alphanum'] . '|' . $this->_regex['mark'] . '|'
. $this->_regex['escaped'] . '|[;:&=+$,])+$/', $password
);
if ($status === false) {
include_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: password validation failed.');
}
return $status == 1;
}
|
[
"public",
"function",
"validatePassword",
"(",
"$",
"password",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"password",
"===",
"null",
")",
"{",
"$",
"password",
"=",
"$",
"this",
"->",
"_password",
";",
"}",
"// If the password is empty, then it is considered valid",
"if",
"(",
"strlen",
"(",
"$",
"password",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"// If the password is nonempty, but there is no username, then it is considered invalid",
"if",
"(",
"strlen",
"(",
"$",
"password",
")",
">",
"0",
"and",
"strlen",
"(",
"$",
"this",
"->",
"_username",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// Check the password against the allowed values",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"'/^('",
".",
"$",
"this",
"->",
"_regex",
"[",
"'alphanum'",
"]",
".",
"'|'",
".",
"$",
"this",
"->",
"_regex",
"[",
"'mark'",
"]",
".",
"'|'",
".",
"$",
"this",
"->",
"_regex",
"[",
"'escaped'",
"]",
".",
"'|[;:&=+$,])+$/'",
",",
"$",
"password",
")",
";",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"include_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'Internal error: password validation failed.'",
")",
";",
"}",
"return",
"$",
"status",
"==",
"1",
";",
"}"
] |
Returns true if and only if the password passes validation. If no password is passed,
then the password contained in the instance variable is used.
@param string $password The HTTP password
@throws Zend_Uri_Exception When password validation fails
@return boolean
@link http://www.faqs.org/rfcs/rfc2396.html
|
[
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"password",
"passes",
"validation",
".",
"If",
"no",
"password",
"is",
"passed",
"then",
"the",
"password",
"contained",
"in",
"the",
"instance",
"variable",
"is",
"used",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L348-L375
|
234,259
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
|
Zend_Uri_Http.validateHost
|
public function validateHost($host = null)
{
if ($host === null) {
$host = $this->_host;
}
// If the host is empty, then it is considered invalid
if (strlen($host) === 0) {
return false;
}
// Check the host against the allowed values; delegated to Zend_Filter.
$validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
return $validate->isValid($host);
}
|
php
|
public function validateHost($host = null)
{
if ($host === null) {
$host = $this->_host;
}
// If the host is empty, then it is considered invalid
if (strlen($host) === 0) {
return false;
}
// Check the host against the allowed values; delegated to Zend_Filter.
$validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
return $validate->isValid($host);
}
|
[
"public",
"function",
"validateHost",
"(",
"$",
"host",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"host",
"===",
"null",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"_host",
";",
"}",
"// If the host is empty, then it is considered invalid",
"if",
"(",
"strlen",
"(",
"$",
"host",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// Check the host against the allowed values; delegated to Zend_Filter.",
"$",
"validate",
"=",
"new",
"Zend_Validate_Hostname",
"(",
"Zend_Validate_Hostname",
"::",
"ALLOW_ALL",
")",
";",
"return",
"$",
"validate",
"->",
"isValid",
"(",
"$",
"host",
")",
";",
"}"
] |
Returns true if and only if the host string passes validation. If no host is passed,
then the host contained in the instance variable is used.
@param string $host The HTTP host
@return boolean
@uses Zend_Filter
|
[
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"host",
"string",
"passes",
"validation",
".",
"If",
"no",
"host",
"is",
"passed",
"then",
"the",
"host",
"contained",
"in",
"the",
"instance",
"variable",
"is",
"used",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L415-L430
|
234,260
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
|
Zend_Uri_Http.validatePort
|
public function validatePort($port = null)
{
if ($port === null) {
$port = $this->_port;
}
// If the port is empty, then it is considered valid
if (strlen($port) === 0) {
return true;
}
// Check the port against the allowed values
return ctype_digit((string) $port) and 1 <= $port and $port <= 65535;
}
|
php
|
public function validatePort($port = null)
{
if ($port === null) {
$port = $this->_port;
}
// If the port is empty, then it is considered valid
if (strlen($port) === 0) {
return true;
}
// Check the port against the allowed values
return ctype_digit((string) $port) and 1 <= $port and $port <= 65535;
}
|
[
"public",
"function",
"validatePort",
"(",
"$",
"port",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"port",
"===",
"null",
")",
"{",
"$",
"port",
"=",
"$",
"this",
"->",
"_port",
";",
"}",
"// If the port is empty, then it is considered valid",
"if",
"(",
"strlen",
"(",
"$",
"port",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"// Check the port against the allowed values",
"return",
"ctype_digit",
"(",
"(",
"string",
")",
"$",
"port",
")",
"and",
"1",
"<=",
"$",
"port",
"and",
"$",
"port",
"<=",
"65535",
";",
"}"
] |
Returns true if and only if the TCP port string passes validation. If no port is passed,
then the port contained in the instance variable is used.
@param string $port The HTTP port
@return boolean
|
[
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"TCP",
"port",
"string",
"passes",
"validation",
".",
"If",
"no",
"port",
"is",
"passed",
"then",
"the",
"port",
"contained",
"in",
"the",
"instance",
"variable",
"is",
"used",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L469-L482
|
234,261
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php
|
Zend_Uri_Http.validateFragment
|
public function validateFragment($fragment = null)
{
if ($fragment === null) {
$fragment = $this->_fragment;
}
// If fragment is empty, it is considered to be valid
if (strlen($fragment) === 0) {
return true;
}
// Determine whether the fragment is well-formed
$pattern = '/^' . $this->_regex['uric'] . '*$/';
$status = @preg_match($pattern, $fragment);
if ($status === false) {
include_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: fragment validation failed');
}
return (boolean) $status;
}
|
php
|
public function validateFragment($fragment = null)
{
if ($fragment === null) {
$fragment = $this->_fragment;
}
// If fragment is empty, it is considered to be valid
if (strlen($fragment) === 0) {
return true;
}
// Determine whether the fragment is well-formed
$pattern = '/^' . $this->_regex['uric'] . '*$/';
$status = @preg_match($pattern, $fragment);
if ($status === false) {
include_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: fragment validation failed');
}
return (boolean) $status;
}
|
[
"public",
"function",
"validateFragment",
"(",
"$",
"fragment",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fragment",
"===",
"null",
")",
"{",
"$",
"fragment",
"=",
"$",
"this",
"->",
"_fragment",
";",
"}",
"// If fragment is empty, it is considered to be valid",
"if",
"(",
"strlen",
"(",
"$",
"fragment",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"// Determine whether the fragment is well-formed",
"$",
"pattern",
"=",
"'/^'",
".",
"$",
"this",
"->",
"_regex",
"[",
"'uric'",
"]",
".",
"'*$/'",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"fragment",
")",
";",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"include_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'Internal error: fragment validation failed'",
")",
";",
"}",
"return",
"(",
"boolean",
")",
"$",
"status",
";",
"}"
] |
Returns true if and only if the fragment passes validation. If no fragment is passed,
then the fragment contained in the instance variable is used.
@param string $fragment Fragment of an URI
@throws Zend_Uri_Exception When fragment validation fails
@return boolean
@link http://www.faqs.org/rfcs/rfc2396.html
|
[
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"fragment",
"passes",
"validation",
".",
"If",
"no",
"fragment",
"is",
"passed",
"then",
"the",
"fragment",
"contained",
"in",
"the",
"instance",
"variable",
"is",
"used",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri/Http.php#L665-L685
|
234,262
|
txj123/zilf
|
src/Zilf/Security/Hashids/Hashids.php
|
Hashids.encodeHex
|
public function encodeHex($str)
{
if (!ctype_xdigit((string)$str)) {
return '';
}
$numbers = trim(chunk_split($str, 12, ' '));
$numbers = explode(' ', $numbers);
foreach ($numbers as $i => $number) {
$numbers[$i] = hexdec('1' . $number);
}
return call_user_func_array([$this, 'encode'], $numbers);
}
|
php
|
public function encodeHex($str)
{
if (!ctype_xdigit((string)$str)) {
return '';
}
$numbers = trim(chunk_split($str, 12, ' '));
$numbers = explode(' ', $numbers);
foreach ($numbers as $i => $number) {
$numbers[$i] = hexdec('1' . $number);
}
return call_user_func_array([$this, 'encode'], $numbers);
}
|
[
"public",
"function",
"encodeHex",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"ctype_xdigit",
"(",
"(",
"string",
")",
"$",
"str",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"numbers",
"=",
"trim",
"(",
"chunk_split",
"(",
"$",
"str",
",",
"12",
",",
"' '",
")",
")",
";",
"$",
"numbers",
"=",
"explode",
"(",
"' '",
",",
"$",
"numbers",
")",
";",
"foreach",
"(",
"$",
"numbers",
"as",
"$",
"i",
"=>",
"$",
"number",
")",
"{",
"$",
"numbers",
"[",
"$",
"i",
"]",
"=",
"hexdec",
"(",
"'1'",
".",
"$",
"number",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'encode'",
"]",
",",
"$",
"numbers",
")",
";",
"}"
] |
Encode hexadecimal values and generate a hash string.
@param string $str
@return string
|
[
"Encode",
"hexadecimal",
"values",
"and",
"generate",
"a",
"hash",
"string",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Hashids.php#L261-L275
|
234,263
|
jlcd/api-cielo30
|
src/Cielo.php
|
Cielo.cancelPayment
|
public function cancelPayment(CieloPayment $cieloPayment)
{
try {
$sale = (new CieloEcommerce($this->merchant, $this->environment))->cancelSale($cieloPayment->getId(), $cieloPayment->getValue());
$paymentData = $sale->jsonSerialize();
$paymentStatus = $sale->getStatus();
$paymentMessage = $sale->getReturnMessage();
} catch (CieloRequestException $e) {
$error = $e->getCieloError();
throw new ResourceErrorException($error->getMessage(), $error->getCode());
}
return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData);
}
|
php
|
public function cancelPayment(CieloPayment $cieloPayment)
{
try {
$sale = (new CieloEcommerce($this->merchant, $this->environment))->cancelSale($cieloPayment->getId(), $cieloPayment->getValue());
$paymentData = $sale->jsonSerialize();
$paymentStatus = $sale->getStatus();
$paymentMessage = $sale->getReturnMessage();
} catch (CieloRequestException $e) {
$error = $e->getCieloError();
throw new ResourceErrorException($error->getMessage(), $error->getCode());
}
return new ResourceResponse($paymentStatus, $paymentMessage, $paymentData);
}
|
[
"public",
"function",
"cancelPayment",
"(",
"CieloPayment",
"$",
"cieloPayment",
")",
"{",
"try",
"{",
"$",
"sale",
"=",
"(",
"new",
"CieloEcommerce",
"(",
"$",
"this",
"->",
"merchant",
",",
"$",
"this",
"->",
"environment",
")",
")",
"->",
"cancelSale",
"(",
"$",
"cieloPayment",
"->",
"getId",
"(",
")",
",",
"$",
"cieloPayment",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"paymentData",
"=",
"$",
"sale",
"->",
"jsonSerialize",
"(",
")",
";",
"$",
"paymentStatus",
"=",
"$",
"sale",
"->",
"getStatus",
"(",
")",
";",
"$",
"paymentMessage",
"=",
"$",
"sale",
"->",
"getReturnMessage",
"(",
")",
";",
"}",
"catch",
"(",
"CieloRequestException",
"$",
"e",
")",
"{",
"$",
"error",
"=",
"$",
"e",
"->",
"getCieloError",
"(",
")",
";",
"throw",
"new",
"ResourceErrorException",
"(",
"$",
"error",
"->",
"getMessage",
"(",
")",
",",
"$",
"error",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"return",
"new",
"ResourceResponse",
"(",
"$",
"paymentStatus",
",",
"$",
"paymentMessage",
",",
"$",
"paymentData",
")",
";",
"}"
] |
Executes a payment refund request on Cielo
@param CieloPayment $cieloPayment
@throws ResourceErrorException
@return ResourceResponse
|
[
"Executes",
"a",
"payment",
"refund",
"request",
"on",
"Cielo"
] |
a8f24e8878a7bd2990565fe889d89116c2aecfa7
|
https://github.com/jlcd/api-cielo30/blob/a8f24e8878a7bd2990565fe889d89116c2aecfa7/src/Cielo.php#L89-L103
|
234,264
|
dave-redfern/laravel-doctrine-tenancy
|
src/TenancyServiceProvider.php
|
TenancyServiceProvider.registerTenantAwareViewFinder
|
protected function registerTenantAwareViewFinder(Repository $config)
{
$this->app->bind('view.finder', function ($app) use ($config) {
$paths = $config['view.paths'];
return new FileViewFinder($app['files'], $paths);
});
}
|
php
|
protected function registerTenantAwareViewFinder(Repository $config)
{
$this->app->bind('view.finder', function ($app) use ($config) {
$paths = $config['view.paths'];
return new FileViewFinder($app['files'], $paths);
});
}
|
[
"protected",
"function",
"registerTenantAwareViewFinder",
"(",
"Repository",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'view.finder'",
",",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"config",
")",
"{",
"$",
"paths",
"=",
"$",
"config",
"[",
"'view.paths'",
"]",
";",
"return",
"new",
"FileViewFinder",
"(",
"$",
"app",
"[",
"'files'",
"]",
",",
"$",
"paths",
")",
";",
"}",
")",
";",
"}"
] |
Re-register the view finder with one that allows manipulating the paths array
@param Repository $config
@return void
|
[
"Re",
"-",
"register",
"the",
"view",
"finder",
"with",
"one",
"that",
"allows",
"manipulating",
"the",
"paths",
"array"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L167-L174
|
234,265
|
dave-redfern/laravel-doctrine-tenancy
|
src/TenancyServiceProvider.php
|
TenancyServiceProvider.registerMultiAccountTenancy
|
protected function registerMultiAccountTenancy(Repository $config)
{
if (!$config->get('tenancy.multi_account.enabled', false)) {
return;
}
$this->registerMultiAccountParticipantRepository($config);
$this->registerTenantParticipantMappings($config->get('tenancy.multi_account.participant.mappings'));
}
|
php
|
protected function registerMultiAccountTenancy(Repository $config)
{
if (!$config->get('tenancy.multi_account.enabled', false)) {
return;
}
$this->registerMultiAccountParticipantRepository($config);
$this->registerTenantParticipantMappings($config->get('tenancy.multi_account.participant.mappings'));
}
|
[
"protected",
"function",
"registerMultiAccountTenancy",
"(",
"Repository",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"$",
"config",
"->",
"get",
"(",
"'tenancy.multi_account.enabled'",
",",
"false",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"registerMultiAccountParticipantRepository",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"registerTenantParticipantMappings",
"(",
"$",
"config",
"->",
"get",
"(",
"'tenancy.multi_account.participant.mappings'",
")",
")",
";",
"}"
] |
Set-up multi-account tenancy services
@param Repository $config
|
[
"Set",
"-",
"up",
"multi",
"-",
"account",
"tenancy",
"services"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L215-L223
|
234,266
|
dave-redfern/laravel-doctrine-tenancy
|
src/TenancyServiceProvider.php
|
TenancyServiceProvider.registerMultiSiteTenancy
|
protected function registerMultiSiteTenancy(Repository $config)
{
if (!$config->get('tenancy.multi_site.enabled', false)) {
return;
}
if (!$this->app instanceof TenantAwareApplication) {
throw new \RuntimeException(
'Multi-site requires updating your bootstrap/app.php to use TenantAwareApplication'
);
}
/*
* @todo Need a way to detect if RouteServiceProvider (or at least an instance of
* Foundation\RouteServiceProvider) has been registered and to fail with a
* warning if so.
*/
$this->registerMultiSiteParticipantRepository($config);
$this->registerMultiSiteConsoleCommands();
$this->registerTenantParticipantMappings($config->get('tenancy.multi_site.participant.mappings'));
}
|
php
|
protected function registerMultiSiteTenancy(Repository $config)
{
if (!$config->get('tenancy.multi_site.enabled', false)) {
return;
}
if (!$this->app instanceof TenantAwareApplication) {
throw new \RuntimeException(
'Multi-site requires updating your bootstrap/app.php to use TenantAwareApplication'
);
}
/*
* @todo Need a way to detect if RouteServiceProvider (or at least an instance of
* Foundation\RouteServiceProvider) has been registered and to fail with a
* warning if so.
*/
$this->registerMultiSiteParticipantRepository($config);
$this->registerMultiSiteConsoleCommands();
$this->registerTenantParticipantMappings($config->get('tenancy.multi_site.participant.mappings'));
}
|
[
"protected",
"function",
"registerMultiSiteTenancy",
"(",
"Repository",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"$",
"config",
"->",
"get",
"(",
"'tenancy.multi_site.enabled'",
",",
"false",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"instanceof",
"TenantAwareApplication",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Multi-site requires updating your bootstrap/app.php to use TenantAwareApplication'",
")",
";",
"}",
"/*\n * @todo Need a way to detect if RouteServiceProvider (or at least an instance of\n * Foundation\\RouteServiceProvider) has been registered and to fail with a\n * warning if so.\n */",
"$",
"this",
"->",
"registerMultiSiteParticipantRepository",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"registerMultiSiteConsoleCommands",
"(",
")",
";",
"$",
"this",
"->",
"registerTenantParticipantMappings",
"(",
"$",
"config",
"->",
"get",
"(",
"'tenancy.multi_site.participant.mappings'",
")",
")",
";",
"}"
] |
Set-up and check the app for multi-site tenancy
@param Repository $config
|
[
"Set",
"-",
"up",
"and",
"check",
"the",
"app",
"for",
"multi",
"-",
"site",
"tenancy"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L230-L251
|
234,267
|
dave-redfern/laravel-doctrine-tenancy
|
src/TenancyServiceProvider.php
|
TenancyServiceProvider.registerTenantParticipantMappings
|
protected function registerTenantParticipantMappings(array $mappings = [])
{
$resolver = $this->app->make('auth.tenant.type_resolver');
foreach ($mappings as $alias => $class) {
$resolver->addMapping($alias, $class);
}
}
|
php
|
protected function registerTenantParticipantMappings(array $mappings = [])
{
$resolver = $this->app->make('auth.tenant.type_resolver');
foreach ($mappings as $alias => $class) {
$resolver->addMapping($alias, $class);
}
}
|
[
"protected",
"function",
"registerTenantParticipantMappings",
"(",
"array",
"$",
"mappings",
"=",
"[",
"]",
")",
"{",
"$",
"resolver",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'auth.tenant.type_resolver'",
")",
";",
"foreach",
"(",
"$",
"mappings",
"as",
"$",
"alias",
"=>",
"$",
"class",
")",
"{",
"$",
"resolver",
"->",
"addMapping",
"(",
"$",
"alias",
",",
"$",
"class",
")",
";",
"}",
"}"
] |
Register the participant mapping aliases
@param array $mappings
@return void
|
[
"Register",
"the",
"participant",
"mapping",
"aliases"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/TenancyServiceProvider.php#L262-L268
|
234,268
|
oxygen-cms/core
|
src/Console/BlueprintListCommand.php
|
BlueprintListCommand.getTable
|
protected function getTable(array $blueprints) {
$results = [];
foreach($blueprints as $key => $blueprint) {
$results[] = $this->getGeneralInformation($key, $blueprint);
}
return array_filter($results);
}
|
php
|
protected function getTable(array $blueprints) {
$results = [];
foreach($blueprints as $key => $blueprint) {
$results[] = $this->getGeneralInformation($key, $blueprint);
}
return array_filter($results);
}
|
[
"protected",
"function",
"getTable",
"(",
"array",
"$",
"blueprints",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"blueprints",
"as",
"$",
"key",
"=>",
"$",
"blueprint",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"this",
"->",
"getGeneralInformation",
"(",
"$",
"key",
",",
"$",
"blueprint",
")",
";",
"}",
"return",
"array_filter",
"(",
"$",
"results",
")",
";",
"}"
] |
Compile the blueprints into a displayable format.
@param array $blueprints
@return array
|
[
"Compile",
"the",
"blueprints",
"into",
"a",
"displayable",
"format",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/BlueprintListCommand.php#L63-L71
|
234,269
|
opis/orm
|
src/Core/EntityMapper.php
|
EntityMapper.getTable
|
public function getTable(): string
{
if ($this->table === null) {
$this->table = $this->getEntityName() . 's';
}
return $this->table;
}
|
php
|
public function getTable(): string
{
if ($this->table === null) {
$this->table = $this->getEntityName() . 's';
}
return $this->table;
}
|
[
"public",
"function",
"getTable",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"table",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"table",
"=",
"$",
"this",
"->",
"getEntityName",
"(",
")",
".",
"'s'",
";",
"}",
"return",
"$",
"this",
"->",
"table",
";",
"}"
] |
Get the entity's table
@return string
|
[
"Get",
"the",
"entity",
"s",
"table"
] |
2723235be55242cd20452b8c9648d4823b7ce8b5
|
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L271-L278
|
234,270
|
opis/orm
|
src/Core/EntityMapper.php
|
EntityMapper.getForeignKey
|
public function getForeignKey(): ForeignKey
{
if ($this->foreignKey === null) {
$pk = $this->getPrimaryKey();
$prefix = $this->getEntityName();
$this->foreignKey = new class($pk, $prefix) extends ForeignKey
{
/**
* constructor.
* @param PrimaryKey $primaryKey
* @param string $prefix
*/
public function __construct(PrimaryKey $primaryKey, string $prefix)
{
$columns = [];
foreach ($primaryKey->columns() as $column) {
$columns[$column] = $prefix . '_' . $column;
}
parent::__construct($columns);
}
};
}
return $this->foreignKey;
}
|
php
|
public function getForeignKey(): ForeignKey
{
if ($this->foreignKey === null) {
$pk = $this->getPrimaryKey();
$prefix = $this->getEntityName();
$this->foreignKey = new class($pk, $prefix) extends ForeignKey
{
/**
* constructor.
* @param PrimaryKey $primaryKey
* @param string $prefix
*/
public function __construct(PrimaryKey $primaryKey, string $prefix)
{
$columns = [];
foreach ($primaryKey->columns() as $column) {
$columns[$column] = $prefix . '_' . $column;
}
parent::__construct($columns);
}
};
}
return $this->foreignKey;
}
|
[
"public",
"function",
"getForeignKey",
"(",
")",
":",
"ForeignKey",
"{",
"if",
"(",
"$",
"this",
"->",
"foreignKey",
"===",
"null",
")",
"{",
"$",
"pk",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getEntityName",
"(",
")",
";",
"$",
"this",
"->",
"foreignKey",
"=",
"new",
"class",
"(",
"$",
"pk",
",",
"$",
"prefix",
")",
"extends",
"ForeignKey",
"{",
"/**\n * constructor.\n * @param PrimaryKey $primaryKey\n * @param string $prefix\n */",
"public",
"function",
"__construct",
"(",
"PrimaryKey",
"$",
"primaryKey",
",",
"string",
"$",
"prefix",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"primaryKey",
"->",
"columns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"$",
"column",
"]",
"=",
"$",
"prefix",
".",
"'_'",
".",
"$",
"column",
";",
"}",
"parent",
"::",
"__construct",
"(",
"$",
"columns",
")",
";",
"}",
"}",
";",
"}",
"return",
"$",
"this",
"->",
"foreignKey",
";",
"}"
] |
Get the default foreign key
@return ForeignKey
|
[
"Get",
"the",
"default",
"foreign",
"key"
] |
2723235be55242cd20452b8c9648d4823b7ce8b5
|
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L304-L328
|
234,271
|
opis/orm
|
src/Core/EntityMapper.php
|
EntityMapper.getEntityName
|
protected function getEntityName()
{
if ($this->entityName === null) {
$name = $this->entityClass;
if (false !== $pos = strrpos($name, '\\')) {
$name = substr($name, $pos + 1);
}
$name = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $name));
$name = str_replace('-', '_', $name);
$this->entityName = $name;
}
return $this->entityName;
}
|
php
|
protected function getEntityName()
{
if ($this->entityName === null) {
$name = $this->entityClass;
if (false !== $pos = strrpos($name, '\\')) {
$name = substr($name, $pos + 1);
}
$name = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $name));
$name = str_replace('-', '_', $name);
$this->entityName = $name;
}
return $this->entityName;
}
|
[
"protected",
"function",
"getEntityName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entityName",
"===",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"entityClass",
";",
"if",
"(",
"false",
"!==",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'\\\\'",
")",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"$",
"name",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/([^A-Z])([A-Z])/'",
",",
"\"$1_$2\"",
",",
"$",
"name",
")",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"entityName",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"this",
"->",
"entityName",
";",
"}"
] |
Returns the entity's name
@return string
|
[
"Returns",
"the",
"entity",
"s",
"name"
] |
2723235be55242cd20452b8c9648d4823b7ce8b5
|
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/EntityMapper.php#L445-L459
|
234,272
|
kiwiz/esquery
|
src/Settings.php
|
Settings.load
|
public function load($arr) {
foreach($arr as $key=>$value) {
if(array_key_exists($key, self::$KEYS)) {
if($this->valid(self::$KEYS[$key], $value)) {
$this->$key = $value;
}
}
}
}
|
php
|
public function load($arr) {
foreach($arr as $key=>$value) {
if(array_key_exists($key, self::$KEYS)) {
if($this->valid(self::$KEYS[$key], $value)) {
$this->$key = $value;
}
}
}
}
|
[
"public",
"function",
"load",
"(",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"KEYS",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
"self",
"::",
"$",
"KEYS",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"}"
] |
Load settings from an array.
@param array $arr Settings array.
|
[
"Load",
"settings",
"from",
"an",
"array",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L65-L73
|
234,273
|
kiwiz/esquery
|
src/Settings.php
|
Settings.valid
|
private function valid($types, $value) {
$types = (array) $types;
foreach($types as $type) {
switch($type) {
case self::T_NULL:
if(is_null($value)) {
return true;
}
break;
case self::T_INT:
if(is_int($value)) {
return true;
}
break;
case self::T_STR:
if(is_string($value)) {
return true;
}
break;
case self::T_ARR:
if(is_array($value)) {
return true;
}
break;
}
}
return false;
}
|
php
|
private function valid($types, $value) {
$types = (array) $types;
foreach($types as $type) {
switch($type) {
case self::T_NULL:
if(is_null($value)) {
return true;
}
break;
case self::T_INT:
if(is_int($value)) {
return true;
}
break;
case self::T_STR:
if(is_string($value)) {
return true;
}
break;
case self::T_ARR:
if(is_array($value)) {
return true;
}
break;
}
}
return false;
}
|
[
"private",
"function",
"valid",
"(",
"$",
"types",
",",
"$",
"value",
")",
"{",
"$",
"types",
"=",
"(",
"array",
")",
"$",
"types",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"T_NULL",
":",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"case",
"self",
"::",
"T_INT",
":",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"case",
"self",
"::",
"T_STR",
":",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"case",
"self",
"::",
"T_ARR",
":",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check type.
@param int|int[] $types
@param mixed $value
@return bool Valid
|
[
"Check",
"type",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L81-L110
|
234,274
|
kiwiz/esquery
|
src/Settings.php
|
Settings.copy
|
public function copy() {
$settings = new Settings();
$settings->fields = $this->fields;
$settings->map = $this->map;
$settings->flatten = $this->flatten;
$settings->sort = $this->sort;
$settings->count = $this->count;
return $settings;
}
|
php
|
public function copy() {
$settings = new Settings();
$settings->fields = $this->fields;
$settings->map = $this->map;
$settings->flatten = $this->flatten;
$settings->sort = $this->sort;
$settings->count = $this->count;
return $settings;
}
|
[
"public",
"function",
"copy",
"(",
")",
"{",
"$",
"settings",
"=",
"new",
"Settings",
"(",
")",
";",
"$",
"settings",
"->",
"fields",
"=",
"$",
"this",
"->",
"fields",
";",
"$",
"settings",
"->",
"map",
"=",
"$",
"this",
"->",
"map",
";",
"$",
"settings",
"->",
"flatten",
"=",
"$",
"this",
"->",
"flatten",
";",
"$",
"settings",
"->",
"sort",
"=",
"$",
"this",
"->",
"sort",
";",
"$",
"settings",
"->",
"count",
"=",
"$",
"this",
"->",
"count",
";",
"return",
"$",
"settings",
";",
"}"
] |
Create a new object, copying over global settings.
@return Settings
|
[
"Create",
"a",
"new",
"object",
"copying",
"over",
"global",
"settings",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Settings.php#L116-L124
|
234,275
|
crysalead/sql-dialect
|
src/Statement/CreateTable.php
|
CreateTable.toString
|
public function toString()
{
if (!$this->_parts['table']) {
throw new SqlException("Invalid `CREATE TABLE` statement missing table name.");
}
if (!$this->_parts['columns']) {
throw new SqlException("Invalid `CREATE TABLE` statement missing columns.");
}
return 'CREATE TABLE' .
$this->_buildFlag('IF NOT EXISTS', $this->_parts['ifNotExists']) .
$this->_buildChunk($this->dialect()->name($this->_parts['table'])) .
$this->_buildDefinition($this->_parts['columns'], $this->_parts['constraints']) .
$this->_buildChunk($this->dialect()->meta('table', $this->_parts['meta']));
}
|
php
|
public function toString()
{
if (!$this->_parts['table']) {
throw new SqlException("Invalid `CREATE TABLE` statement missing table name.");
}
if (!$this->_parts['columns']) {
throw new SqlException("Invalid `CREATE TABLE` statement missing columns.");
}
return 'CREATE TABLE' .
$this->_buildFlag('IF NOT EXISTS', $this->_parts['ifNotExists']) .
$this->_buildChunk($this->dialect()->name($this->_parts['table'])) .
$this->_buildDefinition($this->_parts['columns'], $this->_parts['constraints']) .
$this->_buildChunk($this->dialect()->meta('table', $this->_parts['meta']));
}
|
[
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_parts",
"[",
"'table'",
"]",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Invalid `CREATE TABLE` statement missing table name.\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_parts",
"[",
"'columns'",
"]",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Invalid `CREATE TABLE` statement missing columns.\"",
")",
";",
"}",
"return",
"'CREATE TABLE'",
".",
"$",
"this",
"->",
"_buildFlag",
"(",
"'IF NOT EXISTS'",
",",
"$",
"this",
"->",
"_parts",
"[",
"'ifNotExists'",
"]",
")",
".",
"$",
"this",
"->",
"_buildChunk",
"(",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"name",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'table'",
"]",
")",
")",
".",
"$",
"this",
"->",
"_buildDefinition",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'columns'",
"]",
",",
"$",
"this",
"->",
"_parts",
"[",
"'constraints'",
"]",
")",
".",
"$",
"this",
"->",
"_buildChunk",
"(",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"meta",
"(",
"'table'",
",",
"$",
"this",
"->",
"_parts",
"[",
"'meta'",
"]",
")",
")",
";",
"}"
] |
Render the SQL statement.
@return string The generated SQL string.
|
[
"Render",
"the",
"SQL",
"statement",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/CreateTable.php#L115-L130
|
234,276
|
crysalead/sql-dialect
|
src/Statement/CreateTable.php
|
CreateTable._buildDefinition
|
protected function _buildDefinition($columns, $constraints)
{
foreach ($columns as $name => $field) {
$field['name'] = $name;
$field = $this->dialect()->field($field);
if (!empty($field['serial'])) {
$primary = $name;
}
$result[] = $this->dialect()->column($field);
}
foreach ($constraints as $constraint) {
if (!isset($constraint['type'])) {
throw new SqlException("Missing contraint type.");
}
$type = $constraint['type'];
if ($meta = $this->dialect()->constraint($type, $constraint, ['schemas' => ['' => $this]])) {
$result[] = $meta;
}
if ($type === 'primary') {
$primary = null;
}
}
if (isset($primary)) {
$result[] = $this->dialect()->constraint('primary', ['column' => $primary]);
}
return ' (' . join(', ', array_filter($result)) . ')';
}
|
php
|
protected function _buildDefinition($columns, $constraints)
{
foreach ($columns as $name => $field) {
$field['name'] = $name;
$field = $this->dialect()->field($field);
if (!empty($field['serial'])) {
$primary = $name;
}
$result[] = $this->dialect()->column($field);
}
foreach ($constraints as $constraint) {
if (!isset($constraint['type'])) {
throw new SqlException("Missing contraint type.");
}
$type = $constraint['type'];
if ($meta = $this->dialect()->constraint($type, $constraint, ['schemas' => ['' => $this]])) {
$result[] = $meta;
}
if ($type === 'primary') {
$primary = null;
}
}
if (isset($primary)) {
$result[] = $this->dialect()->constraint('primary', ['column' => $primary]);
}
return ' (' . join(', ', array_filter($result)) . ')';
}
|
[
"protected",
"function",
"_buildDefinition",
"(",
"$",
"columns",
",",
"$",
"constraints",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"field",
")",
"{",
"$",
"field",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"field",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
"[",
"'serial'",
"]",
")",
")",
"{",
"$",
"primary",
"=",
"$",
"name",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"column",
"(",
"$",
"field",
")",
";",
"}",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"constraint",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Missing contraint type.\"",
")",
";",
"}",
"$",
"type",
"=",
"$",
"constraint",
"[",
"'type'",
"]",
";",
"if",
"(",
"$",
"meta",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"constraint",
"(",
"$",
"type",
",",
"$",
"constraint",
",",
"[",
"'schemas'",
"=>",
"[",
"''",
"=>",
"$",
"this",
"]",
"]",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"meta",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"'primary'",
")",
"{",
"$",
"primary",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"primary",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"constraint",
"(",
"'primary'",
",",
"[",
"'column'",
"=>",
"$",
"primary",
"]",
")",
";",
"}",
"return",
"' ('",
".",
"join",
"(",
"', '",
",",
"array_filter",
"(",
"$",
"result",
")",
")",
".",
"')'",
";",
"}"
] |
Helper for building columns definition.
@param array $columns The columns.
@param array $constraints The columns constraints.
@return string The SQL columns definition list.
|
[
"Helper",
"for",
"building",
"columns",
"definition",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/CreateTable.php#L139-L168
|
234,277
|
txj123/zilf
|
src/Zilf/Validation/Validator.php
|
Validator.validateDate
|
protected function validateDate($attribute, $value)
{
if ($value instanceof DateTime) {
return true;
}
if (strtotime($value) === false) {
return false;
}
$date = date_parse($value);
return checkdate($date['month'], $date['day'], $date['year']);
}
|
php
|
protected function validateDate($attribute, $value)
{
if ($value instanceof DateTime) {
return true;
}
if (strtotime($value) === false) {
return false;
}
$date = date_parse($value);
return checkdate($date['month'], $date['day'], $date['year']);
}
|
[
"protected",
"function",
"validateDate",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"DateTime",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strtotime",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"date",
"=",
"date_parse",
"(",
"$",
"value",
")",
";",
"return",
"checkdate",
"(",
"$",
"date",
"[",
"'month'",
"]",
",",
"$",
"date",
"[",
"'day'",
"]",
",",
"$",
"date",
"[",
"'year'",
"]",
")",
";",
"}"
] |
Validate that an attribute is a valid date.
@param string $attribute
@param mixed $value
@return bool
|
[
"Validate",
"that",
"an",
"attribute",
"is",
"a",
"valid",
"date",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L1262-L1275
|
234,278
|
txj123/zilf
|
src/Zilf/Validation/Validator.php
|
Validator.callExtension
|
protected function callExtension($rule, $parameters)
{
$callback = $this->extensions[$rule];
if ($callback instanceof Closure) {
return call_user_func_array($callback, $parameters);
} elseif (is_string($callback)) {
return $this->callClassBasedExtension($callback, $parameters);
}
}
|
php
|
protected function callExtension($rule, $parameters)
{
$callback = $this->extensions[$rule];
if ($callback instanceof Closure) {
return call_user_func_array($callback, $parameters);
} elseif (is_string($callback)) {
return $this->callClassBasedExtension($callback, $parameters);
}
}
|
[
"protected",
"function",
"callExtension",
"(",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"extensions",
"[",
"$",
"rule",
"]",
";",
"if",
"(",
"$",
"callback",
"instanceof",
"Closure",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"$",
"this",
"->",
"callClassBasedExtension",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"}"
] |
Call a custom validator extension.
@param string $rule
@param array $parameters
@return bool
|
[
"Call",
"a",
"custom",
"validator",
"extension",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Validator.php#L2460-L2469
|
234,279
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Decoder.php
|
Zend_Json_Decoder._decodeValue
|
protected function _decodeValue()
{
switch ($this->_token) {
case self::DATUM:
$result = $this->_tokenValue;
$this->_getNextToken();
return($result);
break;
case self::LBRACE:
return($this->_decodeObject());
break;
case self::LBRACKET:
return($this->_decodeArray());
break;
default:
return null;
break;
}
}
|
php
|
protected function _decodeValue()
{
switch ($this->_token) {
case self::DATUM:
$result = $this->_tokenValue;
$this->_getNextToken();
return($result);
break;
case self::LBRACE:
return($this->_decodeObject());
break;
case self::LBRACKET:
return($this->_decodeArray());
break;
default:
return null;
break;
}
}
|
[
"protected",
"function",
"_decodeValue",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"_token",
")",
"{",
"case",
"self",
"::",
"DATUM",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"_tokenValue",
";",
"$",
"this",
"->",
"_getNextToken",
"(",
")",
";",
"return",
"(",
"$",
"result",
")",
";",
"break",
";",
"case",
"self",
"::",
"LBRACE",
":",
"return",
"(",
"$",
"this",
"->",
"_decodeObject",
"(",
")",
")",
";",
"break",
";",
"case",
"self",
"::",
"LBRACKET",
":",
"return",
"(",
"$",
"this",
"->",
"_decodeArray",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"}"
] |
Recursive driving rountine for supported toplevel tops
@return mixed
|
[
"Recursive",
"driving",
"rountine",
"for",
"supported",
"toplevel",
"tops"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Decoder.php#L168-L186
|
234,280
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Decoder.php
|
Zend_Json_Decoder._eatWhitespace
|
protected function _eatWhitespace()
{
if (preg_match(
'/([\t\b\f\n\r ])*/s',
$this->_source,
$matches,
PREG_OFFSET_CAPTURE,
$this->_offset
)
&& $matches[0][1] == $this->_offset
) {
$this->_offset += strlen($matches[0][0]);
}
}
|
php
|
protected function _eatWhitespace()
{
if (preg_match(
'/([\t\b\f\n\r ])*/s',
$this->_source,
$matches,
PREG_OFFSET_CAPTURE,
$this->_offset
)
&& $matches[0][1] == $this->_offset
) {
$this->_offset += strlen($matches[0][0]);
}
}
|
[
"protected",
"function",
"_eatWhitespace",
"(",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/([\\t\\b\\f\\n\\r ])*/s'",
",",
"$",
"this",
"->",
"_source",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
",",
"$",
"this",
"->",
"_offset",
")",
"&&",
"$",
"matches",
"[",
"0",
"]",
"[",
"1",
"]",
"==",
"$",
"this",
"->",
"_offset",
")",
"{",
"$",
"this",
"->",
"_offset",
"+=",
"strlen",
"(",
"$",
"matches",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"}",
"}"
] |
Removes whitepsace characters from the source input
|
[
"Removes",
"whitepsace",
"characters",
"from",
"the",
"source",
"input"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Decoder.php#L288-L301
|
234,281
|
dave-redfern/laravel-doctrine-tenancy
|
src/Http/Middleware/TenantSiteResolver.php
|
TenantSiteResolver.appendPathsInFinder
|
protected function appendPathsInFinder(TenantViewFinder $finder, TenantParticipant $tenant)
{
$finder->prependLocation($this->createViewPath($tenant->getTenantOwner()->getDomain()));
$finder->prependLocation($this->createViewPath($tenant->getDomain()));
return $finder->getPaths();
}
|
php
|
protected function appendPathsInFinder(TenantViewFinder $finder, TenantParticipant $tenant)
{
$finder->prependLocation($this->createViewPath($tenant->getTenantOwner()->getDomain()));
$finder->prependLocation($this->createViewPath($tenant->getDomain()));
return $finder->getPaths();
}
|
[
"protected",
"function",
"appendPathsInFinder",
"(",
"TenantViewFinder",
"$",
"finder",
",",
"TenantParticipant",
"$",
"tenant",
")",
"{",
"$",
"finder",
"->",
"prependLocation",
"(",
"$",
"this",
"->",
"createViewPath",
"(",
"$",
"tenant",
"->",
"getTenantOwner",
"(",
")",
"->",
"getDomain",
"(",
")",
")",
")",
";",
"$",
"finder",
"->",
"prependLocation",
"(",
"$",
"this",
"->",
"createViewPath",
"(",
"$",
"tenant",
"->",
"getDomain",
"(",
")",
")",
")",
";",
"return",
"$",
"finder",
"->",
"getPaths",
"(",
")",
";",
"}"
] |
Prepends the view paths to the FileViewFinder, provided it has been replaced
@param TenantViewFinder $finder
@param TenantParticipant $tenant
@return array
|
[
"Prepends",
"the",
"view",
"paths",
"to",
"the",
"FileViewFinder",
"provided",
"it",
"has",
"been",
"replaced"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Http/Middleware/TenantSiteResolver.php#L101-L107
|
234,282
|
dave-redfern/laravel-doctrine-tenancy
|
src/Http/Middleware/TenantSiteResolver.php
|
TenantSiteResolver.registerPathsInFinder
|
protected function registerPathsInFinder(Factory $view, FileViewFinder $finder, TenantParticipant $tenant)
{
$paths = [];
$this->addPathToViewPaths($paths, $tenant->getDomain());
$this->addPathToViewPaths($paths, $tenant->getTenantOwner()->getDomain());
$paths = array_merge($paths, $finder->getPaths());
$finder = $this->createViewFinder($finder, $paths);
// replace ViewFinder in ViewManager with new instance with ordered paths
$view->setFinder($finder);
return $paths;
}
|
php
|
protected function registerPathsInFinder(Factory $view, FileViewFinder $finder, TenantParticipant $tenant)
{
$paths = [];
$this->addPathToViewPaths($paths, $tenant->getDomain());
$this->addPathToViewPaths($paths, $tenant->getTenantOwner()->getDomain());
$paths = array_merge($paths, $finder->getPaths());
$finder = $this->createViewFinder($finder, $paths);
// replace ViewFinder in ViewManager with new instance with ordered paths
$view->setFinder($finder);
return $paths;
}
|
[
"protected",
"function",
"registerPathsInFinder",
"(",
"Factory",
"$",
"view",
",",
"FileViewFinder",
"$",
"finder",
",",
"TenantParticipant",
"$",
"tenant",
")",
"{",
"$",
"paths",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"addPathToViewPaths",
"(",
"$",
"paths",
",",
"$",
"tenant",
"->",
"getDomain",
"(",
")",
")",
";",
"$",
"this",
"->",
"addPathToViewPaths",
"(",
"$",
"paths",
",",
"$",
"tenant",
"->",
"getTenantOwner",
"(",
")",
"->",
"getDomain",
"(",
")",
")",
";",
"$",
"paths",
"=",
"array_merge",
"(",
"$",
"paths",
",",
"$",
"finder",
"->",
"getPaths",
"(",
")",
")",
";",
"$",
"finder",
"=",
"$",
"this",
"->",
"createViewFinder",
"(",
"$",
"finder",
",",
"$",
"paths",
")",
";",
"// replace ViewFinder in ViewManager with new instance with ordered paths",
"$",
"view",
"->",
"setFinder",
"(",
"$",
"finder",
")",
";",
"return",
"$",
"paths",
";",
"}"
] |
Registers the view paths by creating a new array and injecting a new FileViewFinder
@param Factory $view
@param FileViewFinder $finder
@param TenantParticipant $tenant
@return array
|
[
"Registers",
"the",
"view",
"paths",
"by",
"creating",
"a",
"new",
"array",
"and",
"injecting",
"a",
"new",
"FileViewFinder"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Http/Middleware/TenantSiteResolver.php#L118-L131
|
234,283
|
dave-redfern/laravel-doctrine-tenancy
|
src/Http/Middleware/TenantSiteResolver.php
|
TenantSiteResolver.createViewFinder
|
protected function createViewFinder(FileViewFinder $finder, array $paths = [])
{
$new = new FileViewFinder(app('files'), $paths, $finder->getExtensions());
foreach ($finder->getHints() as $namespace => $hints) {
$new->addNamespace($namespace, $hints);
}
return $new;
}
|
php
|
protected function createViewFinder(FileViewFinder $finder, array $paths = [])
{
$new = new FileViewFinder(app('files'), $paths, $finder->getExtensions());
foreach ($finder->getHints() as $namespace => $hints) {
$new->addNamespace($namespace, $hints);
}
return $new;
}
|
[
"protected",
"function",
"createViewFinder",
"(",
"FileViewFinder",
"$",
"finder",
",",
"array",
"$",
"paths",
"=",
"[",
"]",
")",
"{",
"$",
"new",
"=",
"new",
"FileViewFinder",
"(",
"app",
"(",
"'files'",
")",
",",
"$",
"paths",
",",
"$",
"finder",
"->",
"getExtensions",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"finder",
"->",
"getHints",
"(",
")",
"as",
"$",
"namespace",
"=>",
"$",
"hints",
")",
"{",
"$",
"new",
"->",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"hints",
")",
";",
"}",
"return",
"$",
"new",
";",
"}"
] |
Creates a new FileViewFinder, copying the current contents
@param FileViewFinder $finder
@param array $paths
@return FileViewFinder
|
[
"Creates",
"a",
"new",
"FileViewFinder",
"copying",
"the",
"current",
"contents"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Http/Middleware/TenantSiteResolver.php#L141-L150
|
234,284
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.createRoute
|
protected function createRoute(array $methods, string $name, string $path, $target, array $matchers = []) : Route
{
$builder = RouteBuilder::route($this->defaultRouteClass);
$builder->from($path)->to($target);
foreach ($methods as $method) {
$builder->accepting($method);
}
$builder->named($name);
foreach ($matchers as $param => $paramMatchers) {
foreach ($paramMatchers as $matcher) {
$builder->ifMatches($param, $matcher);
}
}
return $builder->build();
}
|
php
|
protected function createRoute(array $methods, string $name, string $path, $target, array $matchers = []) : Route
{
$builder = RouteBuilder::route($this->defaultRouteClass);
$builder->from($path)->to($target);
foreach ($methods as $method) {
$builder->accepting($method);
}
$builder->named($name);
foreach ($matchers as $param => $paramMatchers) {
foreach ($paramMatchers as $matcher) {
$builder->ifMatches($param, $matcher);
}
}
return $builder->build();
}
|
[
"protected",
"function",
"createRoute",
"(",
"array",
"$",
"methods",
",",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"Route",
"{",
"$",
"builder",
"=",
"RouteBuilder",
"::",
"route",
"(",
"$",
"this",
"->",
"defaultRouteClass",
")",
";",
"$",
"builder",
"->",
"from",
"(",
"$",
"path",
")",
"->",
"to",
"(",
"$",
"target",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"builder",
"->",
"accepting",
"(",
"$",
"method",
")",
";",
"}",
"$",
"builder",
"->",
"named",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"matchers",
"as",
"$",
"param",
"=>",
"$",
"paramMatchers",
")",
"{",
"foreach",
"(",
"$",
"paramMatchers",
"as",
"$",
"matcher",
")",
"{",
"$",
"builder",
"->",
"ifMatches",
"(",
"$",
"param",
",",
"$",
"matcher",
")",
";",
"}",
"}",
"return",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"}"
] |
Creates a route using given params
@param array $methods
@param string $name
@param string $path
@param mixed $target
@param array $matchers
@return Route
|
[
"Creates",
"a",
"route",
"using",
"given",
"params"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L237-L256
|
234,285
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.get
|
public function get(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute(['GET'], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
php
|
public function get(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute(['GET'], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"[",
"'GET'",
"]",
",",
"$",
"name",
",",
"$",
"path",
",",
"$",
"target",
",",
"$",
"matchers",
")",
";",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a GET route
@param string $name
@param string $path
@param mixed $target
@param callable[][] $matchers
@return Adrenaline
|
[
"Adds",
"a",
"GET",
"route"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L267-L272
|
234,286
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.put
|
public function put(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_PUT], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
php
|
public function put(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_PUT], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
[
"public",
"function",
"put",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"[",
"RequestMethodInterface",
"::",
"METHOD_PUT",
"]",
",",
"$",
"name",
",",
"$",
"path",
",",
"$",
"target",
",",
"$",
"matchers",
")",
";",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a PUT route
@param string $name
@param string $path
@param mixed $target
@param callable[][] $matchers
@return Adrenaline
|
[
"Adds",
"a",
"PUT",
"route"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L299-L304
|
234,287
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.delete
|
public function delete(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_DELETE], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
php
|
public function delete(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_DELETE], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
[
"public",
"function",
"delete",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"[",
"RequestMethodInterface",
"::",
"METHOD_DELETE",
"]",
",",
"$",
"name",
",",
"$",
"path",
",",
"$",
"target",
",",
"$",
"matchers",
")",
";",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a DELETE route
@param string $name
@param string $path
@param mixed $target
@param callable[][] $matchers
@return Adrenaline
|
[
"Adds",
"a",
"DELETE",
"route"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L315-L320
|
234,288
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.options
|
public function options(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_OPTIONS], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
php
|
public function options(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_OPTIONS], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
[
"public",
"function",
"options",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"[",
"RequestMethodInterface",
"::",
"METHOD_OPTIONS",
"]",
",",
"$",
"name",
",",
"$",
"path",
",",
"$",
"target",
",",
"$",
"matchers",
")",
";",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an OPTIONS route
@param string $name
@param string $path
@param mixed $target
@param callable[][] $matchers
@return Adrenaline
|
[
"Adds",
"an",
"OPTIONS",
"route"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L331-L336
|
234,289
|
bitExpert/adrenaline
|
src/bitExpert/Adrenaline/Adrenaline.php
|
Adrenaline.patch
|
public function patch(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_PATCH], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
php
|
public function patch(string $name, string $path, $target, array $matchers = []) : self
{
$route = $this->createRoute([RequestMethodInterface::METHOD_PATCH], $name, $path, $target, $matchers);
$this->addRoute($route);
return $this;
}
|
[
"public",
"function",
"patch",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"$",
"target",
",",
"array",
"$",
"matchers",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"[",
"RequestMethodInterface",
"::",
"METHOD_PATCH",
"]",
",",
"$",
"name",
",",
"$",
"path",
",",
"$",
"target",
",",
"$",
"matchers",
")",
";",
"$",
"this",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a PATCH route
@param string $name
@param string $path
@param mixed $target
@param callable[][] $matchers
@return Adrenaline
|
[
"Adds",
"a",
"PATCH",
"route"
] |
2cb9b79147dee04221261d765d66416f0b796b0f
|
https://github.com/bitExpert/adrenaline/blob/2cb9b79147dee04221261d765d66416f0b796b0f/src/bitExpert/Adrenaline/Adrenaline.php#L347-L352
|
234,290
|
txj123/zilf
|
src/Zilf/Db/QueryBuilder.php
|
QueryBuilder.prepareInsertValues
|
protected function prepareInsertValues($table, $columns, $params = [])
{
$schema = $this->db->getSchema();
$tableSchema = $schema->getTableSchema($table);
$columnSchemas = $tableSchema !== null ? $tableSchema->columns : [];
$names = [];
$placeholders = [];
$values = ' DEFAULT VALUES';
if ($columns instanceof Query) {
list($names, $values, $params) = $this->prepareInsertSelectSubQuery($columns, $schema, $params);
} else {
foreach ($columns as $name => $value) {
$names[] = $schema->quoteColumnName($name);
$value = isset($columnSchemas[$name]) ? $columnSchemas[$name]->dbTypecast($value) : $value;
if ($value instanceof ExpressionInterface) {
$placeholders[] = $this->buildExpression($value, $params);
} elseif ($value instanceof \Zilf\Db\Query) {
list($sql, $params) = $this->build($value, $params);
$placeholders[] = "($sql)";
} else {
$placeholders[] = $this->bindParam($value, $params);
}
}
}
return [$names, $placeholders, $values, $params];
}
|
php
|
protected function prepareInsertValues($table, $columns, $params = [])
{
$schema = $this->db->getSchema();
$tableSchema = $schema->getTableSchema($table);
$columnSchemas = $tableSchema !== null ? $tableSchema->columns : [];
$names = [];
$placeholders = [];
$values = ' DEFAULT VALUES';
if ($columns instanceof Query) {
list($names, $values, $params) = $this->prepareInsertSelectSubQuery($columns, $schema, $params);
} else {
foreach ($columns as $name => $value) {
$names[] = $schema->quoteColumnName($name);
$value = isset($columnSchemas[$name]) ? $columnSchemas[$name]->dbTypecast($value) : $value;
if ($value instanceof ExpressionInterface) {
$placeholders[] = $this->buildExpression($value, $params);
} elseif ($value instanceof \Zilf\Db\Query) {
list($sql, $params) = $this->build($value, $params);
$placeholders[] = "($sql)";
} else {
$placeholders[] = $this->bindParam($value, $params);
}
}
}
return [$names, $placeholders, $values, $params];
}
|
[
"protected",
"function",
"prepareInsertValues",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"db",
"->",
"getSchema",
"(",
")",
";",
"$",
"tableSchema",
"=",
"$",
"schema",
"->",
"getTableSchema",
"(",
"$",
"table",
")",
";",
"$",
"columnSchemas",
"=",
"$",
"tableSchema",
"!==",
"null",
"?",
"$",
"tableSchema",
"->",
"columns",
":",
"[",
"]",
";",
"$",
"names",
"=",
"[",
"]",
";",
"$",
"placeholders",
"=",
"[",
"]",
";",
"$",
"values",
"=",
"' DEFAULT VALUES'",
";",
"if",
"(",
"$",
"columns",
"instanceof",
"Query",
")",
"{",
"list",
"(",
"$",
"names",
",",
"$",
"values",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"prepareInsertSelectSubQuery",
"(",
"$",
"columns",
",",
"$",
"schema",
",",
"$",
"params",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"schema",
"->",
"quoteColumnName",
"(",
"$",
"name",
")",
";",
"$",
"value",
"=",
"isset",
"(",
"$",
"columnSchemas",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"columnSchemas",
"[",
"$",
"name",
"]",
"->",
"dbTypecast",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"if",
"(",
"$",
"value",
"instanceof",
"ExpressionInterface",
")",
"{",
"$",
"placeholders",
"[",
"]",
"=",
"$",
"this",
"->",
"buildExpression",
"(",
"$",
"value",
",",
"$",
"params",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"\\",
"Zilf",
"\\",
"Db",
"\\",
"Query",
")",
"{",
"list",
"(",
"$",
"sql",
",",
"$",
"params",
")",
"=",
"$",
"this",
"->",
"build",
"(",
"$",
"value",
",",
"$",
"params",
")",
";",
"$",
"placeholders",
"[",
"]",
"=",
"\"($sql)\"",
";",
"}",
"else",
"{",
"$",
"placeholders",
"[",
"]",
"=",
"$",
"this",
"->",
"bindParam",
"(",
"$",
"value",
",",
"$",
"params",
")",
";",
"}",
"}",
"}",
"return",
"[",
"$",
"names",
",",
"$",
"placeholders",
",",
"$",
"values",
",",
"$",
"params",
"]",
";",
"}"
] |
Prepares a `VALUES` part for an `INSERT` SQL statement.
@param string $table the table that new rows will be inserted into.
@param array|Query $columns the column data (name => value) to be inserted into the table or instance
of [[Zilf\Db\Query|Query]] to perform INSERT INTO ... SELECT SQL statement.
@param array $params the binding parameters that will be generated by this method.
They should be bound to the DB command later.
@return array array of column names, placeholders, values and params.
@since 2.0.14
|
[
"Prepares",
"a",
"VALUES",
"part",
"for",
"an",
"INSERT",
"SQL",
"statement",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/QueryBuilder.php#L364-L390
|
234,291
|
appzcoder/phpcloc
|
src/Analyzers/ClocAnalyzer.php
|
ClocAnalyzer.setStats
|
protected function setStats($extension, $stat)
{
if (isset($this->stats[$extension])) {
$this->stats[$extension]['files'] += $stat['files'];
$this->stats[$extension]['blank'] += $stat['blank'];
$this->stats[$extension]['comment'] += $stat['comment'];
$this->stats[$extension]['code'] += $stat['code'];
} else {
$this->stats[$extension] = $stat;
}
}
|
php
|
protected function setStats($extension, $stat)
{
if (isset($this->stats[$extension])) {
$this->stats[$extension]['files'] += $stat['files'];
$this->stats[$extension]['blank'] += $stat['blank'];
$this->stats[$extension]['comment'] += $stat['comment'];
$this->stats[$extension]['code'] += $stat['code'];
} else {
$this->stats[$extension] = $stat;
}
}
|
[
"protected",
"function",
"setStats",
"(",
"$",
"extension",
",",
"$",
"stat",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
")",
")",
"{",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
"[",
"'files'",
"]",
"+=",
"$",
"stat",
"[",
"'files'",
"]",
";",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
"[",
"'blank'",
"]",
"+=",
"$",
"stat",
"[",
"'blank'",
"]",
";",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
"[",
"'comment'",
"]",
"+=",
"$",
"stat",
"[",
"'comment'",
"]",
";",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
"[",
"'code'",
"]",
"+=",
"$",
"stat",
"[",
"'code'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"stats",
"[",
"$",
"extension",
"]",
"=",
"$",
"stat",
";",
"}",
"}"
] |
Set or increment the stat.
@param string $extension
@param array $stat
@return void
|
[
"Set",
"or",
"increment",
"the",
"stat",
"."
] |
0fa4b45e490238e7210009e4a1278e7a1c98d0c2
|
https://github.com/appzcoder/phpcloc/blob/0fa4b45e490238e7210009e4a1278e7a1c98d0c2/src/Analyzers/ClocAnalyzer.php#L318-L328
|
234,292
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Util/Value.php
|
Value.encode
|
public static function encode($strategy, $value)
{
switch ($strategy) {
case 'explode':
return implode(',', $value);
case 'json':
return json_encode($value);
case 'serialize':
return serialize($value);
}
return $value;
}
|
php
|
public static function encode($strategy, $value)
{
switch ($strategy) {
case 'explode':
return implode(',', $value);
case 'json':
return json_encode($value);
case 'serialize':
return serialize($value);
}
return $value;
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"strategy",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"strategy",
")",
"{",
"case",
"'explode'",
":",
"return",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"case",
"'json'",
":",
"return",
"json_encode",
"(",
"$",
"value",
")",
";",
"case",
"'serialize'",
":",
"return",
"serialize",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Encode a value based on the strategy
@param string $strategy
@param string $value
@access public
@return string
|
[
"Encode",
"a",
"value",
"based",
"on",
"the",
"strategy"
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Util/Value.php#L30-L42
|
234,293
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Util/Value.php
|
Value.decode
|
public static function decode($strategy, $value)
{
switch ($strategy) {
case 'explode':
return explode(',', $value);
case 'json':
return json_decode($value);
case 'serialize':
return unserialize($value);
}
return $value;
}
|
php
|
public static function decode($strategy, $value)
{
switch ($strategy) {
case 'explode':
return explode(',', $value);
case 'json':
return json_decode($value);
case 'serialize':
return unserialize($value);
}
return $value;
}
|
[
"public",
"static",
"function",
"decode",
"(",
"$",
"strategy",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"strategy",
")",
"{",
"case",
"'explode'",
":",
"return",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"case",
"'json'",
":",
"return",
"json_decode",
"(",
"$",
"value",
")",
";",
"case",
"'serialize'",
":",
"return",
"unserialize",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Decode a value based on the strategy.
@param string $strategy
@param string $value
@access public
@return array|mixed
|
[
"Decode",
"a",
"value",
"based",
"on",
"the",
"strategy",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Util/Value.php#L53-L65
|
234,294
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Barcode.php
|
Zend_Validate_Barcode.setType
|
public function setType($barcodeType)
{
switch (strtolower($barcodeType)) {
case 'upc':
case 'upc-a':
$className = 'UpcA';
break;
case 'ean13':
case 'ean-13':
$className = 'Ean13';
break;
default:
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Barcode type '$barcodeType' is not supported'");
break;
}
include_once 'Zend/Validate/Barcode/' . $className . '.php';
$class = 'Zend_Validate_Barcode_' . $className;
$this->_barcodeValidator = new $class;
}
|
php
|
public function setType($barcodeType)
{
switch (strtolower($barcodeType)) {
case 'upc':
case 'upc-a':
$className = 'UpcA';
break;
case 'ean13':
case 'ean-13':
$className = 'Ean13';
break;
default:
include_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Barcode type '$barcodeType' is not supported'");
break;
}
include_once 'Zend/Validate/Barcode/' . $className . '.php';
$class = 'Zend_Validate_Barcode_' . $className;
$this->_barcodeValidator = new $class;
}
|
[
"public",
"function",
"setType",
"(",
"$",
"barcodeType",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"barcodeType",
")",
")",
"{",
"case",
"'upc'",
":",
"case",
"'upc-a'",
":",
"$",
"className",
"=",
"'UpcA'",
";",
"break",
";",
"case",
"'ean13'",
":",
"case",
"'ean-13'",
":",
"$",
"className",
"=",
"'Ean13'",
";",
"break",
";",
"default",
":",
"include_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"Barcode type '$barcodeType' is not supported'\"",
")",
";",
"break",
";",
"}",
"include_once",
"'Zend/Validate/Barcode/'",
".",
"$",
"className",
".",
"'.php'",
";",
"$",
"class",
"=",
"'Zend_Validate_Barcode_'",
".",
"$",
"className",
";",
"$",
"this",
"->",
"_barcodeValidator",
"=",
"new",
"$",
"class",
";",
"}"
] |
Sets a new barcode validator
@param string $barcodeType - Barcode validator to use
@return void
@throws Zend_Validate_Exception
|
[
"Sets",
"a",
"new",
"barcode",
"validator"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Barcode.php#L64-L85
|
234,295
|
dave-redfern/laravel-doctrine-tenancy
|
src/View/FileViewFinder.php
|
FileViewFinder.prependLocation
|
public function prependLocation($location)
{
if ($location && !in_array($location, $this->paths)) {
array_unshift($this->paths, $location);
}
return $this;
}
|
php
|
public function prependLocation($location)
{
if ($location && !in_array($location, $this->paths)) {
array_unshift($this->paths, $location);
}
return $this;
}
|
[
"public",
"function",
"prependLocation",
"(",
"$",
"location",
")",
"{",
"if",
"(",
"$",
"location",
"&&",
"!",
"in_array",
"(",
"$",
"location",
",",
"$",
"this",
"->",
"paths",
")",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"paths",
",",
"$",
"location",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Append a path to the top of the array of paths
@param string $location
@return $this
|
[
"Append",
"a",
"path",
"to",
"the",
"top",
"of",
"the",
"array",
"of",
"paths"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/View/FileViewFinder.php#L40-L47
|
234,296
|
txj123/zilf
|
src/Zilf/Queue/Listener.php
|
Listener.formatCommand
|
protected function formatCommand($command, $connection, $queue, ListenerOptions $options)
{
return sprintf(
$command,
ProcessUtils::escapeArgument($connection),
ProcessUtils::escapeArgument($queue),
$options->delay, $options->memory,
$options->sleep, $options->maxTries
);
}
|
php
|
protected function formatCommand($command, $connection, $queue, ListenerOptions $options)
{
return sprintf(
$command,
ProcessUtils::escapeArgument($connection),
ProcessUtils::escapeArgument($queue),
$options->delay, $options->memory,
$options->sleep, $options->maxTries
);
}
|
[
"protected",
"function",
"formatCommand",
"(",
"$",
"command",
",",
"$",
"connection",
",",
"$",
"queue",
",",
"ListenerOptions",
"$",
"options",
")",
"{",
"return",
"sprintf",
"(",
"$",
"command",
",",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"connection",
")",
",",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"queue",
")",
",",
"$",
"options",
"->",
"delay",
",",
"$",
"options",
"->",
"memory",
",",
"$",
"options",
"->",
"sleep",
",",
"$",
"options",
"->",
"maxTries",
")",
";",
"}"
] |
Format the given command with the listener options.
@param string $command
@param string $connection
@param string $queue
@param \Illuminate\Queue\ListenerOptions $options
@return string
|
[
"Format",
"the",
"given",
"command",
"with",
"the",
"listener",
"options",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Queue/Listener.php#L171-L180
|
234,297
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/phpQueryEvents.php
|
phpQueryEvents.trigger
|
public static function trigger($document, $type, $data = array(), $node = null)
{
// trigger: function(type, data, elem, donative, extra) {
$documentID = phpQuery::getDocumentID($document);
$namespace = null;
if (strpos($type, '.') !== false) {
list($name, $namespace) = explode('.', $type);
} else {
$name = $type;
}
if (! $node) {
if (self::issetGlobal($documentID, $type)) {
$pq = phpQuery::getDocument($documentID);
// TODO check add($pq->document)
$pq->find('*')->add($pq->document)
->trigger($type, $data);
}
} else {
if (isset($data[0]) && $data[0] instanceof DOMEvent) {
$event = $data[0];
$event->relatedTarget = $event->target;
$event->target = $node;
$data = array_slice($data, 1);
} else {
$event = new DOMEvent(
array(
'type' => $type,
'target' => $node,
'timeStamp' => time(),
)
);
}
$i = 0;
while($node) {
// TODO whois
phpQuery::debug(
"Triggering ".($i?"bubbled ":'')."event '{$type}' on "
."node \n"
);//.phpQueryObject::whois($node)."\n");
$event->currentTarget = $node;
$eventNode = self::getNode($documentID, $node);
if (isset($eventNode->eventHandlers)) {
foreach($eventNode->eventHandlers as $eventType => $handlers) {
$eventNamespace = null;
if (strpos($type, '.') !== false) {
list($eventName, $eventNamespace) = explode('.', $eventType);
} else {
$eventName = $eventType;
}
if ($name != $eventName) {
continue;
}
if ($namespace && $eventNamespace && $namespace != $eventNamespace) {
continue;
}
foreach($handlers as $handler) {
phpQuery::debug("Calling event handler\n");
$event->data = $handler['data']
? $handler['data']
: null;
$params = array_merge(array($event), $data);
$return = phpQuery::callbackRun($handler['callback'], $params);
if ($return === false) {
$event->bubbles = false;
}
}
}
}
// to bubble or not to bubble...
if (! $event->bubbles) {
break;
}
$node = $node->parentNode;
$i++;
}
}
}
|
php
|
public static function trigger($document, $type, $data = array(), $node = null)
{
// trigger: function(type, data, elem, donative, extra) {
$documentID = phpQuery::getDocumentID($document);
$namespace = null;
if (strpos($type, '.') !== false) {
list($name, $namespace) = explode('.', $type);
} else {
$name = $type;
}
if (! $node) {
if (self::issetGlobal($documentID, $type)) {
$pq = phpQuery::getDocument($documentID);
// TODO check add($pq->document)
$pq->find('*')->add($pq->document)
->trigger($type, $data);
}
} else {
if (isset($data[0]) && $data[0] instanceof DOMEvent) {
$event = $data[0];
$event->relatedTarget = $event->target;
$event->target = $node;
$data = array_slice($data, 1);
} else {
$event = new DOMEvent(
array(
'type' => $type,
'target' => $node,
'timeStamp' => time(),
)
);
}
$i = 0;
while($node) {
// TODO whois
phpQuery::debug(
"Triggering ".($i?"bubbled ":'')."event '{$type}' on "
."node \n"
);//.phpQueryObject::whois($node)."\n");
$event->currentTarget = $node;
$eventNode = self::getNode($documentID, $node);
if (isset($eventNode->eventHandlers)) {
foreach($eventNode->eventHandlers as $eventType => $handlers) {
$eventNamespace = null;
if (strpos($type, '.') !== false) {
list($eventName, $eventNamespace) = explode('.', $eventType);
} else {
$eventName = $eventType;
}
if ($name != $eventName) {
continue;
}
if ($namespace && $eventNamespace && $namespace != $eventNamespace) {
continue;
}
foreach($handlers as $handler) {
phpQuery::debug("Calling event handler\n");
$event->data = $handler['data']
? $handler['data']
: null;
$params = array_merge(array($event), $data);
$return = phpQuery::callbackRun($handler['callback'], $params);
if ($return === false) {
$event->bubbles = false;
}
}
}
}
// to bubble or not to bubble...
if (! $event->bubbles) {
break;
}
$node = $node->parentNode;
$i++;
}
}
}
|
[
"public",
"static",
"function",
"trigger",
"(",
"$",
"document",
",",
"$",
"type",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"node",
"=",
"null",
")",
"{",
"// trigger: function(type, data, elem, donative, extra) {",
"$",
"documentID",
"=",
"phpQuery",
"::",
"getDocumentID",
"(",
"$",
"document",
")",
";",
"$",
"namespace",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"namespace",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"type",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"type",
";",
"}",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"if",
"(",
"self",
"::",
"issetGlobal",
"(",
"$",
"documentID",
",",
"$",
"type",
")",
")",
"{",
"$",
"pq",
"=",
"phpQuery",
"::",
"getDocument",
"(",
"$",
"documentID",
")",
";",
"// TODO check add($pq->document)",
"$",
"pq",
"->",
"find",
"(",
"'*'",
")",
"->",
"add",
"(",
"$",
"pq",
"->",
"document",
")",
"->",
"trigger",
"(",
"$",
"type",
",",
"$",
"data",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"&&",
"$",
"data",
"[",
"0",
"]",
"instanceof",
"DOMEvent",
")",
"{",
"$",
"event",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"event",
"->",
"relatedTarget",
"=",
"$",
"event",
"->",
"target",
";",
"$",
"event",
"->",
"target",
"=",
"$",
"node",
";",
"$",
"data",
"=",
"array_slice",
"(",
"$",
"data",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"event",
"=",
"new",
"DOMEvent",
"(",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'target'",
"=>",
"$",
"node",
",",
"'timeStamp'",
"=>",
"time",
"(",
")",
",",
")",
")",
";",
"}",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"node",
")",
"{",
"// TODO whois",
"phpQuery",
"::",
"debug",
"(",
"\"Triggering \"",
".",
"(",
"$",
"i",
"?",
"\"bubbled \"",
":",
"''",
")",
".",
"\"event '{$type}' on \"",
".",
"\"node \\n\"",
")",
";",
"//.phpQueryObject::whois($node).\"\\n\");",
"$",
"event",
"->",
"currentTarget",
"=",
"$",
"node",
";",
"$",
"eventNode",
"=",
"self",
"::",
"getNode",
"(",
"$",
"documentID",
",",
"$",
"node",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"eventNode",
"->",
"eventHandlers",
")",
")",
"{",
"foreach",
"(",
"$",
"eventNode",
"->",
"eventHandlers",
"as",
"$",
"eventType",
"=>",
"$",
"handlers",
")",
"{",
"$",
"eventNamespace",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"eventName",
",",
"$",
"eventNamespace",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"eventType",
")",
";",
"}",
"else",
"{",
"$",
"eventName",
"=",
"$",
"eventType",
";",
"}",
"if",
"(",
"$",
"name",
"!=",
"$",
"eventName",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"namespace",
"&&",
"$",
"eventNamespace",
"&&",
"$",
"namespace",
"!=",
"$",
"eventNamespace",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"handlers",
"as",
"$",
"handler",
")",
"{",
"phpQuery",
"::",
"debug",
"(",
"\"Calling event handler\\n\"",
")",
";",
"$",
"event",
"->",
"data",
"=",
"$",
"handler",
"[",
"'data'",
"]",
"?",
"$",
"handler",
"[",
"'data'",
"]",
":",
"null",
";",
"$",
"params",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"event",
")",
",",
"$",
"data",
")",
";",
"$",
"return",
"=",
"phpQuery",
"::",
"callbackRun",
"(",
"$",
"handler",
"[",
"'callback'",
"]",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"return",
"===",
"false",
")",
"{",
"$",
"event",
"->",
"bubbles",
"=",
"false",
";",
"}",
"}",
"}",
"}",
"// to bubble or not to bubble...",
"if",
"(",
"!",
"$",
"event",
"->",
"bubbles",
")",
"{",
"break",
";",
"}",
"$",
"node",
"=",
"$",
"node",
"->",
"parentNode",
";",
"$",
"i",
"++",
";",
"}",
"}",
"}"
] |
Trigger a type of event on every matched element.
@param DOMNode|phpQueryObject|string $document
@param unknown_type $type
@param unknown_type $data
@TODO exclusive events (with !)
@TODO global events (test)
@TODO support more than event in $type (space-separated)
|
[
"Trigger",
"a",
"type",
"of",
"event",
"on",
"every",
"matched",
"element",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/phpQueryEvents.php#L22-L98
|
234,298
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasWhere.php
|
HasWhere.where
|
public function where($conditions)
{
if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
$this->_parts['where'][] = $conditions;
}
return $this;
}
|
php
|
public function where($conditions)
{
if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
$this->_parts['where'][] = $conditions;
}
return $this;
}
|
[
"public",
"function",
"where",
"(",
"$",
"conditions",
")",
"{",
"if",
"(",
"$",
"conditions",
"=",
"is_array",
"(",
"$",
"conditions",
")",
"&&",
"func_num_args",
"(",
")",
"===",
"1",
"?",
"$",
"conditions",
":",
"func_get_args",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"'where'",
"]",
"[",
"]",
"=",
"$",
"conditions",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds some where conditions to the query.
@param string|array $conditions The conditions for this query.
@return object Returns `$this`.
|
[
"Adds",
"some",
"where",
"conditions",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasWhere.php#L12-L18
|
234,299
|
maniaplanet/dedicated-server-api
|
libraries/Maniaplanet/DedicatedServer/Connection.php
|
Connection.authenticate
|
function authenticate($user, $password)
{
if (!is_string($user) || !isset(self::$levels[$user])) {
throw new InvalidArgumentException('user = ' . print_r($user, true));
}
if (self::$levels[$this->user] >= self::$levels[$user]) {
return true;
}
if (!is_string($password)) {
throw new InvalidArgumentException('password = ' . print_r($password, true));
}
$res = $this->execute(ucfirst(__FUNCTION__), array($user, $password));
if ($res) {
$this->user = $user;
}
return $res;
}
|
php
|
function authenticate($user, $password)
{
if (!is_string($user) || !isset(self::$levels[$user])) {
throw new InvalidArgumentException('user = ' . print_r($user, true));
}
if (self::$levels[$this->user] >= self::$levels[$user]) {
return true;
}
if (!is_string($password)) {
throw new InvalidArgumentException('password = ' . print_r($password, true));
}
$res = $this->execute(ucfirst(__FUNCTION__), array($user, $password));
if ($res) {
$this->user = $user;
}
return $res;
}
|
[
"function",
"authenticate",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"user",
")",
"||",
"!",
"isset",
"(",
"self",
"::",
"$",
"levels",
"[",
"$",
"user",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'user = '",
".",
"print_r",
"(",
"$",
"user",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"levels",
"[",
"$",
"this",
"->",
"user",
"]",
">=",
"self",
"::",
"$",
"levels",
"[",
"$",
"user",
"]",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"password",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'password = '",
".",
"print_r",
"(",
"$",
"password",
",",
"true",
")",
")",
";",
"}",
"$",
"res",
"=",
"$",
"this",
"->",
"execute",
"(",
"ucfirst",
"(",
"__FUNCTION__",
")",
",",
"array",
"(",
"$",
"user",
",",
"$",
"password",
")",
")",
";",
"if",
"(",
"$",
"res",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Allow user authentication by specifying a login and a password, to gain access to the set of functionalities corresponding to this authorization level.
@param string $user
@param string $password
@return bool
@throws InvalidArgumentException
|
[
"Allow",
"user",
"authentication",
"by",
"specifying",
"a",
"login",
"and",
"a",
"password",
"to",
"gain",
"access",
"to",
"the",
"set",
"of",
"functionalities",
"corresponding",
"to",
"this",
"authorization",
"level",
"."
] |
c42664b21739fd6335cf2ecfe1907a0eca07c1da
|
https://github.com/maniaplanet/dedicated-server-api/blob/c42664b21739fd6335cf2ecfe1907a0eca07c1da/libraries/Maniaplanet/DedicatedServer/Connection.php#L75-L93
|
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.