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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
221,100
|
christiaan/InlineStyle
|
InlineStyle/InlineStyle.php
|
InlineStyle.getHTML
|
public function getHTML()
{
$clone = clone $this;
foreach ($clone->_getNodesForCssSelector('[inlinestyle-original-style]') as $node) {
$current = $node->hasAttribute("style") ?
$this->_styleToArray($node->getAttribute("style")) :
array();
$original = $node->hasAttribute("inlinestyle-original-style") ?
$this->_styleToArray($node->getAttribute("inlinestyle-original-style")) :
array();
$current = $clone->_mergeStyles($current, $original);
$node->setAttribute("style", $this->_arrayToStyle($current));
$node->removeAttribute('inlinestyle-original-style');
}
return $clone->_dom->saveHTML();
}
|
php
|
public function getHTML()
{
$clone = clone $this;
foreach ($clone->_getNodesForCssSelector('[inlinestyle-original-style]') as $node) {
$current = $node->hasAttribute("style") ?
$this->_styleToArray($node->getAttribute("style")) :
array();
$original = $node->hasAttribute("inlinestyle-original-style") ?
$this->_styleToArray($node->getAttribute("inlinestyle-original-style")) :
array();
$current = $clone->_mergeStyles($current, $original);
$node->setAttribute("style", $this->_arrayToStyle($current));
$node->removeAttribute('inlinestyle-original-style');
}
return $clone->_dom->saveHTML();
}
|
[
"public",
"function",
"getHTML",
"(",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"clone",
"->",
"_getNodesForCssSelector",
"(",
"'[inlinestyle-original-style]'",
")",
"as",
"$",
"node",
")",
"{",
"$",
"current",
"=",
"$",
"node",
"->",
"hasAttribute",
"(",
"\"style\"",
")",
"?",
"$",
"this",
"->",
"_styleToArray",
"(",
"$",
"node",
"->",
"getAttribute",
"(",
"\"style\"",
")",
")",
":",
"array",
"(",
")",
";",
"$",
"original",
"=",
"$",
"node",
"->",
"hasAttribute",
"(",
"\"inlinestyle-original-style\"",
")",
"?",
"$",
"this",
"->",
"_styleToArray",
"(",
"$",
"node",
"->",
"getAttribute",
"(",
"\"inlinestyle-original-style\"",
")",
")",
":",
"array",
"(",
")",
";",
"$",
"current",
"=",
"$",
"clone",
"->",
"_mergeStyles",
"(",
"$",
"current",
",",
"$",
"original",
")",
";",
"$",
"node",
"->",
"setAttribute",
"(",
"\"style\"",
",",
"$",
"this",
"->",
"_arrayToStyle",
"(",
"$",
"current",
")",
")",
";",
"$",
"node",
"->",
"removeAttribute",
"(",
"'inlinestyle-original-style'",
")",
";",
"}",
"return",
"$",
"clone",
"->",
"_dom",
"->",
"saveHTML",
"(",
")",
";",
"}"
] |
Returns the DOMDocument as html
@return string the HTML
|
[
"Returns",
"the",
"DOMDocument",
"as",
"html"
] |
9c408760465f4e3ef2b5fb08cb6995e3233afa98
|
https://github.com/christiaan/InlineStyle/blob/9c408760465f4e3ef2b5fb08cb6995e3233afa98/InlineStyle/InlineStyle.php#L178-L196
|
221,101
|
christiaan/InlineStyle
|
InlineStyle/InlineStyle.php
|
InlineStyle.extractStylesheets
|
public function extractStylesheets($node = null, $base = '', $devices = array('all', 'screen', 'handheld'), $remove = true)
{
if(null === $node) {
$node = $this->_dom;
}
$stylesheets = array();
if($node->hasChildNodes()) {
$removeQueue = array();
/** @var $child \DOMElement */
foreach($node->childNodes as $child) {
$nodeName = strtolower($child->nodeName);
if($nodeName === "style" && $this->isForAllowedMediaDevice($child->getAttribute('media'), $devices)) {
$stylesheets[] = $child->nodeValue;
$removeQueue[] = $child;
} else if($nodeName === "link" && strtolower($child->getAttribute('rel')) === 'stylesheet' && $this->isForAllowedMediaDevice($child->getAttribute('media'), $devices)) {
if($child->hasAttribute("href")) {
$href = $child->getAttribute("href");
if($base && false === strpos($href, "://")) {
$href = "{$base}/{$href}";
}
$ext = @file_get_contents($href);
if($ext) {
$removeQueue[] = $child;
$stylesheets[] = $ext;
}
}
} else {
$stylesheets = array_merge($stylesheets,
$this->extractStylesheets($child, $base, $devices, $remove));
}
}
if ($remove) {
foreach ($removeQueue as $child) {
$child->parentNode->removeChild($child);
}
}
}
return $stylesheets;
}
|
php
|
public function extractStylesheets($node = null, $base = '', $devices = array('all', 'screen', 'handheld'), $remove = true)
{
if(null === $node) {
$node = $this->_dom;
}
$stylesheets = array();
if($node->hasChildNodes()) {
$removeQueue = array();
/** @var $child \DOMElement */
foreach($node->childNodes as $child) {
$nodeName = strtolower($child->nodeName);
if($nodeName === "style" && $this->isForAllowedMediaDevice($child->getAttribute('media'), $devices)) {
$stylesheets[] = $child->nodeValue;
$removeQueue[] = $child;
} else if($nodeName === "link" && strtolower($child->getAttribute('rel')) === 'stylesheet' && $this->isForAllowedMediaDevice($child->getAttribute('media'), $devices)) {
if($child->hasAttribute("href")) {
$href = $child->getAttribute("href");
if($base && false === strpos($href, "://")) {
$href = "{$base}/{$href}";
}
$ext = @file_get_contents($href);
if($ext) {
$removeQueue[] = $child;
$stylesheets[] = $ext;
}
}
} else {
$stylesheets = array_merge($stylesheets,
$this->extractStylesheets($child, $base, $devices, $remove));
}
}
if ($remove) {
foreach ($removeQueue as $child) {
$child->parentNode->removeChild($child);
}
}
}
return $stylesheets;
}
|
[
"public",
"function",
"extractStylesheets",
"(",
"$",
"node",
"=",
"null",
",",
"$",
"base",
"=",
"''",
",",
"$",
"devices",
"=",
"array",
"(",
"'all'",
",",
"'screen'",
",",
"'handheld'",
")",
",",
"$",
"remove",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"_dom",
";",
"}",
"$",
"stylesheets",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"node",
"->",
"hasChildNodes",
"(",
")",
")",
"{",
"$",
"removeQueue",
"=",
"array",
"(",
")",
";",
"/** @var $child \\DOMElement */",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"child",
")",
"{",
"$",
"nodeName",
"=",
"strtolower",
"(",
"$",
"child",
"->",
"nodeName",
")",
";",
"if",
"(",
"$",
"nodeName",
"===",
"\"style\"",
"&&",
"$",
"this",
"->",
"isForAllowedMediaDevice",
"(",
"$",
"child",
"->",
"getAttribute",
"(",
"'media'",
")",
",",
"$",
"devices",
")",
")",
"{",
"$",
"stylesheets",
"[",
"]",
"=",
"$",
"child",
"->",
"nodeValue",
";",
"$",
"removeQueue",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"else",
"if",
"(",
"$",
"nodeName",
"===",
"\"link\"",
"&&",
"strtolower",
"(",
"$",
"child",
"->",
"getAttribute",
"(",
"'rel'",
")",
")",
"===",
"'stylesheet'",
"&&",
"$",
"this",
"->",
"isForAllowedMediaDevice",
"(",
"$",
"child",
"->",
"getAttribute",
"(",
"'media'",
")",
",",
"$",
"devices",
")",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"hasAttribute",
"(",
"\"href\"",
")",
")",
"{",
"$",
"href",
"=",
"$",
"child",
"->",
"getAttribute",
"(",
"\"href\"",
")",
";",
"if",
"(",
"$",
"base",
"&&",
"false",
"===",
"strpos",
"(",
"$",
"href",
",",
"\"://\"",
")",
")",
"{",
"$",
"href",
"=",
"\"{$base}/{$href}\"",
";",
"}",
"$",
"ext",
"=",
"@",
"file_get_contents",
"(",
"$",
"href",
")",
";",
"if",
"(",
"$",
"ext",
")",
"{",
"$",
"removeQueue",
"[",
"]",
"=",
"$",
"child",
";",
"$",
"stylesheets",
"[",
"]",
"=",
"$",
"ext",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"stylesheets",
"=",
"array_merge",
"(",
"$",
"stylesheets",
",",
"$",
"this",
"->",
"extractStylesheets",
"(",
"$",
"child",
",",
"$",
"base",
",",
"$",
"devices",
",",
"$",
"remove",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"remove",
")",
"{",
"foreach",
"(",
"$",
"removeQueue",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"parentNode",
"->",
"removeChild",
"(",
"$",
"child",
")",
";",
"}",
"}",
"}",
"return",
"$",
"stylesheets",
";",
"}"
] |
Recursively extracts the stylesheet nodes from the DOMNode
This cannot be done with XPath or a CSS selector because the order in
which the elements are found matters
@param \DOMNode $node leave empty to extract from the whole document
@param string $base The base URI for relative stylesheets
@param array $devices Considered devices
@param boolean $remove Should it remove the original stylesheets
@return array the extracted stylesheets
|
[
"Recursively",
"extracts",
"the",
"stylesheet",
"nodes",
"from",
"the",
"DOMNode"
] |
9c408760465f4e3ef2b5fb08cb6995e3233afa98
|
https://github.com/christiaan/InlineStyle/blob/9c408760465f4e3ef2b5fb08cb6995e3233afa98/InlineStyle/InlineStyle.php#L210-L254
|
221,102
|
christiaan/InlineStyle
|
InlineStyle/InlineStyle.php
|
InlineStyle.extractStylesheetsWithXpath
|
public function extractStylesheetsWithXpath($xpathQuery)
{
$stylesheets = array();
$nodes = $this->_getDomXpath()->query($xpathQuery);
foreach ($nodes as $node)
{
$stylesheets[] = $node->nodeValue;
$node->parentNode->removeChild($node);
}
return $stylesheets;
}
|
php
|
public function extractStylesheetsWithXpath($xpathQuery)
{
$stylesheets = array();
$nodes = $this->_getDomXpath()->query($xpathQuery);
foreach ($nodes as $node)
{
$stylesheets[] = $node->nodeValue;
$node->parentNode->removeChild($node);
}
return $stylesheets;
}
|
[
"public",
"function",
"extractStylesheetsWithXpath",
"(",
"$",
"xpathQuery",
")",
"{",
"$",
"stylesheets",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"_getDomXpath",
"(",
")",
"->",
"query",
"(",
"$",
"xpathQuery",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"stylesheets",
"[",
"]",
"=",
"$",
"node",
"->",
"nodeValue",
";",
"$",
"node",
"->",
"parentNode",
"->",
"removeChild",
"(",
"$",
"node",
")",
";",
"}",
"return",
"$",
"stylesheets",
";",
"}"
] |
Extracts the stylesheet nodes nodes specified by the xpath
@param string $xpathQuery xpath query to the desired stylesheet
@return array the extracted stylesheets
|
[
"Extracts",
"the",
"stylesheet",
"nodes",
"nodes",
"specified",
"by",
"the",
"xpath"
] |
9c408760465f4e3ef2b5fb08cb6995e3233afa98
|
https://github.com/christiaan/InlineStyle/blob/9c408760465f4e3ef2b5fb08cb6995e3233afa98/InlineStyle/InlineStyle.php#L262-L274
|
221,103
|
christiaan/InlineStyle
|
InlineStyle/InlineStyle.php
|
InlineStyle.parseStylesheet
|
public function parseStylesheet($stylesheet)
{
$parsed = array();
$stylesheet = $this->_stripStylesheet($stylesheet);
$stylesheet = trim(trim($stylesheet), "}");
foreach(explode("}", $stylesheet) as $rule) {
//Don't parse empty rules
if(!trim($rule))continue;
list($selector, $style) = explode("{", $rule, 2);
foreach (explode(',', $selector) as $sel) {
$parsed[] = array(trim($sel), trim(trim($style), ";"));
}
}
return $parsed;
}
|
php
|
public function parseStylesheet($stylesheet)
{
$parsed = array();
$stylesheet = $this->_stripStylesheet($stylesheet);
$stylesheet = trim(trim($stylesheet), "}");
foreach(explode("}", $stylesheet) as $rule) {
//Don't parse empty rules
if(!trim($rule))continue;
list($selector, $style) = explode("{", $rule, 2);
foreach (explode(',', $selector) as $sel) {
$parsed[] = array(trim($sel), trim(trim($style), ";"));
}
}
return $parsed;
}
|
[
"public",
"function",
"parseStylesheet",
"(",
"$",
"stylesheet",
")",
"{",
"$",
"parsed",
"=",
"array",
"(",
")",
";",
"$",
"stylesheet",
"=",
"$",
"this",
"->",
"_stripStylesheet",
"(",
"$",
"stylesheet",
")",
";",
"$",
"stylesheet",
"=",
"trim",
"(",
"trim",
"(",
"$",
"stylesheet",
")",
",",
"\"}\"",
")",
";",
"foreach",
"(",
"explode",
"(",
"\"}\"",
",",
"$",
"stylesheet",
")",
"as",
"$",
"rule",
")",
"{",
"//Don't parse empty rules",
"if",
"(",
"!",
"trim",
"(",
"$",
"rule",
")",
")",
"continue",
";",
"list",
"(",
"$",
"selector",
",",
"$",
"style",
")",
"=",
"explode",
"(",
"\"{\"",
",",
"$",
"rule",
",",
"2",
")",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"selector",
")",
"as",
"$",
"sel",
")",
"{",
"$",
"parsed",
"[",
"]",
"=",
"array",
"(",
"trim",
"(",
"$",
"sel",
")",
",",
"trim",
"(",
"trim",
"(",
"$",
"style",
")",
",",
"\";\"",
")",
")",
";",
"}",
"}",
"return",
"$",
"parsed",
";",
"}"
] |
Parses a stylesheet to selectors and properties
@param string $stylesheet
@return array
|
[
"Parses",
"a",
"stylesheet",
"to",
"selectors",
"and",
"properties"
] |
9c408760465f4e3ef2b5fb08cb6995e3233afa98
|
https://github.com/christiaan/InlineStyle/blob/9c408760465f4e3ef2b5fb08cb6995e3233afa98/InlineStyle/InlineStyle.php#L281-L296
|
221,104
|
christiaan/InlineStyle
|
InlineStyle/InlineStyle.php
|
InlineStyle._mergeStyles
|
private function _mergeStyles(array $styleA, array $styleB)
{
foreach($styleB as $prop => $val) {
if(!isset($styleA[$prop])
|| substr(str_replace(" ", "", strtolower($styleA[$prop])), -10) !== "!important")
{
$styleA[$prop] = $val;
}
}
return $styleA;
}
|
php
|
private function _mergeStyles(array $styleA, array $styleB)
{
foreach($styleB as $prop => $val) {
if(!isset($styleA[$prop])
|| substr(str_replace(" ", "", strtolower($styleA[$prop])), -10) !== "!important")
{
$styleA[$prop] = $val;
}
}
return $styleA;
}
|
[
"private",
"function",
"_mergeStyles",
"(",
"array",
"$",
"styleA",
",",
"array",
"$",
"styleB",
")",
"{",
"foreach",
"(",
"$",
"styleB",
"as",
"$",
"prop",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"styleA",
"[",
"$",
"prop",
"]",
")",
"||",
"substr",
"(",
"str_replace",
"(",
"\" \"",
",",
"\"\"",
",",
"strtolower",
"(",
"$",
"styleA",
"[",
"$",
"prop",
"]",
")",
")",
",",
"-",
"10",
")",
"!==",
"\"!important\"",
")",
"{",
"$",
"styleA",
"[",
"$",
"prop",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"styleA",
";",
"}"
] |
Merges two sets of style properties taking !important into account
@param array $styleA
@param array $styleB
@return array
|
[
"Merges",
"two",
"sets",
"of",
"style",
"properties",
"taking",
"!important",
"into",
"account"
] |
9c408760465f4e3ef2b5fb08cb6995e3233afa98
|
https://github.com/christiaan/InlineStyle/blob/9c408760465f4e3ef2b5fb08cb6995e3233afa98/InlineStyle/InlineStyle.php#L366-L377
|
221,105
|
particle-php/Filter
|
src/FilterRule/NumberFormat.php
|
NumberFormat.filter
|
public function filter($value)
{
if (empty($value)) {
return $value;
}
return number_format(floatval($value), $this->decimals, $this->decimalPoint, $this->thousandSeparator);
}
|
php
|
public function filter($value)
{
if (empty($value)) {
return $value;
}
return number_format(floatval($value), $this->decimals, $this->decimalPoint, $this->thousandSeparator);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"number_format",
"(",
"floatval",
"(",
"$",
"value",
")",
",",
"$",
"this",
"->",
"decimals",
",",
"$",
"this",
"->",
"decimalPoint",
",",
"$",
"this",
"->",
"thousandSeparator",
")",
";",
"}"
] |
Format the numbers
@param mixed $value
@return string
|
[
"Format",
"the",
"numbers"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/NumberFormat.php#L55-L62
|
221,106
|
Mastercard/sdk-core-php
|
MasterCard/Core/Model/SmartMap.php
|
SmartMap.containsKey
|
public function containsKey($key)
{
if (strpos($key, ".") !== false) {
//we have a dot, we need to split the ket by the dot and check
//individual string if they are part of the nestes array
$keys = explode('.', $key);
$keysCount = count($keys);
$tmpArray = $this->properties;
foreach ($keys as $index=>$subKey) {
if (empty($tmpArray) || empty($subKey))
{
return false;
}
else if ($index+1 < $keysCount)
{
//arizzini: if the current $index is not the last $subKey
//we want to check is the $tmpArray is an array
$tmpArray = $this->getArrayObject($tmpArray, $subKey);
}
else {
// echo "checking if subkey=$subKey exists";
// print_r($tmpArray);
//
return $this->getArrayObject($tmpArray, $subKey) !== null;
//return array_key_exists($subKey, $tmpArray);
}
}
} else {
return $this->getArrayObject($this->properties, $key) !== null;
}
}
|
php
|
public function containsKey($key)
{
if (strpos($key, ".") !== false) {
//we have a dot, we need to split the ket by the dot and check
//individual string if they are part of the nestes array
$keys = explode('.', $key);
$keysCount = count($keys);
$tmpArray = $this->properties;
foreach ($keys as $index=>$subKey) {
if (empty($tmpArray) || empty($subKey))
{
return false;
}
else if ($index+1 < $keysCount)
{
//arizzini: if the current $index is not the last $subKey
//we want to check is the $tmpArray is an array
$tmpArray = $this->getArrayObject($tmpArray, $subKey);
}
else {
// echo "checking if subkey=$subKey exists";
// print_r($tmpArray);
//
return $this->getArrayObject($tmpArray, $subKey) !== null;
//return array_key_exists($subKey, $tmpArray);
}
}
} else {
return $this->getArrayObject($this->properties, $key) !== null;
}
}
|
[
"public",
"function",
"containsKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"\".\"",
")",
"!==",
"false",
")",
"{",
"//we have a dot, we need to split the ket by the dot and check",
"//individual string if they are part of the nestes array",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"keysCount",
"=",
"count",
"(",
"$",
"keys",
")",
";",
"$",
"tmpArray",
"=",
"$",
"this",
"->",
"properties",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"index",
"=>",
"$",
"subKey",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tmpArray",
")",
"||",
"empty",
"(",
"$",
"subKey",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"$",
"index",
"+",
"1",
"<",
"$",
"keysCount",
")",
"{",
"//arizzini: if the current $index is not the last $subKey",
"//we want to check is the $tmpArray is an array",
"$",
"tmpArray",
"=",
"$",
"this",
"->",
"getArrayObject",
"(",
"$",
"tmpArray",
",",
"$",
"subKey",
")",
";",
"}",
"else",
"{",
"// echo \"checking if subkey=$subKey exists\";",
"// print_r($tmpArray);",
"//",
"return",
"$",
"this",
"->",
"getArrayObject",
"(",
"$",
"tmpArray",
",",
"$",
"subKey",
")",
"!==",
"null",
";",
"//return array_key_exists($subKey, $tmpArray);",
"}",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getArrayObject",
"(",
"$",
"this",
"->",
"properties",
",",
"$",
"key",
")",
"!==",
"null",
";",
"}",
"}"
] |
This check is the map contains a key
@param type $key
@return boolean true or false
|
[
"This",
"check",
"is",
"the",
"map",
"contains",
"a",
"key"
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/Model/SmartMap.php#L117-L154
|
221,107
|
Mastercard/sdk-core-php
|
MasterCard/Core/Model/SmartMap.php
|
SmartMap.setAll
|
public function setAll($map) {
if ($map instanceof SmartMap) {
$this->properties = array_merge($this->properties, $map->getBaseMapAsArray());
} else {
if ($this->isAssoc($map))
{
//echo "isAssoc==TRUE\r\n";
foreach ($map as $key => $value) {
$this->set($key, $value);
}
} else if (is_array($map)){
//echo "isAssoc==FALSE\r\n";
$list = array();
foreach ($map as $object) {
$tmpBaseMap = new SmartMap();
$tmpBaseMap->setAll($object);
array_push($list, $tmpBaseMap->getBaseMapAsArray());
}
$this->set("list", $list);
}
}
}
|
php
|
public function setAll($map) {
if ($map instanceof SmartMap) {
$this->properties = array_merge($this->properties, $map->getBaseMapAsArray());
} else {
if ($this->isAssoc($map))
{
//echo "isAssoc==TRUE\r\n";
foreach ($map as $key => $value) {
$this->set($key, $value);
}
} else if (is_array($map)){
//echo "isAssoc==FALSE\r\n";
$list = array();
foreach ($map as $object) {
$tmpBaseMap = new SmartMap();
$tmpBaseMap->setAll($object);
array_push($list, $tmpBaseMap->getBaseMapAsArray());
}
$this->set("list", $list);
}
}
}
|
[
"public",
"function",
"setAll",
"(",
"$",
"map",
")",
"{",
"if",
"(",
"$",
"map",
"instanceof",
"SmartMap",
")",
"{",
"$",
"this",
"->",
"properties",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"properties",
",",
"$",
"map",
"->",
"getBaseMapAsArray",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"map",
")",
")",
"{",
"//echo \"isAssoc==TRUE\\r\\n\";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"map",
")",
")",
"{",
"//echo \"isAssoc==FALSE\\r\\n\";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"object",
")",
"{",
"$",
"tmpBaseMap",
"=",
"new",
"SmartMap",
"(",
")",
";",
"$",
"tmpBaseMap",
"->",
"setAll",
"(",
"$",
"object",
")",
";",
"array_push",
"(",
"$",
"list",
",",
"$",
"tmpBaseMap",
"->",
"getBaseMapAsArray",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"\"list\"",
",",
"$",
"list",
")",
";",
"}",
"}",
"}"
] |
Updates the object's properties with the values in the specified map.
@param $map array Map of values to set.
|
[
"Updates",
"the",
"object",
"s",
"properties",
"with",
"the",
"values",
"in",
"the",
"specified",
"map",
"."
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/Model/SmartMap.php#L194-L218
|
221,108
|
particle-php/Filter
|
src/FilterRule/DecodeJSON.php
|
DecodeJSON.filter
|
public function filter($value)
{
if (!is_string($value)) {
return $value;
}
return json_decode($value, $this->assoc, $this->depth, $this->options);
}
|
php
|
public function filter($value)
{
if (!is_string($value)) {
return $value;
}
return json_decode($value, $this->assoc, $this->depth, $this->options);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"json_decode",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"assoc",
",",
"$",
"this",
"->",
"depth",
",",
"$",
"this",
"->",
"options",
")",
";",
"}"
] |
Decodes the value JSON
@param mixed $value
@return mixed
|
[
"Decodes",
"the",
"value",
"JSON"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/DecodeJSON.php#L59-L66
|
221,109
|
chrmorandi/yii2-jasper
|
src/Jasper/Jasper.php
|
Jasper.init
|
public function init()
{
parent::init();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$this->windows = true;
}
if ($this->resource_directory) {
if (!file_exists($this->resource_directory)) {
throw new Exception('Invalid resource directory', 1);
}
}
}
|
php
|
public function init()
{
parent::init();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$this->windows = true;
}
if ($this->resource_directory) {
if (!file_exists($this->resource_directory)) {
throw new Exception('Invalid resource directory', 1);
}
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"strtoupper",
"(",
"substr",
"(",
"PHP_OS",
",",
"0",
",",
"3",
")",
")",
"===",
"'WIN'",
")",
"{",
"$",
"this",
"->",
"windows",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resource_directory",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"resource_directory",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid resource directory'",
",",
"1",
")",
";",
"}",
"}",
"}"
] |
Initializes the Jasper component.
@throws Exception if [[resource_directory]] not exist.
|
[
"Initializes",
"the",
"Jasper",
"component",
"."
] |
4a26c764a8c5dc7c0353c140783470eae426c216
|
https://github.com/chrmorandi/yii2-jasper/blob/4a26c764a8c5dc7c0353c140783470eae426c216/src/Jasper/Jasper.php#L98-L111
|
221,110
|
chrmorandi/yii2-jasper
|
src/Jasper/Jasper.php
|
Jasper.process
|
public function process($input_file, $parameters = [], $format = ['pdf'], $output_file = false)
{
if (is_null($input_file) || empty($input_file)) {
throw new Exception('No input file', 1);
}
if (is_array($format)) {
foreach ($format as $key) {
if (!in_array($key, $this->formats)) {
throw new Exception('Invalid format!', 1);
}
}
} else {
if (!in_array($format, $this->formats)) {
throw new Exception('Invalid format!', 1);
}
}
$command = __DIR__.$this->executable;
$command .= ' process ';
$command .= $input_file;
if ($output_file !== false) {
$command .= ' -o '.$output_file;
}
if (is_array($format)) {
$command .= ' -f '.implode(' ', $format);
} else {
$command .= ' -f '.$format;
}
if ($this->resource_directory) {
$command .= ' -r '.$this->resource_directory;
}
if (!empty($this->locale) && $this->locale != null) {
$parameters = ArrayHelper::merge(['REPORT_LOCALE' => $this->locale], $parameters);
}
if (count($parameters) > 0) {
$command .= ' -P';
foreach ($parameters as $key => $value) {
$command .= ' '.$key.'='.$value;
}
}
if (!empty($this->db)) {
$command .= $this->databaseParams();
}
$this->the_command = escapeshellcmd($command);
return $this;
}
|
php
|
public function process($input_file, $parameters = [], $format = ['pdf'], $output_file = false)
{
if (is_null($input_file) || empty($input_file)) {
throw new Exception('No input file', 1);
}
if (is_array($format)) {
foreach ($format as $key) {
if (!in_array($key, $this->formats)) {
throw new Exception('Invalid format!', 1);
}
}
} else {
if (!in_array($format, $this->formats)) {
throw new Exception('Invalid format!', 1);
}
}
$command = __DIR__.$this->executable;
$command .= ' process ';
$command .= $input_file;
if ($output_file !== false) {
$command .= ' -o '.$output_file;
}
if (is_array($format)) {
$command .= ' -f '.implode(' ', $format);
} else {
$command .= ' -f '.$format;
}
if ($this->resource_directory) {
$command .= ' -r '.$this->resource_directory;
}
if (!empty($this->locale) && $this->locale != null) {
$parameters = ArrayHelper::merge(['REPORT_LOCALE' => $this->locale], $parameters);
}
if (count($parameters) > 0) {
$command .= ' -P';
foreach ($parameters as $key => $value) {
$command .= ' '.$key.'='.$value;
}
}
if (!empty($this->db)) {
$command .= $this->databaseParams();
}
$this->the_command = escapeshellcmd($command);
return $this;
}
|
[
"public",
"function",
"process",
"(",
"$",
"input_file",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"format",
"=",
"[",
"'pdf'",
"]",
",",
"$",
"output_file",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"input_file",
")",
"||",
"empty",
"(",
"$",
"input_file",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No input file'",
",",
"1",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"format",
")",
")",
"{",
"foreach",
"(",
"$",
"format",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"formats",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid format!'",
",",
"1",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"format",
",",
"$",
"this",
"->",
"formats",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid format!'",
",",
"1",
")",
";",
"}",
"}",
"$",
"command",
"=",
"__DIR__",
".",
"$",
"this",
"->",
"executable",
";",
"$",
"command",
".=",
"' process '",
";",
"$",
"command",
".=",
"$",
"input_file",
";",
"if",
"(",
"$",
"output_file",
"!==",
"false",
")",
"{",
"$",
"command",
".=",
"' -o '",
".",
"$",
"output_file",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"format",
")",
")",
"{",
"$",
"command",
".=",
"' -f '",
".",
"implode",
"(",
"' '",
",",
"$",
"format",
")",
";",
"}",
"else",
"{",
"$",
"command",
".=",
"' -f '",
".",
"$",
"format",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resource_directory",
")",
"{",
"$",
"command",
".=",
"' -r '",
".",
"$",
"this",
"->",
"resource_directory",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"locale",
")",
"&&",
"$",
"this",
"->",
"locale",
"!=",
"null",
")",
"{",
"$",
"parameters",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"[",
"'REPORT_LOCALE'",
"=>",
"$",
"this",
"->",
"locale",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
">",
"0",
")",
"{",
"$",
"command",
".=",
"' -P'",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"command",
".=",
"' '",
".",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"db",
")",
")",
"{",
"$",
"command",
".=",
"$",
"this",
"->",
"databaseParams",
"(",
")",
";",
"}",
"$",
"this",
"->",
"the_command",
"=",
"escapeshellcmd",
"(",
"$",
"command",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Process report . Accepts files in the format ".jrxml" or ".jasper".
```php
$jasper->process(
__DIR__ . '/vendor/chrmorandi/yii2-jasper/examples/hello_world.jasper',
['php_version' => 'xxx']
['pdf', 'ods'],
)->execute();
```
@param string $input_file
@param array $parameters
@param array $format available formats : pdf, rtf, xls, xlsx, docx, odt, ods, pptx, csv, html, xhtml, xml, jrprint.
jrprint.
@param string $output_file if false the input_file directory is used. Default is false
@return Jasper
|
[
"Process",
"report",
".",
"Accepts",
"files",
"in",
"the",
"format",
".",
"jrxml",
"or",
".",
"jasper",
"."
] |
4a26c764a8c5dc7c0353c140783470eae426c216
|
https://github.com/chrmorandi/yii2-jasper/blob/4a26c764a8c5dc7c0353c140783470eae426c216/src/Jasper/Jasper.php#L158-L212
|
221,111
|
chrmorandi/yii2-jasper
|
src/Jasper/Jasper.php
|
Jasper.execute
|
public function execute()
{
$this->unixParams();
$output = [];
$return_var = 0;
exec($this->the_command, $output, $return_var);
if ($return_var !== 0) {
throw new Exception(
'Your report has an error and couldn\'t be processed! Try to output the command: '.
escapeshellcmd($this->the_command),
1
);
}
return $output;
}
|
php
|
public function execute()
{
$this->unixParams();
$output = [];
$return_var = 0;
exec($this->the_command, $output, $return_var);
if ($return_var !== 0) {
throw new Exception(
'Your report has an error and couldn\'t be processed! Try to output the command: '.
escapeshellcmd($this->the_command),
1
);
}
return $output;
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"unixParams",
"(",
")",
";",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"return_var",
"=",
"0",
";",
"exec",
"(",
"$",
"this",
"->",
"the_command",
",",
"$",
"output",
",",
"$",
"return_var",
")",
";",
"if",
"(",
"$",
"return_var",
"!==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Your report has an error and couldn\\'t be processed! Try to output the command: '",
".",
"escapeshellcmd",
"(",
"$",
"this",
"->",
"the_command",
")",
",",
"1",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Make report.
@return array
@throws Exception
|
[
"Make",
"report",
"."
] |
4a26c764a8c5dc7c0353c140783470eae426c216
|
https://github.com/chrmorandi/yii2-jasper/blob/4a26c764a8c5dc7c0353c140783470eae426c216/src/Jasper/Jasper.php#L252-L269
|
221,112
|
chrmorandi/yii2-jasper
|
src/Jasper/Jasper.php
|
Jasper.unixParams
|
protected function unixParams()
{
if ($this->windows) {
return;
}
$this->the_command .= $this->redirect_output ? ' > /dev/null 2>&1' : '';
$this->the_command .= $this->background ? ' &' : '';
$this->the_command = $this->run_as_user
? 'su -u '.$this->run_as_user.' -c "'.$this->the_command.'"'
: $this->the_command;
}
|
php
|
protected function unixParams()
{
if ($this->windows) {
return;
}
$this->the_command .= $this->redirect_output ? ' > /dev/null 2>&1' : '';
$this->the_command .= $this->background ? ' &' : '';
$this->the_command = $this->run_as_user
? 'su -u '.$this->run_as_user.' -c "'.$this->the_command.'"'
: $this->the_command;
}
|
[
"protected",
"function",
"unixParams",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"windows",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"the_command",
".=",
"$",
"this",
"->",
"redirect_output",
"?",
"' > /dev/null 2>&1'",
":",
"''",
";",
"$",
"this",
"->",
"the_command",
".=",
"$",
"this",
"->",
"background",
"?",
"' &'",
":",
"''",
";",
"$",
"this",
"->",
"the_command",
"=",
"$",
"this",
"->",
"run_as_user",
"?",
"'su -u '",
".",
"$",
"this",
"->",
"run_as_user",
".",
"' -c \"'",
".",
"$",
"this",
"->",
"the_command",
".",
"'\"'",
":",
"$",
"this",
"->",
"the_command",
";",
"}"
] |
Set optional Unix parameters
|
[
"Set",
"optional",
"Unix",
"parameters"
] |
4a26c764a8c5dc7c0353c140783470eae426c216
|
https://github.com/chrmorandi/yii2-jasper/blob/4a26c764a8c5dc7c0353c140783470eae426c216/src/Jasper/Jasper.php#L274-L285
|
221,113
|
particle-php/Filter
|
src/FilterRule/UpperFirst.php
|
UpperFirst.filter
|
public function filter($value)
{
if ($this->encodingFormat !== null) {
$firstChar = mb_substr($value, 0, 1, $this->encodingFormat);
$rest = mb_substr($value, 1, null, $this->encodingFormat);
return mb_strtoupper($firstChar, $this->encodingFormat) . $rest;
}
$firstChar = mb_substr($value, 0, 1);
$rest = mb_substr($value, 1);
return mb_strtoupper($firstChar) . $rest;
}
|
php
|
public function filter($value)
{
if ($this->encodingFormat !== null) {
$firstChar = mb_substr($value, 0, 1, $this->encodingFormat);
$rest = mb_substr($value, 1, null, $this->encodingFormat);
return mb_strtoupper($firstChar, $this->encodingFormat) . $rest;
}
$firstChar = mb_substr($value, 0, 1);
$rest = mb_substr($value, 1);
return mb_strtoupper($firstChar) . $rest;
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"encodingFormat",
"!==",
"null",
")",
"{",
"$",
"firstChar",
"=",
"mb_substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
",",
"$",
"this",
"->",
"encodingFormat",
")",
";",
"$",
"rest",
"=",
"mb_substr",
"(",
"$",
"value",
",",
"1",
",",
"null",
",",
"$",
"this",
"->",
"encodingFormat",
")",
";",
"return",
"mb_strtoupper",
"(",
"$",
"firstChar",
",",
"$",
"this",
"->",
"encodingFormat",
")",
".",
"$",
"rest",
";",
"}",
"$",
"firstChar",
"=",
"mb_substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
";",
"$",
"rest",
"=",
"mb_substr",
"(",
"$",
"value",
",",
"1",
")",
";",
"return",
"mb_strtoupper",
"(",
"$",
"firstChar",
")",
".",
"$",
"rest",
";",
"}"
] |
Uppercase the first character of the value
@param mixed $value
@return string
|
[
"Uppercase",
"the",
"first",
"character",
"of",
"the",
"value"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/UpperFirst.php#L26-L38
|
221,114
|
laravel-notification-channels/messagebird
|
src/MessagebirdClient.php
|
MessagebirdClient.send
|
public function send(MessagebirdMessage $message)
{
if (empty($message->originator)) {
$message->setOriginator(config('services.messagebird.originator'));
}
if (empty($message->recipients)) {
$message->setRecipients(config('services.messagebird.recipients'));
}
if (empty($message->datacoding)) {
$message->setDatacoding('auto');
}
try {
$this->client->request('POST', 'https://rest.messagebird.com/messages', [
'body' => $message->toJson(),
'headers' => [
'Authorization' => 'AccessKey '.$this->access_key,
],
]);
} catch (Exception $exception) {
throw CouldNotSendNotification::serviceRespondedWithAnError($exception);
}
}
|
php
|
public function send(MessagebirdMessage $message)
{
if (empty($message->originator)) {
$message->setOriginator(config('services.messagebird.originator'));
}
if (empty($message->recipients)) {
$message->setRecipients(config('services.messagebird.recipients'));
}
if (empty($message->datacoding)) {
$message->setDatacoding('auto');
}
try {
$this->client->request('POST', 'https://rest.messagebird.com/messages', [
'body' => $message->toJson(),
'headers' => [
'Authorization' => 'AccessKey '.$this->access_key,
],
]);
} catch (Exception $exception) {
throw CouldNotSendNotification::serviceRespondedWithAnError($exception);
}
}
|
[
"public",
"function",
"send",
"(",
"MessagebirdMessage",
"$",
"message",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
"->",
"originator",
")",
")",
"{",
"$",
"message",
"->",
"setOriginator",
"(",
"config",
"(",
"'services.messagebird.originator'",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"message",
"->",
"recipients",
")",
")",
"{",
"$",
"message",
"->",
"setRecipients",
"(",
"config",
"(",
"'services.messagebird.recipients'",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"message",
"->",
"datacoding",
")",
")",
"{",
"$",
"message",
"->",
"setDatacoding",
"(",
"'auto'",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"'https://rest.messagebird.com/messages'",
",",
"[",
"'body'",
"=>",
"$",
"message",
"->",
"toJson",
"(",
")",
",",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"'AccessKey '",
".",
"$",
"this",
"->",
"access_key",
",",
"]",
",",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"exception",
")",
"{",
"throw",
"CouldNotSendNotification",
"::",
"serviceRespondedWithAnError",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Send the Message.
@param MessagebirdMessage $message
@throws CouldNotSendNotification
|
[
"Send",
"the",
"Message",
"."
] |
d6e0385653f0c66911c8a6b597a802846813f0c9
|
https://github.com/laravel-notification-channels/messagebird/blob/d6e0385653f0c66911c8a6b597a802846813f0c9/src/MessagebirdClient.php#L30-L52
|
221,115
|
particle-php/Filter
|
src/FilterRule/Lower.php
|
Lower.filter
|
public function filter($value)
{
if ($this->encodingFormat !== null) {
return mb_strtolower($value, $this->encodingFormat);
}
return mb_strtolower($value);
}
|
php
|
public function filter($value)
{
if ($this->encodingFormat !== null) {
return mb_strtolower($value, $this->encodingFormat);
}
return mb_strtolower($value);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"encodingFormat",
"!==",
"null",
")",
"{",
"return",
"mb_strtolower",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"encodingFormat",
")",
";",
"}",
"return",
"mb_strtolower",
"(",
"$",
"value",
")",
";",
"}"
] |
Lowercase the given value
@param mixed $value
@return string
|
[
"Lowercase",
"the",
"given",
"value"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/Lower.php#L26-L33
|
221,116
|
particle-php/Filter
|
src/FilterRule/Trim.php
|
Trim.filter
|
public function filter($value)
{
if ($value === null) {
return $value;
}
if ($this->characters === null) {
return trim($value);
}
return trim($value, $this->characters);
}
|
php
|
public function filter($value)
{
if ($value === null) {
return $value;
}
if ($this->characters === null) {
return trim($value);
}
return trim($value, $this->characters);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"characters",
"===",
"null",
")",
"{",
"return",
"trim",
"(",
"$",
"value",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"characters",
")",
";",
"}"
] |
Trim the value, if no characters to trim are given, use the PHP default
@param mixed $value
@return string
|
[
"Trim",
"the",
"value",
"if",
"no",
"characters",
"to",
"trim",
"are",
"given",
"use",
"the",
"PHP",
"default"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/Trim.php#L41-L52
|
221,117
|
particle-php/Filter
|
src/FilterRule/Encode.php
|
Encode.filter
|
public function filter($value)
{
if ($this->toEncoding === null) {
return $value;
}
if ($this->fromEncoding === null) {
return mb_convert_encoding($value, $this->toEncoding);
}
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding);
}
|
php
|
public function filter($value)
{
if ($this->toEncoding === null) {
return $value;
}
if ($this->fromEncoding === null) {
return mb_convert_encoding($value, $this->toEncoding);
}
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding);
}
|
[
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"toEncoding",
"===",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fromEncoding",
"===",
"null",
")",
"{",
"return",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"toEncoding",
")",
";",
"}",
"return",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"toEncoding",
",",
"$",
"this",
"->",
"fromEncoding",
")",
";",
"}"
] |
Changes encoding of the value
@param mixed $value
@return string
|
[
"Changes",
"encoding",
"of",
"the",
"value"
] |
49ba23accb1eb0342438e49258a54ed4e3f3335e
|
https://github.com/particle-php/Filter/blob/49ba23accb1eb0342438e49258a54ed4e3f3335e/src/FilterRule/Encode.php#L50-L61
|
221,118
|
Mastercard/sdk-core-php
|
MasterCard/Core/ApiConfig.php
|
ApiConfig.setSandbox
|
public static function setSandbox($sandbox)
{
if ($sandbox == true) {
static::setEnvironment(Environment::SANDBOX);
} else {
static::setEnvironment(Environment::PRODUCTION);
}
}
|
php
|
public static function setSandbox($sandbox)
{
if ($sandbox == true) {
static::setEnvironment(Environment::SANDBOX);
} else {
static::setEnvironment(Environment::PRODUCTION);
}
}
|
[
"public",
"static",
"function",
"setSandbox",
"(",
"$",
"sandbox",
")",
"{",
"if",
"(",
"$",
"sandbox",
"==",
"true",
")",
"{",
"static",
"::",
"setEnvironment",
"(",
"Environment",
"::",
"SANDBOX",
")",
";",
"}",
"else",
"{",
"static",
"::",
"setEnvironment",
"(",
"Environment",
"::",
"PRODUCTION",
")",
";",
"}",
"}"
] |
Sets the sandbox.
@param boolean sandbox
|
[
"Sets",
"the",
"sandbox",
"."
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/ApiConfig.php#L125-L132
|
221,119
|
Mastercard/sdk-core-php
|
MasterCard/Core/ApiConfig.php
|
ApiConfig.setEnvironment
|
public static function setEnvironment($environment) {
if (!empty($environment)) {
foreach (array_values(static::$registeredInstances) as $instance) {
$instance->setEnvironment($environment);
}
static::$ENVIRONMENT = $environment;
}
}
|
php
|
public static function setEnvironment($environment) {
if (!empty($environment)) {
foreach (array_values(static::$registeredInstances) as $instance) {
$instance->setEnvironment($environment);
}
static::$ENVIRONMENT = $environment;
}
}
|
[
"public",
"static",
"function",
"setEnvironment",
"(",
"$",
"environment",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"environment",
")",
")",
"{",
"foreach",
"(",
"array_values",
"(",
"static",
"::",
"$",
"registeredInstances",
")",
"as",
"$",
"instance",
")",
"{",
"$",
"instance",
"->",
"setEnvironment",
"(",
"$",
"environment",
")",
";",
"}",
"static",
"::",
"$",
"ENVIRONMENT",
"=",
"$",
"environment",
";",
"}",
"}"
] |
This method is used to set the SubDomain
@param type $subDomain
|
[
"This",
"method",
"is",
"used",
"to",
"set",
"the",
"SubDomain"
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/ApiConfig.php#L139-L147
|
221,120
|
Mastercard/sdk-core-php
|
MasterCard/Core/ApiConfig.php
|
ApiConfig.registerResourceConfig
|
public static function registerResourceConfig($instance) {
$className = get_class($instance);
if (!array_key_exists($className, static::$registeredInstances)){
static::$registeredInstances['$className'] = $instance;
}
}
|
php
|
public static function registerResourceConfig($instance) {
$className = get_class($instance);
if (!array_key_exists($className, static::$registeredInstances)){
static::$registeredInstances['$className'] = $instance;
}
}
|
[
"public",
"static",
"function",
"registerResourceConfig",
"(",
"$",
"instance",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"instance",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"className",
",",
"static",
"::",
"$",
"registeredInstances",
")",
")",
"{",
"static",
"::",
"$",
"registeredInstances",
"[",
"'$className'",
"]",
"=",
"$",
"instance",
";",
"}",
"}"
] |
This is used to add the SDKCOnfig to the APIConfig
so when the configuration changes the underline SDKConfig
are updated.
@param type $instance
|
[
"This",
"is",
"used",
"to",
"add",
"the",
"SDKCOnfig",
"to",
"the",
"APIConfig",
"so",
"when",
"the",
"configuration",
"changes",
"the",
"underline",
"SDKConfig",
"are",
"updated",
"."
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/ApiConfig.php#L165-L170
|
221,121
|
Mastercard/sdk-core-php
|
MasterCard/Core/Util.php
|
Util.subMap
|
public static function subMap(&$inputMap, $keyList) {
$subMap = array();
foreach ($keyList as $key)
{
//check is the map contain the
if (array_key_exists($key, $inputMap)){
$subMap[$key] = $inputMap[$key];
unset($inputMap[$key]);
}
}
return $subMap;
}
|
php
|
public static function subMap(&$inputMap, $keyList) {
$subMap = array();
foreach ($keyList as $key)
{
//check is the map contain the
if (array_key_exists($key, $inputMap)){
$subMap[$key] = $inputMap[$key];
unset($inputMap[$key]);
}
}
return $subMap;
}
|
[
"public",
"static",
"function",
"subMap",
"(",
"&",
"$",
"inputMap",
",",
"$",
"keyList",
")",
"{",
"$",
"subMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keyList",
"as",
"$",
"key",
")",
"{",
"//check is the map contain the ",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"inputMap",
")",
")",
"{",
"$",
"subMap",
"[",
"$",
"key",
"]",
"=",
"$",
"inputMap",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"inputMap",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"subMap",
";",
"}"
] |
This method is used to generate a sumMap by taking a subset of the map
which contains the key specified in the list
@param type $inputMap
@param type $keyList
@return type
|
[
"This",
"method",
"is",
"used",
"to",
"generate",
"a",
"sumMap",
"by",
"taking",
"a",
"subset",
"of",
"the",
"map",
"which",
"contains",
"the",
"key",
"specified",
"in",
"the",
"list"
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/Util.php#L92-L104
|
221,122
|
Mastercard/sdk-core-php
|
MasterCard/Core/Security/SecurityUtil.php
|
SecurityUtil.getNonce
|
public static function getNonce($length = 16)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
|
php
|
public static function getNonce($length = 16)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
|
[
"public",
"static",
"function",
"getNonce",
"(",
"$",
"length",
"=",
"16",
")",
"{",
"$",
"characters",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"$",
"charactersLength",
"=",
"strlen",
"(",
"$",
"characters",
")",
";",
"$",
"randomString",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"randomString",
".=",
"$",
"characters",
"[",
"rand",
"(",
"0",
",",
"$",
"charactersLength",
"-",
"1",
")",
"]",
";",
"}",
"return",
"$",
"randomString",
";",
"}"
] |
Generate a Nonce string
@param type $length
@return String
|
[
"Generate",
"a",
"Nonce",
"string"
] |
4785426d649771aedd15bd498708e7995c78df8c
|
https://github.com/Mastercard/sdk-core-php/blob/4785426d649771aedd15bd498708e7995c78df8c/MasterCard/Core/Security/SecurityUtil.php#L56-L66
|
221,123
|
helthe/Turbolinks
|
Turbolinks.php
|
Turbolinks.decorateResponse
|
public function decorateResponse(Request $request, Response $response)
{
if ($request->headers->has(self::ORIGIN_REQUEST_HEADER)) {
$request->headers->set('referer', $request->headers->get(self::ORIGIN_REQUEST_HEADER));
}
$this->setTurbolinksLocationHeaderFromSession($request, $response);
if ($response->isRedirect() && $response->headers->has(self::ORIGIN_RESPONSE_HEADER)) {
$this->redirectTo($request, $response);
}
$this->modifyStatusCode($request, $response);
}
|
php
|
public function decorateResponse(Request $request, Response $response)
{
if ($request->headers->has(self::ORIGIN_REQUEST_HEADER)) {
$request->headers->set('referer', $request->headers->get(self::ORIGIN_REQUEST_HEADER));
}
$this->setTurbolinksLocationHeaderFromSession($request, $response);
if ($response->isRedirect() && $response->headers->has(self::ORIGIN_RESPONSE_HEADER)) {
$this->redirectTo($request, $response);
}
$this->modifyStatusCode($request, $response);
}
|
[
"public",
"function",
"decorateResponse",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"self",
"::",
"ORIGIN_REQUEST_HEADER",
")",
")",
"{",
"$",
"request",
"->",
"headers",
"->",
"set",
"(",
"'referer'",
",",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"self",
"::",
"ORIGIN_REQUEST_HEADER",
")",
")",
";",
"}",
"$",
"this",
"->",
"setTurbolinksLocationHeaderFromSession",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isRedirect",
"(",
")",
"&&",
"$",
"response",
"->",
"headers",
"->",
"has",
"(",
"self",
"::",
"ORIGIN_RESPONSE_HEADER",
")",
")",
"{",
"$",
"this",
"->",
"redirectTo",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"$",
"this",
"->",
"modifyStatusCode",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
] |
Modifies the HTTP headers and status code of the Response so that it can be
properly handled by the Turbolinks javascript.
@param Request $request
@param Response $response
|
[
"Modifies",
"the",
"HTTP",
"headers",
"and",
"status",
"code",
"of",
"the",
"Response",
"so",
"that",
"it",
"can",
"be",
"properly",
"handled",
"by",
"the",
"Turbolinks",
"javascript",
"."
] |
015661bd8a32630996e47f801960bb1c0318003c
|
https://github.com/helthe/Turbolinks/blob/015661bd8a32630996e47f801960bb1c0318003c/Turbolinks.php#L73-L86
|
221,124
|
helthe/Turbolinks
|
Turbolinks.php
|
Turbolinks.canHandleRedirect
|
private function canHandleRedirect(Request $request)
{
$session = $request->getSession();
return (is_a($session, '\Symfony\Component\HttpFoundation\Session\SessionInterface') || is_a($session, '\Illuminate\Contracts\Session\Session')) &&
$request->headers->has(self::ORIGIN_REQUEST_HEADER);
}
|
php
|
private function canHandleRedirect(Request $request)
{
$session = $request->getSession();
return (is_a($session, '\Symfony\Component\HttpFoundation\Session\SessionInterface') || is_a($session, '\Illuminate\Contracts\Session\Session')) &&
$request->headers->has(self::ORIGIN_REQUEST_HEADER);
}
|
[
"private",
"function",
"canHandleRedirect",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"session",
"=",
"$",
"request",
"->",
"getSession",
"(",
")",
";",
"return",
"(",
"is_a",
"(",
"$",
"session",
",",
"'\\Symfony\\Component\\HttpFoundation\\Session\\SessionInterface'",
")",
"||",
"is_a",
"(",
"$",
"session",
",",
"'\\Illuminate\\Contracts\\Session\\Session'",
")",
")",
"&&",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"self",
"::",
"ORIGIN_REQUEST_HEADER",
")",
";",
"}"
] |
Checks if the request can handle a Turbolink redirect. You need to have a
session and a XHR request header to handle a redirect.
@param Request $request
@return bool
|
[
"Checks",
"if",
"the",
"request",
"can",
"handle",
"a",
"Turbolink",
"redirect",
".",
"You",
"need",
"to",
"have",
"a",
"session",
"and",
"a",
"XHR",
"request",
"header",
"to",
"handle",
"a",
"redirect",
"."
] |
015661bd8a32630996e47f801960bb1c0318003c
|
https://github.com/helthe/Turbolinks/blob/015661bd8a32630996e47f801960bb1c0318003c/Turbolinks.php#L119-L124
|
221,125
|
helthe/Turbolinks
|
Turbolinks.php
|
Turbolinks.getUrlOrigin
|
private function getUrlOrigin($url)
{
return array(
parse_url($url, PHP_URL_SCHEME),
parse_url($url, PHP_URL_HOST),
parse_url($url, PHP_URL_PORT),
);
}
|
php
|
private function getUrlOrigin($url)
{
return array(
parse_url($url, PHP_URL_SCHEME),
parse_url($url, PHP_URL_HOST),
parse_url($url, PHP_URL_PORT),
);
}
|
[
"private",
"function",
"getUrlOrigin",
"(",
"$",
"url",
")",
"{",
"return",
"array",
"(",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_SCHEME",
")",
",",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
",",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_PORT",
")",
",",
")",
";",
"}"
] |
Parse the given url into an origin array with the scheme, host and port.
@param string $url
@return array
|
[
"Parse",
"the",
"given",
"url",
"into",
"an",
"origin",
"array",
"with",
"the",
"scheme",
"host",
"and",
"port",
"."
] |
015661bd8a32630996e47f801960bb1c0318003c
|
https://github.com/helthe/Turbolinks/blob/015661bd8a32630996e47f801960bb1c0318003c/Turbolinks.php#L133-L140
|
221,126
|
helthe/Turbolinks
|
Turbolinks.php
|
Turbolinks.haveSameOrigin
|
private function haveSameOrigin(Request $request, Response $response)
{
$requestOrigin = $this->getUrlOrigin($request->headers->get(self::ORIGIN_REQUEST_HEADER));
$responseOrigin = $this->getUrlOrigin($response->headers->get(self::ORIGIN_RESPONSE_HEADER));
return $requestOrigin == $responseOrigin;
}
|
php
|
private function haveSameOrigin(Request $request, Response $response)
{
$requestOrigin = $this->getUrlOrigin($request->headers->get(self::ORIGIN_REQUEST_HEADER));
$responseOrigin = $this->getUrlOrigin($response->headers->get(self::ORIGIN_RESPONSE_HEADER));
return $requestOrigin == $responseOrigin;
}
|
[
"private",
"function",
"haveSameOrigin",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"requestOrigin",
"=",
"$",
"this",
"->",
"getUrlOrigin",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"self",
"::",
"ORIGIN_REQUEST_HEADER",
")",
")",
";",
"$",
"responseOrigin",
"=",
"$",
"this",
"->",
"getUrlOrigin",
"(",
"$",
"response",
"->",
"headers",
"->",
"get",
"(",
"self",
"::",
"ORIGIN_RESPONSE_HEADER",
")",
")",
";",
"return",
"$",
"requestOrigin",
"==",
"$",
"responseOrigin",
";",
"}"
] |
Checks if the request and the response have the same origin.
@param Request $request
@param Response $response
@return bool
|
[
"Checks",
"if",
"the",
"request",
"and",
"the",
"response",
"have",
"the",
"same",
"origin",
"."
] |
015661bd8a32630996e47f801960bb1c0318003c
|
https://github.com/helthe/Turbolinks/blob/015661bd8a32630996e47f801960bb1c0318003c/Turbolinks.php#L150-L156
|
221,127
|
helthe/Turbolinks
|
Turbolinks.php
|
Turbolinks.modifyStatusCode
|
private function modifyStatusCode(Request $request, Response $response)
{
if ($request->headers->has(self::ORIGIN_REQUEST_HEADER)
&& $response->headers->has(self::ORIGIN_RESPONSE_HEADER)
&& !$this->haveSameOrigin($request, $response)
) {
$response->setStatusCode(Response::HTTP_FORBIDDEN);
}
}
|
php
|
private function modifyStatusCode(Request $request, Response $response)
{
if ($request->headers->has(self::ORIGIN_REQUEST_HEADER)
&& $response->headers->has(self::ORIGIN_RESPONSE_HEADER)
&& !$this->haveSameOrigin($request, $response)
) {
$response->setStatusCode(Response::HTTP_FORBIDDEN);
}
}
|
[
"private",
"function",
"modifyStatusCode",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"self",
"::",
"ORIGIN_REQUEST_HEADER",
")",
"&&",
"$",
"response",
"->",
"headers",
"->",
"has",
"(",
"self",
"::",
"ORIGIN_RESPONSE_HEADER",
")",
"&&",
"!",
"$",
"this",
"->",
"haveSameOrigin",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
"{",
"$",
"response",
"->",
"setStatusCode",
"(",
"Response",
"::",
"HTTP_FORBIDDEN",
")",
";",
"}",
"}"
] |
Modifies the response status code. Checks for cross domain redirects and
blocks them.
@param Request $request
@param Response $response
|
[
"Modifies",
"the",
"response",
"status",
"code",
".",
"Checks",
"for",
"cross",
"domain",
"redirects",
"and",
"blocks",
"them",
"."
] |
015661bd8a32630996e47f801960bb1c0318003c
|
https://github.com/helthe/Turbolinks/blob/015661bd8a32630996e47f801960bb1c0318003c/Turbolinks.php#L165-L173
|
221,128
|
bryglen/yii2-sendgrid
|
Mailer.php
|
Mailer.createSendGridMailer
|
public function createSendGridMailer($username, $password, $options)
{
if (!$username) {
throw new InvalidConfigException("Username cannot be empty.");
}
if (!$password) {
throw new InvalidConfigException("Password cannot be empty.");
}
$sendgrid = new \SendGrid($username, $password , $options);
return $sendgrid;
}
|
php
|
public function createSendGridMailer($username, $password, $options)
{
if (!$username) {
throw new InvalidConfigException("Username cannot be empty.");
}
if (!$password) {
throw new InvalidConfigException("Password cannot be empty.");
}
$sendgrid = new \SendGrid($username, $password , $options);
return $sendgrid;
}
|
[
"public",
"function",
"createSendGridMailer",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"username",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"Username cannot be empty.\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"password",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"Password cannot be empty.\"",
")",
";",
"}",
"$",
"sendgrid",
"=",
"new",
"\\",
"SendGrid",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"return",
"$",
"sendgrid",
";",
"}"
] |
Create send grid mail instance
@param string $username the username for the sendgrid api
@param string $password the password for the sendgrid api
@return \SendGrid
@throws \yii\base\InvalidConfigException
|
[
"Create",
"send",
"grid",
"mail",
"instance"
] |
2eda790e9b4284be56058042c7e3fc20fae0ec5f
|
https://github.com/bryglen/yii2-sendgrid/blob/2eda790e9b4284be56058042c7e3fc20fae0ec5f/Mailer.php#L100-L111
|
221,129
|
doublesecretagency/craft-inventory
|
src/services/InventoryService.php
|
InventoryService.getFieldLayouts
|
public function getFieldLayouts(&$context)
{
$context['fieldLayouts'] = [];
foreach ($context['fields'] as $field) {
$layouts = [];
foreach ($this->_getRelatedLayoutIds($field) as $row) {
$layouts[] = $this->_getLayoutData($row);
}
$context['fieldLayouts'][] = [
'field' => $field,
'layouts' => $layouts,
];
}
}
|
php
|
public function getFieldLayouts(&$context)
{
$context['fieldLayouts'] = [];
foreach ($context['fields'] as $field) {
$layouts = [];
foreach ($this->_getRelatedLayoutIds($field) as $row) {
$layouts[] = $this->_getLayoutData($row);
}
$context['fieldLayouts'][] = [
'field' => $field,
'layouts' => $layouts,
];
}
}
|
[
"public",
"function",
"getFieldLayouts",
"(",
"&",
"$",
"context",
")",
"{",
"$",
"context",
"[",
"'fieldLayouts'",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"context",
"[",
"'fields'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"layouts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getRelatedLayoutIds",
"(",
"$",
"field",
")",
"as",
"$",
"row",
")",
"{",
"$",
"layouts",
"[",
"]",
"=",
"$",
"this",
"->",
"_getLayoutData",
"(",
"$",
"row",
")",
";",
"}",
"$",
"context",
"[",
"'fieldLayouts'",
"]",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'layouts'",
"=>",
"$",
"layouts",
",",
"]",
";",
"}",
"}"
] |
Collect all layouts based on existing fields.
@param array &$context The current template context.
@return void
|
[
"Collect",
"all",
"layouts",
"based",
"on",
"existing",
"fields",
"."
] |
0dd1b3a62e4bece3832fa127c1c9d178ed49d742
|
https://github.com/doublesecretagency/craft-inventory/blob/0dd1b3a62e4bece3832fa127c1c9d178ed49d742/src/services/InventoryService.php#L33-L49
|
221,130
|
doublesecretagency/craft-inventory
|
src/services/InventoryService.php
|
InventoryService._getRelatedLayoutIds
|
private function _getRelatedLayoutIds($field)
{
return (new Query())
->select(['layoutId','tabId'])
->from(['{{%fieldlayoutfields}}'])
->where('fieldId=:id', [':id' => $field->id])
->orderBy('layoutId ASC')
->all();
}
|
php
|
private function _getRelatedLayoutIds($field)
{
return (new Query())
->select(['layoutId','tabId'])
->from(['{{%fieldlayoutfields}}'])
->where('fieldId=:id', [':id' => $field->id])
->orderBy('layoutId ASC')
->all();
}
|
[
"private",
"function",
"_getRelatedLayoutIds",
"(",
"$",
"field",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'layoutId'",
",",
"'tabId'",
"]",
")",
"->",
"from",
"(",
"[",
"'{{%fieldlayoutfields}}'",
"]",
")",
"->",
"where",
"(",
"'fieldId=:id'",
",",
"[",
"':id'",
"=>",
"$",
"field",
"->",
"id",
"]",
")",
"->",
"orderBy",
"(",
"'layoutId ASC'",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get partial data for all layouts which contain the specified field.
@param craft\base\Field $field Model of specified field.
@return array Partial data for all layouts which contain the specified field.
|
[
"Get",
"partial",
"data",
"for",
"all",
"layouts",
"which",
"contain",
"the",
"specified",
"field",
"."
] |
0dd1b3a62e4bece3832fa127c1c9d178ed49d742
|
https://github.com/doublesecretagency/craft-inventory/blob/0dd1b3a62e4bece3832fa127c1c9d178ed49d742/src/services/InventoryService.php#L58-L66
|
221,131
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.asObject
|
public function asObject(string $className, array $constructorArgs = []): QueryBuilderHandler
{
return $this->setFetchMode(PDO::FETCH_CLASS, $className, $constructorArgs);
}
|
php
|
public function asObject(string $className, array $constructorArgs = []): QueryBuilderHandler
{
return $this->setFetchMode(PDO::FETCH_CLASS, $className, $constructorArgs);
}
|
[
"public",
"function",
"asObject",
"(",
"string",
"$",
"className",
",",
"array",
"$",
"constructorArgs",
"=",
"[",
"]",
")",
":",
"QueryBuilderHandler",
"{",
"return",
"$",
"this",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"className",
",",
"$",
"constructorArgs",
")",
";",
"}"
] |
Fetch query results as object of specified type
@param string $className
@param array $constructorArgs
@return static
|
[
"Fetch",
"query",
"results",
"as",
"object",
"of",
"specified",
"type"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L123-L126
|
221,132
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.aggregate
|
protected function aggregate(string $type, string $field = '*'): float
{
// Verify that field exists
if ($field !== '*' && isset($this->statements['selects']) === true && \in_array($field, $this->statements['selects'], true) === false) {
throw new ColumnNotFoundException(sprintf('Failed to count query - the column %s hasn\'t been selected in the query.', $field));
}
if (isset($this->statements['tables']) === false) {
throw new Exception('No table selected');
}
$count = $this
->table($this->subQuery($this, 'count'))
->select([$this->raw(sprintf('%s(%s) AS `field`', strtoupper($type), $field))])
->first();
return isset($count->field) === true ? (float)$count->field : 0;
}
|
php
|
protected function aggregate(string $type, string $field = '*'): float
{
// Verify that field exists
if ($field !== '*' && isset($this->statements['selects']) === true && \in_array($field, $this->statements['selects'], true) === false) {
throw new ColumnNotFoundException(sprintf('Failed to count query - the column %s hasn\'t been selected in the query.', $field));
}
if (isset($this->statements['tables']) === false) {
throw new Exception('No table selected');
}
$count = $this
->table($this->subQuery($this, 'count'))
->select([$this->raw(sprintf('%s(%s) AS `field`', strtoupper($type), $field))])
->first();
return isset($count->field) === true ? (float)$count->field : 0;
}
|
[
"protected",
"function",
"aggregate",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"field",
"=",
"'*'",
")",
":",
"float",
"{",
"// Verify that field exists",
"if",
"(",
"$",
"field",
"!==",
"'*'",
"&&",
"isset",
"(",
"$",
"this",
"->",
"statements",
"[",
"'selects'",
"]",
")",
"===",
"true",
"&&",
"\\",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"statements",
"[",
"'selects'",
"]",
",",
"true",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"ColumnNotFoundException",
"(",
"sprintf",
"(",
"'Failed to count query - the column %s hasn\\'t been selected in the query.'",
",",
"$",
"field",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"statements",
"[",
"'tables'",
"]",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No table selected'",
")",
";",
"}",
"$",
"count",
"=",
"$",
"this",
"->",
"table",
"(",
"$",
"this",
"->",
"subQuery",
"(",
"$",
"this",
",",
"'count'",
")",
")",
"->",
"select",
"(",
"[",
"$",
"this",
"->",
"raw",
"(",
"sprintf",
"(",
"'%s(%s) AS `field`'",
",",
"strtoupper",
"(",
"$",
"type",
")",
",",
"$",
"field",
")",
")",
"]",
")",
"->",
"first",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"count",
"->",
"field",
")",
"===",
"true",
"?",
"(",
"float",
")",
"$",
"count",
"->",
"field",
":",
"0",
";",
"}"
] |
Performs special queries like COUNT, SUM etc based on the current query.
@param string $type
@param string $field
@throws Exception
@return float
|
[
"Performs",
"special",
"queries",
"like",
"COUNT",
"SUM",
"etc",
"based",
"on",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L163-L180
|
221,133
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.getAlias
|
public function getAlias(): ?string
{
return isset($this->statements['aliases']) === true ? array_values($this->statements['aliases'])[0] : null;
}
|
php
|
public function getAlias(): ?string
{
return isset($this->statements['aliases']) === true ? array_values($this->statements['aliases'])[0] : null;
}
|
[
"public",
"function",
"getAlias",
"(",
")",
":",
"?",
"string",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"statements",
"[",
"'aliases'",
"]",
")",
"===",
"true",
"?",
"array_values",
"(",
"$",
"this",
"->",
"statements",
"[",
"'aliases'",
"]",
")",
"[",
"0",
"]",
":",
"null",
";",
"}"
] |
Get the alias for the current query
@return string|null
|
[
"Get",
"the",
"alias",
"for",
"the",
"current",
"query"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L187-L190
|
221,134
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.getTable
|
public function getTable(): ?string
{
if (isset($this->statements['tables']) === true) {
$table = array_values($this->statements['tables'])[0];
if ($table instanceof Raw === false) {
return $table;
}
}
return null;
}
|
php
|
public function getTable(): ?string
{
if (isset($this->statements['tables']) === true) {
$table = array_values($this->statements['tables'])[0];
if ($table instanceof Raw === false) {
return $table;
}
}
return null;
}
|
[
"public",
"function",
"getTable",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"statements",
"[",
"'tables'",
"]",
")",
"===",
"true",
")",
"{",
"$",
"table",
"=",
"array_values",
"(",
"$",
"this",
"->",
"statements",
"[",
"'tables'",
"]",
")",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"table",
"instanceof",
"Raw",
"===",
"false",
")",
"{",
"return",
"$",
"table",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the table-name for the current query
@return string|null
|
[
"Get",
"the",
"table",
"-",
"name",
"for",
"the",
"current",
"query"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L197-L207
|
221,135
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.first
|
public function first()
{
$result = $this->limit(1)->get();
return ($result !== null && \count($result) !== 0) ? $result[0] : null;
}
|
php
|
public function first()
{
$result = $this->limit(1)->get();
return ($result !== null && \count($result) !== 0) ? $result[0] : null;
}
|
[
"public",
"function",
"first",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"limit",
"(",
"1",
")",
"->",
"get",
"(",
")",
";",
"return",
"(",
"$",
"result",
"!==",
"null",
"&&",
"\\",
"count",
"(",
"$",
"result",
")",
"!==",
"0",
")",
"?",
"$",
"result",
"[",
"0",
"]",
":",
"null",
";",
"}"
] |
Returns the first row
@throws Exception
@return \stdClass|string|null
|
[
"Returns",
"the",
"first",
"row"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L215-L220
|
221,136
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.getQuery
|
public function getQuery(string $type = 'select', ...$arguments): QueryObject
{
$allowedTypes = [
'select',
'insert',
'insertignore',
'replace',
'delete',
'update',
'criteriaonly',
];
if (\in_array(strtolower($type), $allowedTypes, true) === false) {
throw new Exception($type . ' is not a known type.', 1);
}
$queryArr = $this->adapterInstance->$type($this->statements, ...$arguments);
return new QueryObject($queryArr['sql'], $queryArr['bindings'], $this->getConnection());
}
|
php
|
public function getQuery(string $type = 'select', ...$arguments): QueryObject
{
$allowedTypes = [
'select',
'insert',
'insertignore',
'replace',
'delete',
'update',
'criteriaonly',
];
if (\in_array(strtolower($type), $allowedTypes, true) === false) {
throw new Exception($type . ' is not a known type.', 1);
}
$queryArr = $this->adapterInstance->$type($this->statements, ...$arguments);
return new QueryObject($queryArr['sql'], $queryArr['bindings'], $this->getConnection());
}
|
[
"public",
"function",
"getQuery",
"(",
"string",
"$",
"type",
"=",
"'select'",
",",
"...",
"$",
"arguments",
")",
":",
"QueryObject",
"{",
"$",
"allowedTypes",
"=",
"[",
"'select'",
",",
"'insert'",
",",
"'insertignore'",
",",
"'replace'",
",",
"'delete'",
",",
"'update'",
",",
"'criteriaonly'",
",",
"]",
";",
"if",
"(",
"\\",
"in_array",
"(",
"strtolower",
"(",
"$",
"type",
")",
",",
"$",
"allowedTypes",
",",
"true",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"type",
".",
"' is not a known type.'",
",",
"1",
")",
";",
"}",
"$",
"queryArr",
"=",
"$",
"this",
"->",
"adapterInstance",
"->",
"$",
"type",
"(",
"$",
"this",
"->",
"statements",
",",
"...",
"$",
"arguments",
")",
";",
"return",
"new",
"QueryObject",
"(",
"$",
"queryArr",
"[",
"'sql'",
"]",
",",
"$",
"queryArr",
"[",
"'bindings'",
"]",
",",
"$",
"this",
"->",
"getConnection",
"(",
")",
")",
";",
"}"
] |
Returns Query-object.
@param string $type
@param array|mixed|null $arguments
@return QueryObject
@throws Exception
|
[
"Returns",
"Query",
"-",
"object",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L274-L293
|
221,137
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.fireEvents
|
public function fireEvents(string $name, QueryObject $queryObject, array $eventArguments = []): void
{
$this->connection->getEventHandler()->fireEvents($name, $queryObject, $this, $eventArguments);
}
|
php
|
public function fireEvents(string $name, QueryObject $queryObject, array $eventArguments = []): void
{
$this->connection->getEventHandler()->fireEvents($name, $queryObject, $this, $eventArguments);
}
|
[
"public",
"function",
"fireEvents",
"(",
"string",
"$",
"name",
",",
"QueryObject",
"$",
"queryObject",
",",
"array",
"$",
"eventArguments",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"this",
"->",
"connection",
"->",
"getEventHandler",
"(",
")",
"->",
"fireEvents",
"(",
"$",
"name",
",",
"$",
"queryObject",
",",
"$",
"this",
",",
"$",
"eventArguments",
")",
";",
"}"
] |
Fires event by given event name
@param string $name
@param QueryObject $queryObject
@param array $eventArguments
@return void
|
[
"Fires",
"event",
"by",
"given",
"event",
"name"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L328-L331
|
221,138
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.parseParameterType
|
protected function parseParameterType($value): int
{
if ($value === null) {
return PDO::PARAM_NULL;
}
if (\is_int($value) === true || \is_bool($value) === true) {
return PDO::PARAM_INT;
}
return PDO::PARAM_STR;
}
|
php
|
protected function parseParameterType($value): int
{
if ($value === null) {
return PDO::PARAM_NULL;
}
if (\is_int($value) === true || \is_bool($value) === true) {
return PDO::PARAM_INT;
}
return PDO::PARAM_STR;
}
|
[
"protected",
"function",
"parseParameterType",
"(",
"$",
"value",
")",
":",
"int",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"PDO",
"::",
"PARAM_NULL",
";",
"}",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"value",
")",
"===",
"true",
"||",
"\\",
"is_bool",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"return",
"PDO",
"::",
"PARAM_INT",
";",
"}",
"return",
"PDO",
"::",
"PARAM_STR",
";",
"}"
] |
Parse parameter type from value
@param mixed $value
@return int
|
[
"Parse",
"parameter",
"type",
"from",
"value"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L397-L409
|
221,139
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.addStatement
|
protected function addStatement(string $key, $value): void
{
if (array_key_exists($key, $this->statements) === false) {
$this->statements[$key] = (array)$value;
} else {
$this->statements[$key] = array_merge($this->statements[$key], (array)$value);
}
}
|
php
|
protected function addStatement(string $key, $value): void
{
if (array_key_exists($key, $this->statements) === false) {
$this->statements[$key] = (array)$value;
} else {
$this->statements[$key] = array_merge($this->statements[$key], (array)$value);
}
}
|
[
"protected",
"function",
"addStatement",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"statements",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"$",
"key",
"]",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"statements",
"[",
"$",
"key",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"statements",
"[",
"$",
"key",
"]",
",",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"}"
] |
Add new statement to statement-list
@param string $key
@param string|array $value
@return void
|
[
"Add",
"new",
"statement",
"to",
"statement",
"-",
"list"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L523-L530
|
221,140
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.from
|
public function from($tables = null): IQueryBuilderHandler
{
if ($tables === null) {
$this->statements['tables'] = null;
return $this;
}
if (\is_array($tables) === false) {
$tables = \func_get_args();
}
$tTables = [];
foreach ((array)$tables as $key => $value) {
if (\is_string($key) === true) {
$this->alias($value, $key);
$tTables[] = $key;
continue;
}
$tTables[] = $value;
}
$tTables = $this->addTablePrefix($tTables, false);
$this->statements['tables'] = $tTables;
return $this;
}
|
php
|
public function from($tables = null): IQueryBuilderHandler
{
if ($tables === null) {
$this->statements['tables'] = null;
return $this;
}
if (\is_array($tables) === false) {
$tables = \func_get_args();
}
$tTables = [];
foreach ((array)$tables as $key => $value) {
if (\is_string($key) === true) {
$this->alias($value, $key);
$tTables[] = $key;
continue;
}
$tTables[] = $value;
}
$tTables = $this->addTablePrefix($tTables, false);
$this->statements['tables'] = $tTables;
return $this;
}
|
[
"public",
"function",
"from",
"(",
"$",
"tables",
"=",
"null",
")",
":",
"IQueryBuilderHandler",
"{",
"if",
"(",
"$",
"tables",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"'tables'",
"]",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"tables",
")",
"===",
"false",
")",
"{",
"$",
"tables",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"}",
"$",
"tTables",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"tables",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"key",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"alias",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"$",
"tTables",
"[",
"]",
"=",
"$",
"key",
";",
"continue",
";",
"}",
"$",
"tTables",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"tTables",
"=",
"$",
"this",
"->",
"addTablePrefix",
"(",
"$",
"tTables",
",",
"false",
")",
";",
"$",
"this",
"->",
"statements",
"[",
"'tables'",
"]",
"=",
"$",
"tTables",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds FROM statement to the current query.
@param string|array|null $tables Single table or multiple tables as an array or as multiple parameters
@return static
|
[
"Adds",
"FROM",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L573-L601
|
221,141
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.subQuery
|
public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null): Raw
{
$sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')';
if ($alias !== null) {
$sql = $sql . ' AS ' . $this->adapterInstance->wrapSanitizer($alias);
}
return $queryBuilder->raw($sql);
}
|
php
|
public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null): Raw
{
$sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')';
if ($alias !== null) {
$sql = $sql . ' AS ' . $this->adapterInstance->wrapSanitizer($alias);
}
return $queryBuilder->raw($sql);
}
|
[
"public",
"function",
"subQuery",
"(",
"QueryBuilderHandler",
"$",
"queryBuilder",
",",
"$",
"alias",
"=",
"null",
")",
":",
"Raw",
"{",
"$",
"sql",
"=",
"'('",
".",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getRawSql",
"(",
")",
".",
"')'",
";",
"if",
"(",
"$",
"alias",
"!==",
"null",
")",
"{",
"$",
"sql",
"=",
"$",
"sql",
".",
"' AS '",
".",
"$",
"this",
"->",
"adapterInstance",
"->",
"wrapSanitizer",
"(",
"$",
"alias",
")",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"raw",
"(",
"$",
"sql",
")",
";",
"}"
] |
Performs new sub-query.
Call this method when you want to add a new sub-query in your where etc.
@param QueryBuilderHandler $queryBuilder
@param string|null $alias
@throws Exception
@return Raw
|
[
"Performs",
"new",
"sub",
"-",
"query",
".",
"Call",
"this",
"method",
"when",
"you",
"want",
"to",
"add",
"a",
"new",
"sub",
"-",
"query",
"in",
"your",
"where",
"etc",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L646-L654
|
221,142
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.raw
|
public function raw(string $value, $bindings = null): Raw
{
if (\is_array($bindings) === false) {
$bindings = \func_get_args();
array_shift($bindings);
}
return new Raw($value, $bindings);
}
|
php
|
public function raw(string $value, $bindings = null): Raw
{
if (\is_array($bindings) === false) {
$bindings = \func_get_args();
array_shift($bindings);
}
return new Raw($value, $bindings);
}
|
[
"public",
"function",
"raw",
"(",
"string",
"$",
"value",
",",
"$",
"bindings",
"=",
"null",
")",
":",
"Raw",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"bindings",
")",
"===",
"false",
")",
"{",
"$",
"bindings",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"bindings",
")",
";",
"}",
"return",
"new",
"Raw",
"(",
"$",
"value",
",",
"$",
"bindings",
")",
";",
"}"
] |
Adds a raw string to the current query.
This query will be ignored from any parsing or formatting by the Query builder
and should be used in conjunction with other statements in the query.
For example: $qb->where('result', '>', $qb->raw('COUNT(`score`)));
@param string $value
@param array|null|mixed $bindings ...
@return Raw
|
[
"Adds",
"a",
"raw",
"string",
"to",
"the",
"current",
"query",
".",
"This",
"query",
"will",
"be",
"ignored",
"from",
"any",
"parsing",
"or",
"formatting",
"by",
"the",
"Query",
"builder",
"and",
"should",
"be",
"used",
"in",
"conjunction",
"with",
"other",
"statements",
"in",
"the",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L668-L676
|
221,143
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.delete
|
public function delete(array $columns = null): \PDOStatement
{
/* @var $response \PDOStatement */
$queryObject = $this->getQuery('delete', $columns);
$this->connection->setLastQuery($queryObject);
$this->fireEvents(EventHandler::EVENT_BEFORE_DELETE, $queryObject);
[$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());
$this->fireEvents(EventHandler::EVENT_AFTER_DELETE, $queryObject, [
'execution_time' => $executionTime,
]);
return $response;
}
|
php
|
public function delete(array $columns = null): \PDOStatement
{
/* @var $response \PDOStatement */
$queryObject = $this->getQuery('delete', $columns);
$this->connection->setLastQuery($queryObject);
$this->fireEvents(EventHandler::EVENT_BEFORE_DELETE, $queryObject);
[$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());
$this->fireEvents(EventHandler::EVENT_AFTER_DELETE, $queryObject, [
'execution_time' => $executionTime,
]);
return $response;
}
|
[
"public",
"function",
"delete",
"(",
"array",
"$",
"columns",
"=",
"null",
")",
":",
"\\",
"PDOStatement",
"{",
"/* @var $response \\PDOStatement */",
"$",
"queryObject",
"=",
"$",
"this",
"->",
"getQuery",
"(",
"'delete'",
",",
"$",
"columns",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"setLastQuery",
"(",
"$",
"queryObject",
")",
";",
"$",
"this",
"->",
"fireEvents",
"(",
"EventHandler",
"::",
"EVENT_BEFORE_DELETE",
",",
"$",
"queryObject",
")",
";",
"[",
"$",
"response",
",",
"$",
"executionTime",
"]",
"=",
"$",
"this",
"->",
"statement",
"(",
"$",
"queryObject",
"->",
"getSql",
"(",
")",
",",
"$",
"queryObject",
"->",
"getBindings",
"(",
")",
")",
";",
"$",
"this",
"->",
"fireEvents",
"(",
"EventHandler",
"::",
"EVENT_AFTER_DELETE",
",",
"$",
"queryObject",
",",
"[",
"'execution_time'",
"=>",
"$",
"executionTime",
",",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Forms delete on the current query.
@var array|null $columns
@return \PDOStatement
@throws Exception
|
[
"Forms",
"delete",
"on",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L737-L752
|
221,144
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.where
|
public function where($key, $operator = null, $value = null): IQueryBuilderHandler
{
// If two params are given then assume operator is =
if (\func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
if (\is_bool($value) === true) {
$value = (int)$value;
}
return $this->whereHandler($key, $operator, $value);
}
|
php
|
public function where($key, $operator = null, $value = null): IQueryBuilderHandler
{
// If two params are given then assume operator is =
if (\func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
if (\is_bool($value) === true) {
$value = (int)$value;
}
return $this->whereHandler($key, $operator, $value);
}
|
[
"public",
"function",
"where",
"(",
"$",
"key",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
":",
"IQueryBuilderHandler",
"{",
"// If two params are given then assume operator is =",
"if",
"(",
"\\",
"func_num_args",
"(",
")",
"===",
"2",
")",
"{",
"$",
"value",
"=",
"$",
"operator",
";",
"$",
"operator",
"=",
"'='",
";",
"}",
"if",
"(",
"\\",
"is_bool",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"whereHandler",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}"
] |
Adds WHERE statement to the current query.
@param string|Raw|\Closure $key
@param string|null $operator
@param mixed|Raw|\Closure|null $value
@return static
|
[
"Adds",
"WHERE",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L777-L790
|
221,145
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.getEvent
|
public function getEvent(string $name, string $table = null): ?callable
{
return $this->connection->getEventHandler()->getEvent($name, $table);
}
|
php
|
public function getEvent(string $name, string $table = null): ?callable
{
return $this->connection->getEventHandler()->getEvent($name, $table);
}
|
[
"public",
"function",
"getEvent",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"table",
"=",
"null",
")",
":",
"?",
"callable",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"getEventHandler",
"(",
")",
"->",
"getEvent",
"(",
"$",
"name",
",",
"$",
"table",
")",
";",
"}"
] |
Get event by event name
@param string $name
@param string|null $table
@return callable|null
|
[
"Get",
"event",
"by",
"event",
"name"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L832-L835
|
221,146
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.groupBy
|
public function groupBy($field): IQueryBuilderHandler
{
if (($field instanceof Raw) === false) {
$field = $this->addTablePrefix($field);
}
if (\is_array($field) === true) {
$this->statements['groupBys'] = array_merge($this->statements['groupBys'], $field);
} else {
$this->statements['groupBys'][] = $field;
}
return $this;
}
|
php
|
public function groupBy($field): IQueryBuilderHandler
{
if (($field instanceof Raw) === false) {
$field = $this->addTablePrefix($field);
}
if (\is_array($field) === true) {
$this->statements['groupBys'] = array_merge($this->statements['groupBys'], $field);
} else {
$this->statements['groupBys'][] = $field;
}
return $this;
}
|
[
"public",
"function",
"groupBy",
"(",
"$",
"field",
")",
":",
"IQueryBuilderHandler",
"{",
"if",
"(",
"(",
"$",
"field",
"instanceof",
"Raw",
")",
"===",
"false",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"addTablePrefix",
"(",
"$",
"field",
")",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"field",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"'groupBys'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"statements",
"[",
"'groupBys'",
"]",
",",
"$",
"field",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"statements",
"[",
"'groupBys'",
"]",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds GROUP BY to the current query.
@param string|Raw|\Closure|array $field
@return static
|
[
"Adds",
"GROUP",
"BY",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L844-L857
|
221,147
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.join
|
public function join($table, $key = null, $operator = null, $value = null, $type = ''): IQueryBuilderHandler
{
$joinBuilder = null;
if ($key !== null) {
$joinBuilder = new JoinBuilder($this->connection);
/**
* Build a new JoinBuilder class, keep it by reference so any changes made
* in the closure should reflect here
*/
if ($key instanceof \Closure === false) {
$key = function (JoinBuilder $joinBuilder) use ($key, $operator, $value) {
$joinBuilder->on($key, $operator, $value);
};
}
// Call the closure with our new joinBuilder object
$key($joinBuilder);
}
$table = $this->addTablePrefix($table, false);
// Get the criteria only query from the joinBuilder object
$this->statements['joins'][] = [
'type' => $type,
'table' => $table,
'joinBuilder' => $joinBuilder,
];
return $this;
}
|
php
|
public function join($table, $key = null, $operator = null, $value = null, $type = ''): IQueryBuilderHandler
{
$joinBuilder = null;
if ($key !== null) {
$joinBuilder = new JoinBuilder($this->connection);
/**
* Build a new JoinBuilder class, keep it by reference so any changes made
* in the closure should reflect here
*/
if ($key instanceof \Closure === false) {
$key = function (JoinBuilder $joinBuilder) use ($key, $operator, $value) {
$joinBuilder->on($key, $operator, $value);
};
}
// Call the closure with our new joinBuilder object
$key($joinBuilder);
}
$table = $this->addTablePrefix($table, false);
// Get the criteria only query from the joinBuilder object
$this->statements['joins'][] = [
'type' => $type,
'table' => $table,
'joinBuilder' => $joinBuilder,
];
return $this;
}
|
[
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"key",
"=",
"null",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
"=",
"''",
")",
":",
"IQueryBuilderHandler",
"{",
"$",
"joinBuilder",
"=",
"null",
";",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"joinBuilder",
"=",
"new",
"JoinBuilder",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"/**\n * Build a new JoinBuilder class, keep it by reference so any changes made\n * in the closure should reflect here\n */",
"if",
"(",
"$",
"key",
"instanceof",
"\\",
"Closure",
"===",
"false",
")",
"{",
"$",
"key",
"=",
"function",
"(",
"JoinBuilder",
"$",
"joinBuilder",
")",
"use",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"$",
"joinBuilder",
"->",
"on",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}",
";",
"}",
"// Call the closure with our new joinBuilder object",
"$",
"key",
"(",
"$",
"joinBuilder",
")",
";",
"}",
"$",
"table",
"=",
"$",
"this",
"->",
"addTablePrefix",
"(",
"$",
"table",
",",
"false",
")",
";",
"// Get the criteria only query from the joinBuilder object",
"$",
"this",
"->",
"statements",
"[",
"'joins'",
"]",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"type",
",",
"'table'",
"=>",
"$",
"table",
",",
"'joinBuilder'",
"=>",
"$",
"joinBuilder",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds new JOIN statement to the current query.
@param string|Raw|\Closure|array $table
@param string|JoinBuilder|Raw|\Closure|null $key
@param string|null $operator
@param string|Raw|\Closure $value
@param string $type
@return static
@throws Exception
```
Examples:
- basic usage
->join('table2', 'table2.person_id', '=', 'table1.id');
- as alias 'bar'
->join(['table2','bar'], 'bar.person_id', '=', 'table1.id');
- complex usage
->join('another_table', function($table)
{
$table->on('another_table.person_id', '=', 'my_table.id');
$table->on('another_table.person_id2', '=', 'my_table.id2');
$table->orOn('another_table.age', '>', $queryBuilder->raw(1));
})
```
|
[
"Adds",
"new",
"JOIN",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L904-L935
|
221,148
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.transaction
|
public function transaction(\Closure $callback): Transaction
{
/**
* Get the Transaction class
*
* @var \Pecee\Pixie\QueryBuilder\Transaction $queryTransaction
* @throws \Exception
*/
$queryTransaction = new Transaction($this->connection);
$queryTransaction->statements = $this->statements;
try {
// Begin the PDO transaction
if ($this->pdo()->inTransaction() === false) {
$this->pdo()->beginTransaction();
}
// Call closure - this callback will return TransactionHaltException if user has already committed the transaction
$callback($queryTransaction);
// If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes
$this->pdo()->commit();
} catch (TransactionHaltException $e) {
// Commit or rollback behavior has been triggered in the closure
return $queryTransaction;
} catch (\Exception $e) {
// Something went wrong. Rollback and throw Exception
if ($this->pdo()->inTransaction() === true) {
$this->pdo()->rollBack();
}
throw Exception::create($e, $this->getConnection()->getAdapter()->getQueryAdapterClass(), $this->getLastQuery());
}
return $queryTransaction;
}
|
php
|
public function transaction(\Closure $callback): Transaction
{
/**
* Get the Transaction class
*
* @var \Pecee\Pixie\QueryBuilder\Transaction $queryTransaction
* @throws \Exception
*/
$queryTransaction = new Transaction($this->connection);
$queryTransaction->statements = $this->statements;
try {
// Begin the PDO transaction
if ($this->pdo()->inTransaction() === false) {
$this->pdo()->beginTransaction();
}
// Call closure - this callback will return TransactionHaltException if user has already committed the transaction
$callback($queryTransaction);
// If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes
$this->pdo()->commit();
} catch (TransactionHaltException $e) {
// Commit or rollback behavior has been triggered in the closure
return $queryTransaction;
} catch (\Exception $e) {
// Something went wrong. Rollback and throw Exception
if ($this->pdo()->inTransaction() === true) {
$this->pdo()->rollBack();
}
throw Exception::create($e, $this->getConnection()->getAdapter()->getQueryAdapterClass(), $this->getLastQuery());
}
return $queryTransaction;
}
|
[
"public",
"function",
"transaction",
"(",
"\\",
"Closure",
"$",
"callback",
")",
":",
"Transaction",
"{",
"/**\n * Get the Transaction class\n *\n * @var \\Pecee\\Pixie\\QueryBuilder\\Transaction $queryTransaction\n * @throws \\Exception\n */",
"$",
"queryTransaction",
"=",
"new",
"Transaction",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"queryTransaction",
"->",
"statements",
"=",
"$",
"this",
"->",
"statements",
";",
"try",
"{",
"// Begin the PDO transaction",
"if",
"(",
"$",
"this",
"->",
"pdo",
"(",
")",
"->",
"inTransaction",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"pdo",
"(",
")",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"// Call closure - this callback will return TransactionHaltException if user has already committed the transaction",
"$",
"callback",
"(",
"$",
"queryTransaction",
")",
";",
"// If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes",
"$",
"this",
"->",
"pdo",
"(",
")",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"TransactionHaltException",
"$",
"e",
")",
"{",
"// Commit or rollback behavior has been triggered in the closure",
"return",
"$",
"queryTransaction",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Something went wrong. Rollback and throw Exception",
"if",
"(",
"$",
"this",
"->",
"pdo",
"(",
")",
"->",
"inTransaction",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"pdo",
"(",
")",
"->",
"rollBack",
"(",
")",
";",
"}",
"throw",
"Exception",
"::",
"create",
"(",
"$",
"e",
",",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"getAdapter",
"(",
")",
"->",
"getQueryAdapterClass",
"(",
")",
",",
"$",
"this",
"->",
"getLastQuery",
"(",
")",
")",
";",
"}",
"return",
"$",
"queryTransaction",
";",
"}"
] |
Performs the transaction
@param \Closure $callback
@throws Exception
@return Transaction
|
[
"Performs",
"the",
"transaction"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1015-L1054
|
221,149
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.orHaving
|
public function orHaving($key, $operator, $value): IQueryBuilderHandler
{
return $this->having($key, $operator, $value, 'OR');
}
|
php
|
public function orHaving($key, $operator, $value): IQueryBuilderHandler
{
return $this->having($key, $operator, $value, 'OR');
}
|
[
"public",
"function",
"orHaving",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
":",
"IQueryBuilderHandler",
"{",
"return",
"$",
"this",
"->",
"having",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'OR'",
")",
";",
"}"
] |
Adds OR HAVING statement to the current query.
@param string|Raw|\Closure $key
@param string|Raw|\Closure $operator
@param mixed|Raw|\Closure|null $value
@return static
|
[
"Adds",
"OR",
"HAVING",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1136-L1139
|
221,150
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.orWhereBetween
|
public function orWhereBetween($key, $valueFrom, $valueTo): IQueryBuilderHandler
{
return $this->whereHandler($key, 'BETWEEN', [$valueFrom, $valueTo], 'OR');
}
|
php
|
public function orWhereBetween($key, $valueFrom, $valueTo): IQueryBuilderHandler
{
return $this->whereHandler($key, 'BETWEEN', [$valueFrom, $valueTo], 'OR');
}
|
[
"public",
"function",
"orWhereBetween",
"(",
"$",
"key",
",",
"$",
"valueFrom",
",",
"$",
"valueTo",
")",
":",
"IQueryBuilderHandler",
"{",
"return",
"$",
"this",
"->",
"whereHandler",
"(",
"$",
"key",
",",
"'BETWEEN'",
",",
"[",
"$",
"valueFrom",
",",
"$",
"valueTo",
"]",
",",
"'OR'",
")",
";",
"}"
] |
Adds OR WHERE BETWEEN statement to the current query.
@param string|Raw|\Closure $key
@param string|integer|float $valueFrom
@param string|integer|float $valueTo
@return static
|
[
"Adds",
"OR",
"WHERE",
"BETWEEN",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1188-L1191
|
221,151
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.whereNullHandler
|
protected function whereNullHandler($key, string $prefix = '', string $operator = ''): IQueryBuilderHandler
{
$key = $this->adapterInstance->wrapSanitizer($this->addTablePrefix($key));
$prefix = ($prefix !== '') ? $prefix . ' ' : $prefix;
return $this->{$operator . 'Where'}($this->raw("$key IS {$prefix}NULL"));
}
|
php
|
protected function whereNullHandler($key, string $prefix = '', string $operator = ''): IQueryBuilderHandler
{
$key = $this->adapterInstance->wrapSanitizer($this->addTablePrefix($key));
$prefix = ($prefix !== '') ? $prefix . ' ' : $prefix;
return $this->{$operator . 'Where'}($this->raw("$key IS {$prefix}NULL"));
}
|
[
"protected",
"function",
"whereNullHandler",
"(",
"$",
"key",
",",
"string",
"$",
"prefix",
"=",
"''",
",",
"string",
"$",
"operator",
"=",
"''",
")",
":",
"IQueryBuilderHandler",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"adapterInstance",
"->",
"wrapSanitizer",
"(",
"$",
"this",
"->",
"addTablePrefix",
"(",
"$",
"key",
")",
")",
";",
"$",
"prefix",
"=",
"(",
"$",
"prefix",
"!==",
"''",
")",
"?",
"$",
"prefix",
".",
"' '",
":",
"$",
"prefix",
";",
"return",
"$",
"this",
"->",
"{",
"$",
"operator",
".",
"'Where'",
"}",
"(",
"$",
"this",
"->",
"raw",
"(",
"\"$key IS {$prefix}NULL\"",
")",
")",
";",
"}"
] |
Handles WHERE NULL statements.
@param string|Raw|\Closure $key
@param string $prefix
@param string $operator
@return static
|
[
"Handles",
"WHERE",
"NULL",
"statements",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1260-L1266
|
221,152
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.orderBy
|
public function orderBy($fields, string $direction = 'ASC'): IQueryBuilderHandler
{
if (\is_array($fields) === false) {
$fields = [$fields];
}
foreach ((array)$fields as $key => $value) {
$field = $key;
$type = $value;
if (\is_int($key) === true) {
$field = $value;
$type = $direction;
}
if (($field instanceof Raw) === false) {
$field = $this->addTablePrefix($field);
}
$this->statements['orderBys'][] = compact('field', 'type');
}
return $this;
}
|
php
|
public function orderBy($fields, string $direction = 'ASC'): IQueryBuilderHandler
{
if (\is_array($fields) === false) {
$fields = [$fields];
}
foreach ((array)$fields as $key => $value) {
$field = $key;
$type = $value;
if (\is_int($key) === true) {
$field = $value;
$type = $direction;
}
if (($field instanceof Raw) === false) {
$field = $this->addTablePrefix($field);
}
$this->statements['orderBys'][] = compact('field', 'type');
}
return $this;
}
|
[
"public",
"function",
"orderBy",
"(",
"$",
"fields",
",",
"string",
"$",
"direction",
"=",
"'ASC'",
")",
":",
"IQueryBuilderHandler",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"fields",
")",
"===",
"false",
")",
"{",
"$",
"fields",
"=",
"[",
"$",
"fields",
"]",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"field",
"=",
"$",
"key",
";",
"$",
"type",
"=",
"$",
"value",
";",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"key",
")",
"===",
"true",
")",
"{",
"$",
"field",
"=",
"$",
"value",
";",
"$",
"type",
"=",
"$",
"direction",
";",
"}",
"if",
"(",
"(",
"$",
"field",
"instanceof",
"Raw",
")",
"===",
"false",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"addTablePrefix",
"(",
"$",
"field",
")",
";",
"}",
"$",
"this",
"->",
"statements",
"[",
"'orderBys'",
"]",
"[",
"]",
"=",
"compact",
"(",
"'field'",
",",
"'type'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds ORDER BY statement to the current query.
@param string|Raw|\Closure|array $fields
@param string $direction
@return static
|
[
"Adds",
"ORDER",
"BY",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1288-L1311
|
221,153
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.query
|
public function query(string $sql, array $bindings = []): IQueryBuilderHandler
{
$queryObject = new QueryObject($sql, $bindings, $this->getConnection());
$this->connection->setLastQuery($queryObject);
$this->fireEvents(EventHandler::EVENT_BEFORE_QUERY, $queryObject);
[$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());
$this->fireEvents(EventHandler::EVENT_AFTER_QUERY, $queryObject, [
'execution_time' => $executionTime,
]);
$this->pdoStatement = $response;
return $this;
}
|
php
|
public function query(string $sql, array $bindings = []): IQueryBuilderHandler
{
$queryObject = new QueryObject($sql, $bindings, $this->getConnection());
$this->connection->setLastQuery($queryObject);
$this->fireEvents(EventHandler::EVENT_BEFORE_QUERY, $queryObject);
[$response, $executionTime] = $this->statement($queryObject->getSql(), $queryObject->getBindings());
$this->fireEvents(EventHandler::EVENT_AFTER_QUERY, $queryObject, [
'execution_time' => $executionTime,
]);
$this->pdoStatement = $response;
return $this;
}
|
[
"public",
"function",
"query",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"bindings",
"=",
"[",
"]",
")",
":",
"IQueryBuilderHandler",
"{",
"$",
"queryObject",
"=",
"new",
"QueryObject",
"(",
"$",
"sql",
",",
"$",
"bindings",
",",
"$",
"this",
"->",
"getConnection",
"(",
")",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"setLastQuery",
"(",
"$",
"queryObject",
")",
";",
"$",
"this",
"->",
"fireEvents",
"(",
"EventHandler",
"::",
"EVENT_BEFORE_QUERY",
",",
"$",
"queryObject",
")",
";",
"[",
"$",
"response",
",",
"$",
"executionTime",
"]",
"=",
"$",
"this",
"->",
"statement",
"(",
"$",
"queryObject",
"->",
"getSql",
"(",
")",
",",
"$",
"queryObject",
"->",
"getBindings",
"(",
")",
")",
";",
"$",
"this",
"->",
"fireEvents",
"(",
"EventHandler",
"::",
"EVENT_AFTER_QUERY",
",",
"$",
"queryObject",
",",
"[",
"'execution_time'",
"=>",
"$",
"executionTime",
",",
"]",
")",
";",
"$",
"this",
"->",
"pdoStatement",
"=",
"$",
"response",
";",
"return",
"$",
"this",
";",
"}"
] |
Performs query.
@param string $sql
@param array $bindings
@return static
@throws Exception
|
[
"Performs",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1322-L1338
|
221,154
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.registerEvent
|
public function registerEvent(string $name, ?string $table = null, \Closure $action): void
{
$this->connection->getEventHandler()->registerEvent($name, $table, $action);
}
|
php
|
public function registerEvent(string $name, ?string $table = null, \Closure $action): void
{
$this->connection->getEventHandler()->registerEvent($name, $table, $action);
}
|
[
"public",
"function",
"registerEvent",
"(",
"string",
"$",
"name",
",",
"?",
"string",
"$",
"table",
"=",
"null",
",",
"\\",
"Closure",
"$",
"action",
")",
":",
"void",
"{",
"$",
"this",
"->",
"connection",
"->",
"getEventHandler",
"(",
")",
"->",
"registerEvent",
"(",
"$",
"name",
",",
"$",
"table",
",",
"$",
"action",
")",
";",
"}"
] |
Register new event
@param string $name
@param string|null $table
@param \Closure $action
@return void
|
[
"Register",
"new",
"event"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1349-L1352
|
221,155
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.rightJoin
|
public function rightJoin($table, $key, ?string $operator = null, $value = null): IQueryBuilderHandler
{
return $this->join($table, $key, $operator, $value, 'right');
}
|
php
|
public function rightJoin($table, $key, ?string $operator = null, $value = null): IQueryBuilderHandler
{
return $this->join($table, $key, $operator, $value, 'right');
}
|
[
"public",
"function",
"rightJoin",
"(",
"$",
"table",
",",
"$",
"key",
",",
"?",
"string",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
":",
"IQueryBuilderHandler",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'right'",
")",
";",
"}"
] |
Adds new right join statement to the current query.
@param string|Raw|\Closure|array $table
@param string|JoinBuilder|Raw|\Closure $key
@param string|null $operator
@param string|Raw|\Closure|null $value
@return static
@throws Exception
|
[
"Adds",
"new",
"right",
"join",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1391-L1394
|
221,156
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.selectDistinct
|
public function selectDistinct($fields)
{
if ($this->overwriteEnabled === true) {
$this->statements['distincts'] = $fields;
} else {
$this->addStatement('distincts', $fields);
}
return $this;
}
|
php
|
public function selectDistinct($fields)
{
if ($this->overwriteEnabled === true) {
$this->statements['distincts'] = $fields;
} else {
$this->addStatement('distincts', $fields);
}
return $this;
}
|
[
"public",
"function",
"selectDistinct",
"(",
"$",
"fields",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"overwriteEnabled",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"'distincts'",
"]",
"=",
"$",
"fields",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addStatement",
"(",
"'distincts'",
",",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Performs select distinct on the current query.
@param string|Raw|\Closure|array $fields
@return static
|
[
"Performs",
"select",
"distinct",
"on",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1403-L1412
|
221,157
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.whereBetween
|
public function whereBetween($key, $valueFrom, $valueTo): IQueryBuilderHandler
{
return $this->whereHandler($key, 'BETWEEN', [$valueFrom, $valueTo]);
}
|
php
|
public function whereBetween($key, $valueFrom, $valueTo): IQueryBuilderHandler
{
return $this->whereHandler($key, 'BETWEEN', [$valueFrom, $valueTo]);
}
|
[
"public",
"function",
"whereBetween",
"(",
"$",
"key",
",",
"$",
"valueFrom",
",",
"$",
"valueTo",
")",
":",
"IQueryBuilderHandler",
"{",
"return",
"$",
"this",
"->",
"whereHandler",
"(",
"$",
"key",
",",
"'BETWEEN'",
",",
"[",
"$",
"valueFrom",
",",
"$",
"valueTo",
"]",
")",
";",
"}"
] |
Adds WHERE BETWEEN statement to the current query.
@param string|Raw|\Closure $key
@param string|integer|float|Raw|\Closure $valueFrom
@param string|integer|float|Raw|\Closure $valueTo
@return static
|
[
"Adds",
"WHERE",
"BETWEEN",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1529-L1532
|
221,158
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.whereNot
|
public function whereNot($key, $operator = null, $value = null): IQueryBuilderHandler
{
// If two params are given then assume operator is =
if (\func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return $this->whereHandler($key, $operator, $value, 'AND NOT');
}
|
php
|
public function whereNot($key, $operator = null, $value = null): IQueryBuilderHandler
{
// If two params are given then assume operator is =
if (\func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return $this->whereHandler($key, $operator, $value, 'AND NOT');
}
|
[
"public",
"function",
"whereNot",
"(",
"$",
"key",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
":",
"IQueryBuilderHandler",
"{",
"// If two params are given then assume operator is =",
"if",
"(",
"\\",
"func_num_args",
"(",
")",
"===",
"2",
")",
"{",
"$",
"value",
"=",
"$",
"operator",
";",
"$",
"operator",
"=",
"'='",
";",
"}",
"return",
"$",
"this",
"->",
"whereHandler",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'AND NOT'",
")",
";",
"}"
] |
Adds WHERE NOT statement to the current query.
@param string|Raw|\Closure $key
@param string|array|Raw|\Closure|null $operator
@param mixed|Raw|\Closure|null $value
@return static
|
[
"Adds",
"WHERE",
"NOT",
"statement",
"to",
"the",
"current",
"query",
"."
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1556-L1565
|
221,159
|
skipperbent/pecee-pixie
|
src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
|
QueryBuilderHandler.getColumns
|
public function getColumns(): array
{
$tSelects = isset($this->statements['selects']) === true ? $this->statements['selects'] : [];
$tColumns = [];
foreach ($tSelects as $key => $value) {
if (\is_string($value)) {
if (\is_int($key)) {
$tElements = explode('.', $value);
if (!\in_array('*', $tElements, true)) {
$tColumns[$tElements[1] ?? $tElements[0]] = $value;
}
} elseif (\is_string($key)) {
$tColumns[$value] = $key;
}
}
}
return $tColumns;
}
|
php
|
public function getColumns(): array
{
$tSelects = isset($this->statements['selects']) === true ? $this->statements['selects'] : [];
$tColumns = [];
foreach ($tSelects as $key => $value) {
if (\is_string($value)) {
if (\is_int($key)) {
$tElements = explode('.', $value);
if (!\in_array('*', $tElements, true)) {
$tColumns[$tElements[1] ?? $tElements[0]] = $value;
}
} elseif (\is_string($key)) {
$tColumns[$value] = $key;
}
}
}
return $tColumns;
}
|
[
"public",
"function",
"getColumns",
"(",
")",
":",
"array",
"{",
"$",
"tSelects",
"=",
"isset",
"(",
"$",
"this",
"->",
"statements",
"[",
"'selects'",
"]",
")",
"===",
"true",
"?",
"$",
"this",
"->",
"statements",
"[",
"'selects'",
"]",
":",
"[",
"]",
";",
"$",
"tColumns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tSelects",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"tElements",
"=",
"explode",
"(",
"'.'",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"'*'",
",",
"$",
"tElements",
",",
"true",
")",
")",
"{",
"$",
"tColumns",
"[",
"$",
"tElements",
"[",
"1",
"]",
"??",
"$",
"tElements",
"[",
"0",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"tColumns",
"[",
"$",
"value",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"$",
"tColumns",
";",
"}"
] |
Returns all columns in current query
@return array
|
[
"Returns",
"all",
"columns",
"in",
"current",
"query"
] |
9c66de8a19c5bec476f09f972b2350e58b01b1a2
|
https://github.com/skipperbent/pecee-pixie/blob/9c66de8a19c5bec476f09f972b2350e58b01b1a2/src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php#L1609-L1626
|
221,160
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/EmbedConverter.php
|
EmbedConverter.embedlyToHtml
|
public function embedlyToHtml()
{
if (filter_var($this->data['url'], FILTER_VALIDATE_URL)) {
return $this->view('embedly.'.$this->type, [
'url' => $this->data['url'],
'options' => $this->config['embedly'] ?? '',
]);
}
return '';
}
|
php
|
public function embedlyToHtml()
{
if (filter_var($this->data['url'], FILTER_VALIDATE_URL)) {
return $this->view('embedly.'.$this->type, [
'url' => $this->data['url'],
'options' => $this->config['embedly'] ?? '',
]);
}
return '';
}
|
[
"public",
"function",
"embedlyToHtml",
"(",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"this",
"->",
"data",
"[",
"'url'",
"]",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"(",
"'embedly.'",
".",
"$",
"this",
"->",
"type",
",",
"[",
"'url'",
"=>",
"$",
"this",
"->",
"data",
"[",
"'url'",
"]",
",",
"'options'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'embedly'",
"]",
"??",
"''",
",",
"]",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Render of embedly.
@return string
|
[
"Render",
"of",
"embedly",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/EmbedConverter.php#L66-L76
|
221,161
|
stein189/Simple-PHP-Router
|
src/Router.php
|
Router.add
|
public function add($url, $method, $action)
{
$route = $this->factory->create($url, $method, $action);
$this->routes[] = $route;
foreach ($route->getMethod() as $method) {
$this->routesByMethod[$method][] = $route;
}
}
|
php
|
public function add($url, $method, $action)
{
$route = $this->factory->create($url, $method, $action);
$this->routes[] = $route;
foreach ($route->getMethod() as $method) {
$this->routesByMethod[$method][] = $route;
}
}
|
[
"public",
"function",
"add",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"action",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"action",
")",
";",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"route",
";",
"foreach",
"(",
"$",
"route",
"->",
"getMethod",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"routesByMethod",
"[",
"$",
"method",
"]",
"[",
"]",
"=",
"$",
"route",
";",
"}",
"}"
] |
Add new route to routes array
@param string $url
@param string $method
@param mixed $action
@return void
|
[
"Add",
"new",
"route",
"to",
"routes",
"array"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/Router.php#L157-L166
|
221,162
|
stein189/Simple-PHP-Router
|
src/Router.php
|
Router.getRoutesByMethod
|
public function getRoutesByMethod($method)
{
return ($this->routesByMethod && isset($this->routesByMethod[$method])) ? $this->routesByMethod[$method] : array();
}
|
php
|
public function getRoutesByMethod($method)
{
return ($this->routesByMethod && isset($this->routesByMethod[$method])) ? $this->routesByMethod[$method] : array();
}
|
[
"public",
"function",
"getRoutesByMethod",
"(",
"$",
"method",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"routesByMethod",
"&&",
"isset",
"(",
"$",
"this",
"->",
"routesByMethod",
"[",
"$",
"method",
"]",
")",
")",
"?",
"$",
"this",
"->",
"routesByMethod",
"[",
"$",
"method",
"]",
":",
"array",
"(",
")",
";",
"}"
] |
Get routes by method
@param string $method
@return array
|
[
"Get",
"routes",
"by",
"method"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/Router.php#L175-L178
|
221,163
|
igdb/igdb-api-php
|
src/Client.php
|
Client.assertValidResource
|
private function assertValidResource($resource)
{
$resource = (string) $resource;
// All resources are basic ASCII, so we can ignore the fact that `strtolower` doesn't handle UTF-8 well.
$resource = strtolower($resource);
if (!in_array($resource, static::VALID_RESOURCES)) {
throw new InvalidResourceException($resource);
}
return $resource;
}
|
php
|
private function assertValidResource($resource)
{
$resource = (string) $resource;
// All resources are basic ASCII, so we can ignore the fact that `strtolower` doesn't handle UTF-8 well.
$resource = strtolower($resource);
if (!in_array($resource, static::VALID_RESOURCES)) {
throw new InvalidResourceException($resource);
}
return $resource;
}
|
[
"private",
"function",
"assertValidResource",
"(",
"$",
"resource",
")",
"{",
"$",
"resource",
"=",
"(",
"string",
")",
"$",
"resource",
";",
"// All resources are basic ASCII, so we can ignore the fact that `strtolower` doesn't handle UTF-8 well.",
"$",
"resource",
"=",
"strtolower",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"resource",
",",
"static",
"::",
"VALID_RESOURCES",
")",
")",
"{",
"throw",
"new",
"InvalidResourceException",
"(",
"$",
"resource",
")",
";",
"}",
"return",
"$",
"resource",
";",
"}"
] |
Ensure that a given resource name is valid.
@param string $resource The resource name to check.
@return string The sanitized resource name.
@throws InvalidResourceException Thrown if the requested resource is invalid.
|
[
"Ensure",
"that",
"a",
"given",
"resource",
"name",
"is",
"valid",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L106-L117
|
221,164
|
igdb/igdb-api-php
|
src/Client.php
|
Client.normalizeOffsetAndLimit
|
private function normalizeOffsetAndLimit($offset = 0, $limit = 25)
{
$offset = (int) $offset;
$limit = (int) $limit;
$offset = max($offset, 0);
$limit = min(max($limit, 0), 25);
return [$offset, $limit];
}
|
php
|
private function normalizeOffsetAndLimit($offset = 0, $limit = 25)
{
$offset = (int) $offset;
$limit = (int) $limit;
$offset = max($offset, 0);
$limit = min(max($limit, 0), 25);
return [$offset, $limit];
}
|
[
"private",
"function",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"$",
"offset",
"=",
"(",
"int",
")",
"$",
"offset",
";",
"$",
"limit",
"=",
"(",
"int",
")",
"$",
"limit",
";",
"$",
"offset",
"=",
"max",
"(",
"$",
"offset",
",",
"0",
")",
";",
"$",
"limit",
"=",
"min",
"(",
"max",
"(",
"$",
"limit",
",",
"0",
")",
",",
"25",
")",
";",
"return",
"[",
"$",
"offset",
",",
"$",
"limit",
"]",
";",
"}"
] |
Normalize the offset and limit parameters into valid formats.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return array The normalized offset and limit in the form [offset, limit].
|
[
"Normalize",
"the",
"offset",
"and",
"limit",
"parameters",
"into",
"valid",
"formats",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L196-L205
|
221,165
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getGames
|
public function getGames($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('games', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getGames($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('games', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getGames",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'games'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Retrieve a list of all games.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Retrieve",
"a",
"list",
"of",
"all",
"games",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L235-L243
|
221,166
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getGameById
|
public function getGameById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('games/'.$id);
}
|
php
|
public function getGameById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('games/'.$id);
}
|
[
"public",
"function",
"getGameById",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"id",
"=",
"max",
"(",
"0",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'games/'",
".",
"$",
"id",
")",
";",
"}"
] |
Get the details for a single game by its ID.
@param int $id The ID of the game.
@return string The response received from the API.
|
[
"Get",
"the",
"details",
"for",
"a",
"single",
"game",
"by",
"its",
"ID",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L264-L270
|
221,167
|
igdb/igdb-api-php
|
src/Client.php
|
Client.searchGames
|
public function searchGames($query, $parameters = [], $offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
$query = str_replace(' ', '-', $query);
$params = array_merge($this->buildFilterParameters($parameters), [
'q' => $query,
'offset' => $offset,
'limit' => $limit,
]);
return $this->request('games/search', $params);
}
|
php
|
public function searchGames($query, $parameters = [], $offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
$query = str_replace(' ', '-', $query);
$params = array_merge($this->buildFilterParameters($parameters), [
'q' => $query,
'offset' => $offset,
'limit' => $limit,
]);
return $this->request('games/search', $params);
}
|
[
"public",
"function",
"searchGames",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"' '",
",",
"'-'",
",",
"$",
"query",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"buildFilterParameters",
"(",
"$",
"parameters",
")",
",",
"[",
"'q'",
"=>",
"$",
"query",
",",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'games/search'",
",",
"$",
"params",
")",
";",
"}"
] |
Search for games based upon the given criteria.
@param string $query A query term to search the games with.
@param array $parameters A list of filter parameters to filter results with.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Search",
"for",
"games",
"based",
"upon",
"the",
"given",
"criteria",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L282-L295
|
221,168
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getCompanies
|
public function getCompanies($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('companies', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getCompanies($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('companies', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getCompanies",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'companies'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Retrieve a list of all companies.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Retrieve",
"a",
"list",
"of",
"all",
"companies",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L305-L313
|
221,169
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getCompanyById
|
public function getCompanyById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('companies/'.$id);
}
|
php
|
public function getCompanyById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('companies/'.$id);
}
|
[
"public",
"function",
"getCompanyById",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"id",
"=",
"max",
"(",
"0",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'companies/'",
".",
"$",
"id",
")",
";",
"}"
] |
Get the details for a single company by its ID.
@param int $id The ID of the company.
@return string The response received from the API.
|
[
"Get",
"the",
"details",
"for",
"a",
"single",
"company",
"by",
"its",
"ID",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L332-L338
|
221,170
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getGamesByCompany
|
public function getGamesByCompany($id, $offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
$id = (int) $id;
$id = max(0, $id);
return $this->request('companies/'.$id.'/games', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getGamesByCompany($id, $offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
$id = (int) $id;
$id = max(0, $id);
return $this->request('companies/'.$id.'/games', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getGamesByCompany",
"(",
"$",
"id",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"id",
"=",
"max",
"(",
"0",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'companies/'",
".",
"$",
"id",
".",
"'/games'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Get all the games for a specific company.
@param int $id The ID of the company.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string
|
[
"Get",
"all",
"the",
"games",
"for",
"a",
"specific",
"company",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L349-L360
|
221,171
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getPeople
|
public function getPeople($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('people', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getPeople($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('people', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getPeople",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'people'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Retrieve a list of all people.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Retrieve",
"a",
"list",
"of",
"all",
"people",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L370-L378
|
221,172
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getPersonById
|
public function getPersonById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('people/'.$id);
}
|
php
|
public function getPersonById($id)
{
$id = (int) $id;
$id = max(0, $id);
return $this->request('people/'.$id);
}
|
[
"public",
"function",
"getPersonById",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"id",
"=",
"max",
"(",
"0",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'people/'",
".",
"$",
"id",
")",
";",
"}"
] |
Get the details for a single person by its ID.
@param int $id The ID of the person.
@return string The response received from the API.
|
[
"Get",
"the",
"details",
"for",
"a",
"single",
"person",
"by",
"its",
"ID",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L397-L403
|
221,173
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getFranchises
|
public function getFranchises($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('franchises', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getFranchises($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('franchises', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getFranchises",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'franchises'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Retrieve a list of all franchises.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Retrieve",
"a",
"list",
"of",
"all",
"franchises",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L435-L443
|
221,174
|
igdb/igdb-api-php
|
src/Client.php
|
Client.getPlatforms
|
public function getPlatforms($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('platforms', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
php
|
public function getPlatforms($offset = 0, $limit = 25)
{
list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);
return $this->request('platforms', [
'offset' => $offset,
'limit' => $limit,
]);
}
|
[
"public",
"function",
"getPlatforms",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"this",
"->",
"normalizeOffsetAndLimit",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'platforms'",
",",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
")",
";",
"}"
] |
Retrieve a list of all platforms.
@param int $offset The offset to start at.
@param int $limit The maximum number of items to include.
@return string The response received from the API.
|
[
"Retrieve",
"a",
"list",
"of",
"all",
"platforms",
"."
] |
418f6cf895b6223942dc22a4d72bf69f4c34bc6b
|
https://github.com/igdb/igdb-api-php/blob/418f6cf895b6223942dc22a4d72bf69f4c34bc6b/src/Client.php#L500-L508
|
221,175
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/MeetupKeyAuthClient.php
|
MeetupKeyAuthClient.factory
|
public static function factory($config = array())
{
$configuration = static::buildConfig($config);
$client = new self($configuration->get('base_url'), $configuration);
$client->addSubscriber(new KeyAuthPlugin($configuration->get('key')));
static::loadDefinitions($client);
static::toggleRateLimitingPlugin($client, $config);
return $client;
}
|
php
|
public static function factory($config = array())
{
$configuration = static::buildConfig($config);
$client = new self($configuration->get('base_url'), $configuration);
$client->addSubscriber(new KeyAuthPlugin($configuration->get('key')));
static::loadDefinitions($client);
static::toggleRateLimitingPlugin($client, $config);
return $client;
}
|
[
"public",
"static",
"function",
"factory",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"configuration",
"=",
"static",
"::",
"buildConfig",
"(",
"$",
"config",
")",
";",
"$",
"client",
"=",
"new",
"self",
"(",
"$",
"configuration",
"->",
"get",
"(",
"'base_url'",
")",
",",
"$",
"configuration",
")",
";",
"$",
"client",
"->",
"addSubscriber",
"(",
"new",
"KeyAuthPlugin",
"(",
"$",
"configuration",
"->",
"get",
"(",
"'key'",
")",
")",
")",
";",
"static",
"::",
"loadDefinitions",
"(",
"$",
"client",
")",
";",
"static",
"::",
"toggleRateLimitingPlugin",
"(",
"$",
"client",
",",
"$",
"config",
")",
";",
"return",
"$",
"client",
";",
"}"
] |
Factory Method to build new Client.
@param array $config
@return MeetupKeyAuthClient
|
[
"Factory",
"Method",
"to",
"build",
"new",
"Client",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/MeetupKeyAuthClient.php#L46-L58
|
221,176
|
pepijnolivier/Eloquent-Model-Generator
|
src/Console/GenerateModelsCommand.php
|
GenerateModelsCommand.detectManyToMany
|
private function detectManyToMany($prep, $table)
{
$properties = $prep[$table];
$foreignKeys = $properties['foreign'];
$primaryKeys = $properties['primary'];
//ensure we only have two foreign keys
if (count($foreignKeys) === 2) {
//ensure our foreign keys are not also defined as primary keys
$primaryKeyCountThatAreAlsoForeignKeys = 0;
foreach ($foreignKeys as $foreign) {
foreach ($primaryKeys as $primary) {
if ($primary === $foreign['name']) {
++$primaryKeyCountThatAreAlsoForeignKeys;
}
}
}
if ($primaryKeyCountThatAreAlsoForeignKeys === 1) {
//one of the keys foreign keys was also a primary key
//this is not a many to many. (many to many is only possible when both or none of the foreign keys are also primary)
return false;
}
//ensure no other tables refer to this one
foreach ($prep as $compareTable => $properties) {
if ($table !== $compareTable) {
foreach ($properties['foreign'] as $prop) {
if ($prop['on'] === $table) {
return false;
}
}
}
}
//this is a many to many table!
return true;
}
return false;
}
|
php
|
private function detectManyToMany($prep, $table)
{
$properties = $prep[$table];
$foreignKeys = $properties['foreign'];
$primaryKeys = $properties['primary'];
//ensure we only have two foreign keys
if (count($foreignKeys) === 2) {
//ensure our foreign keys are not also defined as primary keys
$primaryKeyCountThatAreAlsoForeignKeys = 0;
foreach ($foreignKeys as $foreign) {
foreach ($primaryKeys as $primary) {
if ($primary === $foreign['name']) {
++$primaryKeyCountThatAreAlsoForeignKeys;
}
}
}
if ($primaryKeyCountThatAreAlsoForeignKeys === 1) {
//one of the keys foreign keys was also a primary key
//this is not a many to many. (many to many is only possible when both or none of the foreign keys are also primary)
return false;
}
//ensure no other tables refer to this one
foreach ($prep as $compareTable => $properties) {
if ($table !== $compareTable) {
foreach ($properties['foreign'] as $prop) {
if ($prop['on'] === $table) {
return false;
}
}
}
}
//this is a many to many table!
return true;
}
return false;
}
|
[
"private",
"function",
"detectManyToMany",
"(",
"$",
"prep",
",",
"$",
"table",
")",
"{",
"$",
"properties",
"=",
"$",
"prep",
"[",
"$",
"table",
"]",
";",
"$",
"foreignKeys",
"=",
"$",
"properties",
"[",
"'foreign'",
"]",
";",
"$",
"primaryKeys",
"=",
"$",
"properties",
"[",
"'primary'",
"]",
";",
"//ensure we only have two foreign keys",
"if",
"(",
"count",
"(",
"$",
"foreignKeys",
")",
"===",
"2",
")",
"{",
"//ensure our foreign keys are not also defined as primary keys",
"$",
"primaryKeyCountThatAreAlsoForeignKeys",
"=",
"0",
";",
"foreach",
"(",
"$",
"foreignKeys",
"as",
"$",
"foreign",
")",
"{",
"foreach",
"(",
"$",
"primaryKeys",
"as",
"$",
"primary",
")",
"{",
"if",
"(",
"$",
"primary",
"===",
"$",
"foreign",
"[",
"'name'",
"]",
")",
"{",
"++",
"$",
"primaryKeyCountThatAreAlsoForeignKeys",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"primaryKeyCountThatAreAlsoForeignKeys",
"===",
"1",
")",
"{",
"//one of the keys foreign keys was also a primary key",
"//this is not a many to many. (many to many is only possible when both or none of the foreign keys are also primary)",
"return",
"false",
";",
"}",
"//ensure no other tables refer to this one",
"foreach",
"(",
"$",
"prep",
"as",
"$",
"compareTable",
"=>",
"$",
"properties",
")",
"{",
"if",
"(",
"$",
"table",
"!==",
"$",
"compareTable",
")",
"{",
"foreach",
"(",
"$",
"properties",
"[",
"'foreign'",
"]",
"as",
"$",
"prop",
")",
"{",
"if",
"(",
"$",
"prop",
"[",
"'on'",
"]",
"===",
"$",
"table",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"//this is a many to many table!",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
and no tables in the database refer to this table?
|
[
"and",
"no",
"tables",
"in",
"the",
"database",
"refer",
"to",
"this",
"table?"
] |
a9930e07d7e74d47096d3615f868e66f6e1cd78f
|
https://github.com/pepijnolivier/Eloquent-Model-Generator/blob/a9930e07d7e74d47096d3615f868e66f6e1cd78f/src/Console/GenerateModelsCommand.php#L510-L550
|
221,177
|
caouecs/Laravel-SirTrevorJS
|
src/Caouecs/Sirtrevorjs/Converter/BaseConverter.php
|
BaseConverter.view
|
public function view(string $viewName, array $params = [], string $type = '')
{
if (empty($type)) {
$type = $this->type;
}
$jsExternal = $this->getJsExternal();
if (!empty($jsExternal[$this->output][$type])) {
$this->codejs[$type] = $jsExternal[$this->output][$type];
}
if (!empty($this->view) && View::exists($this->view.'.'.$viewName)) {
return view($this->view.'.'.$viewName, $params);
} elseif (isset($this->config['view']) && View::exists($this->config['view'].'.'.$viewName)) {
return view($this->config['view'].'.'.$viewName, $params);
}
return view('sirtrevorjs::html.'.$viewName, $params);
}
|
php
|
public function view(string $viewName, array $params = [], string $type = '')
{
if (empty($type)) {
$type = $this->type;
}
$jsExternal = $this->getJsExternal();
if (!empty($jsExternal[$this->output][$type])) {
$this->codejs[$type] = $jsExternal[$this->output][$type];
}
if (!empty($this->view) && View::exists($this->view.'.'.$viewName)) {
return view($this->view.'.'.$viewName, $params);
} elseif (isset($this->config['view']) && View::exists($this->config['view'].'.'.$viewName)) {
return view($this->config['view'].'.'.$viewName, $params);
}
return view('sirtrevorjs::html.'.$viewName, $params);
}
|
[
"public",
"function",
"view",
"(",
"string",
"$",
"viewName",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"string",
"$",
"type",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"type",
";",
"}",
"$",
"jsExternal",
"=",
"$",
"this",
"->",
"getJsExternal",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"jsExternal",
"[",
"$",
"this",
"->",
"output",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"codejs",
"[",
"$",
"type",
"]",
"=",
"$",
"jsExternal",
"[",
"$",
"this",
"->",
"output",
"]",
"[",
"$",
"type",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
"&&",
"View",
"::",
"exists",
"(",
"$",
"this",
"->",
"view",
".",
"'.'",
".",
"$",
"viewName",
")",
")",
"{",
"return",
"view",
"(",
"$",
"this",
"->",
"view",
".",
"'.'",
".",
"$",
"viewName",
",",
"$",
"params",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'view'",
"]",
")",
"&&",
"View",
"::",
"exists",
"(",
"$",
"this",
"->",
"config",
"[",
"'view'",
"]",
".",
"'.'",
".",
"$",
"viewName",
")",
")",
"{",
"return",
"view",
"(",
"$",
"this",
"->",
"config",
"[",
"'view'",
"]",
".",
"'.'",
".",
"$",
"viewName",
",",
"$",
"params",
")",
";",
"}",
"return",
"view",
"(",
"'sirtrevorjs::html.'",
".",
"$",
"viewName",
",",
"$",
"params",
")",
";",
"}"
] |
Personalized views.
@param string $viewName Name of the base view
@param array $params Params
@param string $type Block type
|
[
"Personalized",
"views",
"."
] |
a514c8115d4f28f7e608c44315eae3b93530c688
|
https://github.com/caouecs/Laravel-SirTrevorJS/blob/a514c8115d4f28f7e608c44315eae3b93530c688/src/Caouecs/Sirtrevorjs/Converter/BaseConverter.php#L125-L143
|
221,178
|
stein189/Simple-PHP-Router
|
src/RouteResolver.php
|
RouteResolver.resolve
|
public function resolve(Router $router, $uri, $method)
{
// get all register routes with the same request method
$routes = $router->getRoutesByMethod($method);
// remove trailing and leading slash
$requestedUri = trim(preg_replace('/\?.*/', '', $uri), '/');
// loop trough the posible routes
foreach ($routes as $route) {
$matches = array();
// if the requested route matches one of the defined routes
if ($route->getUrl() === $requestedUri || preg_match('~^'.$route->getUrl().'$~', $requestedUri, $matches)) {
$argumentArray = array();
$arguments = $this->getArguments($matches);
// check if there route has arguments
if (is_array($route->getArguments()) && count($route->getArguments()) > 0) {
// loop trough all the arguments
foreach ($route->getArguments() as $key => $argument) {
// if the argument exists set the value
if (isset($arguments[$key])) {
$argumentArray[$argument] = $arguments[$key];
} else {
// setting the value to null should only occure when we use an optional parameter
$argumentArray[$argument] = null;
}
}
}
return [
'code' => Route::STATUS_FOUND,
'handler' => $route->getAction(),
'arguments' => $argumentArray
];
}
}
return [
'code' => Route::STATUS_NOT_FOUND,
'handler' => null,
'arguments' => []
];
}
|
php
|
public function resolve(Router $router, $uri, $method)
{
// get all register routes with the same request method
$routes = $router->getRoutesByMethod($method);
// remove trailing and leading slash
$requestedUri = trim(preg_replace('/\?.*/', '', $uri), '/');
// loop trough the posible routes
foreach ($routes as $route) {
$matches = array();
// if the requested route matches one of the defined routes
if ($route->getUrl() === $requestedUri || preg_match('~^'.$route->getUrl().'$~', $requestedUri, $matches)) {
$argumentArray = array();
$arguments = $this->getArguments($matches);
// check if there route has arguments
if (is_array($route->getArguments()) && count($route->getArguments()) > 0) {
// loop trough all the arguments
foreach ($route->getArguments() as $key => $argument) {
// if the argument exists set the value
if (isset($arguments[$key])) {
$argumentArray[$argument] = $arguments[$key];
} else {
// setting the value to null should only occure when we use an optional parameter
$argumentArray[$argument] = null;
}
}
}
return [
'code' => Route::STATUS_FOUND,
'handler' => $route->getAction(),
'arguments' => $argumentArray
];
}
}
return [
'code' => Route::STATUS_NOT_FOUND,
'handler' => null,
'arguments' => []
];
}
|
[
"public",
"function",
"resolve",
"(",
"Router",
"$",
"router",
",",
"$",
"uri",
",",
"$",
"method",
")",
"{",
"// get all register routes with the same request method",
"$",
"routes",
"=",
"$",
"router",
"->",
"getRoutesByMethod",
"(",
"$",
"method",
")",
";",
"// remove trailing and leading slash",
"$",
"requestedUri",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/\\?.*/'",
",",
"''",
",",
"$",
"uri",
")",
",",
"'/'",
")",
";",
"// loop trough the posible routes",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"// if the requested route matches one of the defined routes",
"if",
"(",
"$",
"route",
"->",
"getUrl",
"(",
")",
"===",
"$",
"requestedUri",
"||",
"preg_match",
"(",
"'~^'",
".",
"$",
"route",
"->",
"getUrl",
"(",
")",
".",
"'$~'",
",",
"$",
"requestedUri",
",",
"$",
"matches",
")",
")",
"{",
"$",
"argumentArray",
"=",
"array",
"(",
")",
";",
"$",
"arguments",
"=",
"$",
"this",
"->",
"getArguments",
"(",
"$",
"matches",
")",
";",
"// check if there route has arguments",
"if",
"(",
"is_array",
"(",
"$",
"route",
"->",
"getArguments",
"(",
")",
")",
"&&",
"count",
"(",
"$",
"route",
"->",
"getArguments",
"(",
")",
")",
">",
"0",
")",
"{",
"// loop trough all the arguments",
"foreach",
"(",
"$",
"route",
"->",
"getArguments",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"argument",
")",
"{",
"// if the argument exists set the value",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"argumentArray",
"[",
"$",
"argument",
"]",
"=",
"$",
"arguments",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"// setting the value to null should only occure when we use an optional parameter",
"$",
"argumentArray",
"[",
"$",
"argument",
"]",
"=",
"null",
";",
"}",
"}",
"}",
"return",
"[",
"'code'",
"=>",
"Route",
"::",
"STATUS_FOUND",
",",
"'handler'",
"=>",
"$",
"route",
"->",
"getAction",
"(",
")",
",",
"'arguments'",
"=>",
"$",
"argumentArray",
"]",
";",
"}",
"}",
"return",
"[",
"'code'",
"=>",
"Route",
"::",
"STATUS_NOT_FOUND",
",",
"'handler'",
"=>",
"null",
",",
"'arguments'",
"=>",
"[",
"]",
"]",
";",
"}"
] |
Resolve the given url and call the method that belongs to the route
@param Router $router
@param string $uri
@param string $method
@return array
|
[
"Resolve",
"the",
"given",
"url",
"and",
"call",
"the",
"method",
"that",
"belongs",
"to",
"the",
"route"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/RouteResolver.php#L30-L72
|
221,179
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/ValueObject/Operation.php
|
Operation.addStandardParameters
|
protected function addStandardParameters($httpMethod)
{
if ($httpMethod != 'GET') {
return;
}
$this->addParameter('page', 'query', false);
$this->addParameter('offset', 'query', false);
$this->addParameter('desc', 'query', false);
$this->addParameter('order', 'query', false);
$this->addParameter('only', 'query', false);
$this->addParameter('omit', 'query', false);
}
|
php
|
protected function addStandardParameters($httpMethod)
{
if ($httpMethod != 'GET') {
return;
}
$this->addParameter('page', 'query', false);
$this->addParameter('offset', 'query', false);
$this->addParameter('desc', 'query', false);
$this->addParameter('order', 'query', false);
$this->addParameter('only', 'query', false);
$this->addParameter('omit', 'query', false);
}
|
[
"protected",
"function",
"addStandardParameters",
"(",
"$",
"httpMethod",
")",
"{",
"if",
"(",
"$",
"httpMethod",
"!=",
"'GET'",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"addParameter",
"(",
"'page'",
",",
"'query'",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"'offset'",
",",
"'query'",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"'desc'",
",",
"'query'",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"'order'",
",",
"'query'",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"'only'",
",",
"'query'",
",",
"false",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"'omit'",
",",
"'query'",
",",
"false",
")",
";",
"}"
] |
Add default parameters.
@param string $httpMethod
|
[
"Add",
"default",
"parameters",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/ValueObject/Operation.php#L91-L103
|
221,180
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/ValueObject/Operation.php
|
Operation.parsePath
|
protected function parsePath($path)
{
$uriParams = array();
$uriParamsCount = preg_match_all("/(:[^\/]*)/", $path, $uriParams);
$translateParams = array();
foreach ($uriParams[0] as $rawParam) {
$param = str_replace(':', '', $rawParam);
$this->addParameter($param, 'uri', true);
$translateParams[$rawParam] = '{'.$param.'}';
}
$this->uri = strtr($path, $translateParams);
}
|
php
|
protected function parsePath($path)
{
$uriParams = array();
$uriParamsCount = preg_match_all("/(:[^\/]*)/", $path, $uriParams);
$translateParams = array();
foreach ($uriParams[0] as $rawParam) {
$param = str_replace(':', '', $rawParam);
$this->addParameter($param, 'uri', true);
$translateParams[$rawParam] = '{'.$param.'}';
}
$this->uri = strtr($path, $translateParams);
}
|
[
"protected",
"function",
"parsePath",
"(",
"$",
"path",
")",
"{",
"$",
"uriParams",
"=",
"array",
"(",
")",
";",
"$",
"uriParamsCount",
"=",
"preg_match_all",
"(",
"\"/(:[^\\/]*)/\"",
",",
"$",
"path",
",",
"$",
"uriParams",
")",
";",
"$",
"translateParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"uriParams",
"[",
"0",
"]",
"as",
"$",
"rawParam",
")",
"{",
"$",
"param",
"=",
"str_replace",
"(",
"':'",
",",
"''",
",",
"$",
"rawParam",
")",
";",
"$",
"this",
"->",
"addParameter",
"(",
"$",
"param",
",",
"'uri'",
",",
"true",
")",
";",
"$",
"translateParams",
"[",
"$",
"rawParam",
"]",
"=",
"'{'",
".",
"$",
"param",
".",
"'}'",
";",
"}",
"$",
"this",
"->",
"uri",
"=",
"strtr",
"(",
"$",
"path",
",",
"$",
"translateParams",
")",
";",
"}"
] |
Parse Parameters from Path.
@param string $path
|
[
"Parse",
"Parameters",
"from",
"Path",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/ValueObject/Operation.php#L110-L124
|
221,181
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/ValueObject/Operation.php
|
Operation.addParameter
|
protected function addParameter($name, $location, $required, $description = null)
{
$name = trim($name);
if (strpos($name, ',') !== false) {
foreach (explode(',', $name) as $subname) {
$this->addParameter($subname, $location, $required, $description);
}
return;
}
$this->parameters[$name] = Parameter::build($location, $required, $description);
}
|
php
|
protected function addParameter($name, $location, $required, $description = null)
{
$name = trim($name);
if (strpos($name, ',') !== false) {
foreach (explode(',', $name) as $subname) {
$this->addParameter($subname, $location, $required, $description);
}
return;
}
$this->parameters[$name] = Parameter::build($location, $required, $description);
}
|
[
"protected",
"function",
"addParameter",
"(",
"$",
"name",
",",
"$",
"location",
",",
"$",
"required",
",",
"$",
"description",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"','",
")",
"!==",
"false",
")",
"{",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"name",
")",
"as",
"$",
"subname",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"$",
"subname",
",",
"$",
"location",
",",
"$",
"required",
",",
"$",
"description",
")",
";",
"}",
"return",
";",
"}",
"$",
"this",
"->",
"parameters",
"[",
"$",
"name",
"]",
"=",
"Parameter",
"::",
"build",
"(",
"$",
"location",
",",
"$",
"required",
",",
"$",
"description",
")",
";",
"}"
] |
Add a new parameter to definition.
@param string $name
@param string $location
@param bool $required
@param string|null $description
|
[
"Add",
"a",
"new",
"parameter",
"to",
"definition",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/ValueObject/Operation.php#L134-L147
|
221,182
|
rdohms/meetup-api-client
|
src/DMS/Tools/Meetup/Command/GenerateJsonDefinitionsCommand.php
|
GenerateJsonDefinitionsCommand.parseDocumentationPage
|
protected function parseDocumentationPage($file)
{
try {
/** @var $file SplFileInfo */
if ($file->getExtension() !== 'html') {
throw new \OutOfBoundsException('Not HTML.');
}
$crawler = new Crawler(file_get_contents($file->getRealPath()));
// Check is Doc page
if ($crawler->filter('#method-info')->count() == 0) {
throw new \OutOfBoundsException('Not Documentation File.');
}
// Check if is not deprecated
if ($crawler->filter('.deprecation-warning')->count() > 0) {
throw new \OutOfBoundsException('Deprecated.');
}
$this->output->writeln('Parsing: '.$file->getPathname());
$this->getMethodDefinitions($crawler);
} catch (\OutOfBoundsException $e) {
$this->output->writeln(
sprintf(
'<error>SKIPPED:</error> <info>%s</info> because <info>%s</info>',
$file->getPathname(),
$e->getMessage()
)
);
} catch (InvalidArgumentException $e) {
$this->output->writeln(
sprintf(
'<error>ERROR:</error> <info>%s</info> with <info>%s</info> at line %d',
$file->getPathname(),
$e->getMessage(),
$e->getLine()
)
);
} catch (Exception $e) {
$this->output->writeln(
sprintf(
'<error>ERROR:</error> <info>%s</info> with <info>%s</info>',
$file->getPathname(),
$e->getMessage()
)
);
}
}
|
php
|
protected function parseDocumentationPage($file)
{
try {
/** @var $file SplFileInfo */
if ($file->getExtension() !== 'html') {
throw new \OutOfBoundsException('Not HTML.');
}
$crawler = new Crawler(file_get_contents($file->getRealPath()));
// Check is Doc page
if ($crawler->filter('#method-info')->count() == 0) {
throw new \OutOfBoundsException('Not Documentation File.');
}
// Check if is not deprecated
if ($crawler->filter('.deprecation-warning')->count() > 0) {
throw new \OutOfBoundsException('Deprecated.');
}
$this->output->writeln('Parsing: '.$file->getPathname());
$this->getMethodDefinitions($crawler);
} catch (\OutOfBoundsException $e) {
$this->output->writeln(
sprintf(
'<error>SKIPPED:</error> <info>%s</info> because <info>%s</info>',
$file->getPathname(),
$e->getMessage()
)
);
} catch (InvalidArgumentException $e) {
$this->output->writeln(
sprintf(
'<error>ERROR:</error> <info>%s</info> with <info>%s</info> at line %d',
$file->getPathname(),
$e->getMessage(),
$e->getLine()
)
);
} catch (Exception $e) {
$this->output->writeln(
sprintf(
'<error>ERROR:</error> <info>%s</info> with <info>%s</info>',
$file->getPathname(),
$e->getMessage()
)
);
}
}
|
[
"protected",
"function",
"parseDocumentationPage",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"/** @var $file SplFileInfo */",
"if",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
"!==",
"'html'",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Not HTML.'",
")",
";",
"}",
"$",
"crawler",
"=",
"new",
"Crawler",
"(",
"file_get_contents",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
")",
";",
"// Check is Doc page",
"if",
"(",
"$",
"crawler",
"->",
"filter",
"(",
"'#method-info'",
")",
"->",
"count",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Not Documentation File.'",
")",
";",
"}",
"// Check if is not deprecated",
"if",
"(",
"$",
"crawler",
"->",
"filter",
"(",
"'.deprecation-warning'",
")",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Deprecated.'",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'Parsing: '",
".",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"$",
"this",
"->",
"getMethodDefinitions",
"(",
"$",
"crawler",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<error>SKIPPED:</error> <info>%s</info> because <info>%s</info>'",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<error>ERROR:</error> <info>%s</info> with <info>%s</info> at line %d'",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getLine",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<error>ERROR:</error> <info>%s</info> with <info>%s</info>'",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Parses Documentation Page.
@param $file
@throws \OutOfBoundsException
|
[
"Parses",
"Documentation",
"Page",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Tools/Meetup/Command/GenerateJsonDefinitionsCommand.php#L104-L153
|
221,183
|
stein189/Simple-PHP-Router
|
src/Route.php
|
Route.setMethod
|
public function setMethod($method)
{
if ($method === null || !is_array($method) || empty($method)) {
throw new InvalidArgumentException('No method provided');
}
foreach ($method as $m) {
if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
}
}
$this->method = $method;
return $this;
}
|
php
|
public function setMethod($method)
{
if ($method === null || !is_array($method) || empty($method)) {
throw new InvalidArgumentException('No method provided');
}
foreach ($method as $m) {
if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
}
}
$this->method = $method;
return $this;
}
|
[
"public",
"function",
"setMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"null",
"||",
"!",
"is_array",
"(",
"$",
"method",
")",
"||",
"empty",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No method provided'",
")",
";",
"}",
"foreach",
"(",
"$",
"method",
"as",
"$",
"m",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"m",
",",
"array",
"(",
"'GET'",
",",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
",",
"'DELETE'",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the method of the current route
@param array $method
@return $this
|
[
"Set",
"the",
"method",
"of",
"the",
"current",
"route"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/Route.php#L84-L99
|
221,184
|
stein189/Simple-PHP-Router
|
src/RouteFactory.php
|
RouteFactory.create
|
public function create($url, $method, $action)
{
return new Route(
$this->parseUrl($url),
$this->parseArguments($url),
$this->parseMethod($method),
$action
);
}
|
php
|
public function create($url, $method, $action)
{
return new Route(
$this->parseUrl($url),
$this->parseArguments($url),
$this->parseMethod($method),
$action
);
}
|
[
"public",
"function",
"create",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"action",
")",
"{",
"return",
"new",
"Route",
"(",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"url",
")",
",",
"$",
"this",
"->",
"parseArguments",
"(",
"$",
"url",
")",
",",
"$",
"this",
"->",
"parseMethod",
"(",
"$",
"method",
")",
",",
"$",
"action",
")",
";",
"}"
] |
Create new route
@param string $url
@param string $method
@param string $action
@return RouteInterface
|
[
"Create",
"new",
"route"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/RouteFactory.php#L62-L70
|
221,185
|
stein189/Simple-PHP-Router
|
src/RouteFactory.php
|
RouteFactory.parseUrl
|
private function parseUrl($url)
{
$newUrl = preg_replace($this->patterns, $this->replacements, $url);
$newUrl = trim($newUrl, '\/?');
$newUrl = trim($newUrl, '\/');
return $newUrl;
}
|
php
|
private function parseUrl($url)
{
$newUrl = preg_replace($this->patterns, $this->replacements, $url);
$newUrl = trim($newUrl, '\/?');
$newUrl = trim($newUrl, '\/');
return $newUrl;
}
|
[
"private",
"function",
"parseUrl",
"(",
"$",
"url",
")",
"{",
"$",
"newUrl",
"=",
"preg_replace",
"(",
"$",
"this",
"->",
"patterns",
",",
"$",
"this",
"->",
"replacements",
",",
"$",
"url",
")",
";",
"$",
"newUrl",
"=",
"trim",
"(",
"$",
"newUrl",
",",
"'\\/?'",
")",
";",
"$",
"newUrl",
"=",
"trim",
"(",
"$",
"newUrl",
",",
"'\\/'",
")",
";",
"return",
"$",
"newUrl",
";",
"}"
] |
Parse url into a regex url
@param string $url
@return string
|
[
"Parse",
"url",
"into",
"a",
"regex",
"url"
] |
292d2202f95bdd6c4cdc7d91ef6057614806d2f1
|
https://github.com/stein189/Simple-PHP-Router/blob/292d2202f95bdd6c4cdc7d91ef6057614806d2f1/src/RouteFactory.php#L79-L86
|
221,186
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Command/MeetupResponseParser.php
|
MeetupResponseParser.createMultiResultResponse
|
protected function createMultiResultResponse($response)
{
$response = new MultiResultResponse($response->getStatusCode(), $response->getHeaders(), $response->getBody());
return $response;
}
|
php
|
protected function createMultiResultResponse($response)
{
$response = new MultiResultResponse($response->getStatusCode(), $response->getHeaders(), $response->getBody());
return $response;
}
|
[
"protected",
"function",
"createMultiResultResponse",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"new",
"MultiResultResponse",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"response",
"->",
"getHeaders",
"(",
")",
",",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Create a Multi-Response Object.
@param Response $response
@return \DMS\Service\Meetup\Response\MultiResultResponse
|
[
"Create",
"a",
"Multi",
"-",
"Response",
"Object",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Command/MeetupResponseParser.php#L61-L66
|
221,187
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Command/MeetupResponseParser.php
|
MeetupResponseParser.parseResponseIntoArray
|
protected function parseResponseIntoArray($response)
{
if (!$response->isContentType('json')) {
parse_str($response->getBody(true), $array);
return $array;
}
return $response->json();
}
|
php
|
protected function parseResponseIntoArray($response)
{
if (!$response->isContentType('json')) {
parse_str($response->getBody(true), $array);
return $array;
}
return $response->json();
}
|
[
"protected",
"function",
"parseResponseIntoArray",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"response",
"->",
"isContentType",
"(",
"'json'",
")",
")",
"{",
"parse_str",
"(",
"$",
"response",
"->",
"getBody",
"(",
"true",
")",
",",
"$",
"array",
")",
";",
"return",
"$",
"array",
";",
"}",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] |
Parses response into an array.
@param Response $response
@return array
|
[
"Parses",
"response",
"into",
"an",
"array",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Command/MeetupResponseParser.php#L87-L96
|
221,188
|
charliedevelopment/craft3-section-field
|
src/fields/SectionField.php
|
SectionField.validateSectionWhitelist
|
public function validateSectionWhitelist(string $attribute) {
$sections = $this->getSections();
foreach ($this->whitelistedSections as $section) {
if (!isset($sections[$section])) {
$this->addError($attribute, Craft::t('section-field', 'Invalid section selected.'));
}
}
}
|
php
|
public function validateSectionWhitelist(string $attribute) {
$sections = $this->getSections();
foreach ($this->whitelistedSections as $section) {
if (!isset($sections[$section])) {
$this->addError($attribute, Craft::t('section-field', 'Invalid section selected.'));
}
}
}
|
[
"public",
"function",
"validateSectionWhitelist",
"(",
"string",
"$",
"attribute",
")",
"{",
"$",
"sections",
"=",
"$",
"this",
"->",
"getSections",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"whitelistedSections",
"as",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"sections",
"[",
"$",
"section",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"Craft",
"::",
"t",
"(",
"'section-field'",
",",
"'Invalid section selected.'",
")",
")",
";",
"}",
"}",
"}"
] |
Ensures the section IDs selected for the whitelist are for valid sections.
@param string $attribute The name of the attribute being validated.
@return void
|
[
"Ensures",
"the",
"section",
"IDs",
"selected",
"for",
"the",
"whitelist",
"are",
"for",
"valid",
"sections",
"."
] |
4c57a7a1cd69105453d9e188b8b64fe83409064e
|
https://github.com/charliedevelopment/craft3-section-field/blob/4c57a7a1cd69105453d9e188b8b64fe83409064e/src/fields/SectionField.php#L94-L103
|
221,189
|
charliedevelopment/craft3-section-field
|
src/fields/SectionField.php
|
SectionField.validateSections
|
public function validateSections(ElementInterface $element)
{
$value = $element->getFieldValue($this->handle);
if (!is_array($value)) {
$value = [$value];
}
$sections = $this->getSections();
foreach ($value as $section) {
if (!isset($sections[$section])) {
$element->addError($this->handle, Craft::t('section-field', 'Invalid section selected.'));
}
}
}
|
php
|
public function validateSections(ElementInterface $element)
{
$value = $element->getFieldValue($this->handle);
if (!is_array($value)) {
$value = [$value];
}
$sections = $this->getSections();
foreach ($value as $section) {
if (!isset($sections[$section])) {
$element->addError($this->handle, Craft::t('section-field', 'Invalid section selected.'));
}
}
}
|
[
"public",
"function",
"validateSections",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"value",
"=",
"$",
"element",
"->",
"getFieldValue",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"$",
"sections",
"=",
"$",
"this",
"->",
"getSections",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"sections",
"[",
"$",
"section",
"]",
")",
")",
"{",
"$",
"element",
"->",
"addError",
"(",
"$",
"this",
"->",
"handle",
",",
"Craft",
"::",
"t",
"(",
"'section-field'",
",",
"'Invalid section selected.'",
")",
")",
";",
"}",
"}",
"}"
] |
Ensures the section IDs selected are available to the current user.
@param ElementInterface $element The element with the value being validated.
@return void
|
[
"Ensures",
"the",
"section",
"IDs",
"selected",
"are",
"available",
"to",
"the",
"current",
"user",
"."
] |
4c57a7a1cd69105453d9e188b8b64fe83409064e
|
https://github.com/charliedevelopment/craft3-section-field/blob/4c57a7a1cd69105453d9e188b8b64fe83409064e/src/fields/SectionField.php#L144-L159
|
221,190
|
charliedevelopment/craft3-section-field
|
src/fields/SectionField.php
|
SectionField.getSections
|
private function getSections() {
$sections = array();
foreach (Craft::$app->getSections()->getEditableSections() as $section) {
$sections[$section->id] = Craft::t('site', $section->name);
}
return $sections;
}
|
php
|
private function getSections() {
$sections = array();
foreach (Craft::$app->getSections()->getEditableSections() as $section) {
$sections[$section->id] = Craft::t('site', $section->name);
}
return $sections;
}
|
[
"private",
"function",
"getSections",
"(",
")",
"{",
"$",
"sections",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Craft",
"::",
"$",
"app",
"->",
"getSections",
"(",
")",
"->",
"getEditableSections",
"(",
")",
"as",
"$",
"section",
")",
"{",
"$",
"sections",
"[",
"$",
"section",
"->",
"id",
"]",
"=",
"Craft",
"::",
"t",
"(",
"'site'",
",",
"$",
"section",
"->",
"name",
")",
";",
"}",
"return",
"$",
"sections",
";",
"}"
] |
Retrieves all sections in an id-name pair, suitable for the underlying options display.
|
[
"Retrieves",
"all",
"sections",
"in",
"an",
"id",
"-",
"name",
"pair",
"suitable",
"for",
"the",
"underlying",
"options",
"display",
"."
] |
4c57a7a1cd69105453d9e188b8b64fe83409064e
|
https://github.com/charliedevelopment/craft3-section-field/blob/4c57a7a1cd69105453d9e188b8b64fe83409064e/src/fields/SectionField.php#L204-L210
|
221,191
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Response/MultiResultResponse.php
|
MultiResultResponse.parseMeetupApiData
|
protected function parseMeetupApiData()
{
$responseBody = $this->parseBodyContent();
$this->data = $responseBody['results'];
$this->metadata = $responseBody['meta'];
}
|
php
|
protected function parseMeetupApiData()
{
$responseBody = $this->parseBodyContent();
$this->data = $responseBody['results'];
$this->metadata = $responseBody['meta'];
}
|
[
"protected",
"function",
"parseMeetupApiData",
"(",
")",
"{",
"$",
"responseBody",
"=",
"$",
"this",
"->",
"parseBodyContent",
"(",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"responseBody",
"[",
"'results'",
"]",
";",
"$",
"this",
"->",
"metadata",
"=",
"$",
"responseBody",
"[",
"'meta'",
"]",
";",
"}"
] |
Makes Meetup API Data available on the Data attribute.
|
[
"Makes",
"Meetup",
"API",
"Data",
"available",
"on",
"the",
"Data",
"attribute",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Response/MultiResultResponse.php#L21-L27
|
221,192
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Response/MultiResultResponse.php
|
MultiResultResponse.map
|
public function map(Closure $func)
{
$clone = clone $this;
$clone->data = array_map($func, $this->data);
$clone->updateBody();
return $clone;
}
|
php
|
public function map(Closure $func)
{
$clone = clone $this;
$clone->data = array_map($func, $this->data);
$clone->updateBody();
return $clone;
}
|
[
"public",
"function",
"map",
"(",
"Closure",
"$",
"func",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"data",
"=",
"array_map",
"(",
"$",
"func",
",",
"$",
"this",
"->",
"data",
")",
";",
"$",
"clone",
"->",
"updateBody",
"(",
")",
";",
"return",
"$",
"clone",
";",
"}"
] |
Applies the given function to each element in the collection and returns
a new collection with the elements returned by the function.
@param Closure $func
@return MultiResultResponse
|
[
"Applies",
"the",
"given",
"function",
"to",
"each",
"element",
"in",
"the",
"collection",
"and",
"returns",
"a",
"new",
"collection",
"with",
"the",
"elements",
"returned",
"by",
"the",
"function",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Response/MultiResultResponse.php#L37-L45
|
221,193
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Response/MultiResultResponse.php
|
MultiResultResponse.updateBody
|
private function updateBody()
{
$data = array('meta' => $this->metadata, 'results' => $this->data);
$this->body = EntityBody::factory(
$this->isContentType('json') ? json_encode($data) : http_build_query($data)
);
}
|
php
|
private function updateBody()
{
$data = array('meta' => $this->metadata, 'results' => $this->data);
$this->body = EntityBody::factory(
$this->isContentType('json') ? json_encode($data) : http_build_query($data)
);
}
|
[
"private",
"function",
"updateBody",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'meta'",
"=>",
"$",
"this",
"->",
"metadata",
",",
"'results'",
"=>",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"body",
"=",
"EntityBody",
"::",
"factory",
"(",
"$",
"this",
"->",
"isContentType",
"(",
"'json'",
")",
"?",
"json_encode",
"(",
"$",
"data",
")",
":",
"http_build_query",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Assigns a new body to the request, based on the data it contains.
|
[
"Assigns",
"a",
"new",
"body",
"to",
"the",
"request",
"based",
"on",
"the",
"data",
"it",
"contains",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Response/MultiResultResponse.php#L68-L75
|
221,194
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Plugin/RateLimitPlugin.php
|
RateLimitPlugin.onBeforeSend
|
public function onBeforeSend()
{
$currentAmount = $this->rateLimitMax - $this->rateLimitRemaining;
$currentFactor = $currentAmount / $this->rateLimitMax;
// Perform slowdown if the factor is hit
if ($currentFactor > $this->rateLimitFactor) {
$this->slowdownRequests();
}
}
|
php
|
public function onBeforeSend()
{
$currentAmount = $this->rateLimitMax - $this->rateLimitRemaining;
$currentFactor = $currentAmount / $this->rateLimitMax;
// Perform slowdown if the factor is hit
if ($currentFactor > $this->rateLimitFactor) {
$this->slowdownRequests();
}
}
|
[
"public",
"function",
"onBeforeSend",
"(",
")",
"{",
"$",
"currentAmount",
"=",
"$",
"this",
"->",
"rateLimitMax",
"-",
"$",
"this",
"->",
"rateLimitRemaining",
";",
"$",
"currentFactor",
"=",
"$",
"currentAmount",
"/",
"$",
"this",
"->",
"rateLimitMax",
";",
"// Perform slowdown if the factor is hit",
"if",
"(",
"$",
"currentFactor",
">",
"$",
"this",
"->",
"rateLimitFactor",
")",
"{",
"$",
"this",
"->",
"slowdownRequests",
"(",
")",
";",
"}",
"}"
] |
Performs slowdown when rate limiting is enabled and nearing it's limit.
|
[
"Performs",
"slowdown",
"when",
"rate",
"limiting",
"is",
"enabled",
"and",
"nearing",
"it",
"s",
"limit",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Plugin/RateLimitPlugin.php#L132-L141
|
221,195
|
rdohms/meetup-api-client
|
src/DMS/Service/Meetup/Plugin/RateLimitPlugin.php
|
RateLimitPlugin.slowdownRequests
|
protected function slowdownRequests()
{
$sleepInMicroseconds = ((int) $this->rateLimitRemaining === 0)
? $this->rateLimitReset * 1000000
: $this->rateLimitReset / $this->rateLimitRemaining * 1000000;
usleep((int) $sleepInMicroseconds);
}
|
php
|
protected function slowdownRequests()
{
$sleepInMicroseconds = ((int) $this->rateLimitRemaining === 0)
? $this->rateLimitReset * 1000000
: $this->rateLimitReset / $this->rateLimitRemaining * 1000000;
usleep((int) $sleepInMicroseconds);
}
|
[
"protected",
"function",
"slowdownRequests",
"(",
")",
"{",
"$",
"sleepInMicroseconds",
"=",
"(",
"(",
"int",
")",
"$",
"this",
"->",
"rateLimitRemaining",
"===",
"0",
")",
"?",
"$",
"this",
"->",
"rateLimitReset",
"*",
"1000000",
":",
"$",
"this",
"->",
"rateLimitReset",
"/",
"$",
"this",
"->",
"rateLimitRemaining",
"*",
"1000000",
";",
"usleep",
"(",
"(",
"int",
")",
"$",
"sleepInMicroseconds",
")",
";",
"}"
] |
Implements a wait in the code to space out requests to respect the current limit and the reset time.
|
[
"Implements",
"a",
"wait",
"in",
"the",
"code",
"to",
"space",
"out",
"requests",
"to",
"respect",
"the",
"current",
"limit",
"and",
"the",
"reset",
"time",
"."
] |
6abb76a6f8ee4c638569ba712c37114a04c8a824
|
https://github.com/rdohms/meetup-api-client/blob/6abb76a6f8ee4c638569ba712c37114a04c8a824/src/DMS/Service/Meetup/Plugin/RateLimitPlugin.php#L146-L153
|
221,196
|
yii2mod/yii2-selectize
|
Selectize.php
|
Selectize.getPluginOptions
|
public function getPluginOptions()
{
if ($this->url !== null) {
$url = Url::to($this->url);
$this->pluginOptions['load'] = new JsExpression("
function (query, callback) {
if (!query.length) return callback();
$.getJSON('$url', { query: encodeURIComponent(query) }, function (data) { callback(data); })
.fail(function () { callback(); });
}
");
}
return Json::encode($this->pluginOptions);
}
|
php
|
public function getPluginOptions()
{
if ($this->url !== null) {
$url = Url::to($this->url);
$this->pluginOptions['load'] = new JsExpression("
function (query, callback) {
if (!query.length) return callback();
$.getJSON('$url', { query: encodeURIComponent(query) }, function (data) { callback(data); })
.fail(function () { callback(); });
}
");
}
return Json::encode($this->pluginOptions);
}
|
[
"public",
"function",
"getPluginOptions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"url",
"!==",
"null",
")",
"{",
"$",
"url",
"=",
"Url",
"::",
"to",
"(",
"$",
"this",
"->",
"url",
")",
";",
"$",
"this",
"->",
"pluginOptions",
"[",
"'load'",
"]",
"=",
"new",
"JsExpression",
"(",
"\"\n function (query, callback) {\n if (!query.length) return callback();\n $.getJSON('$url', { query: encodeURIComponent(query) }, function (data) { callback(data); })\n .fail(function () { callback(); });\n }\n \"",
")",
";",
"}",
"return",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"pluginOptions",
")",
";",
"}"
] |
Get plugin options in the json format
@return string
|
[
"Get",
"plugin",
"options",
"in",
"the",
"json",
"format"
] |
145c6cbb78d82817d0e96e0faf27f1330505baff
|
https://github.com/yii2mod/yii2-selectize/blob/145c6cbb78d82817d0e96e0faf27f1330505baff/Selectize.php#L84-L98
|
221,197
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.findBy
|
public function findBy($attribute, $value, $columns = ['*'], $with = [])
{
$cacheKey = $this->generateKey([$attribute, $value, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $value, $columns, $with) {
return $this->model->with($with)
->where($attribute, '=', $value)
->first($columns);
});
}
|
php
|
public function findBy($attribute, $value, $columns = ['*'], $with = [])
{
$cacheKey = $this->generateKey([$attribute, $value, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $value, $columns, $with) {
return $this->model->with($with)
->where($attribute, '=', $value)
->first($columns);
});
}
|
[
"public",
"function",
"findBy",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
",",
"$",
"with",
"=",
"[",
"]",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"generateKey",
"(",
"[",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"columns",
",",
"$",
"with",
"]",
")",
";",
"return",
"$",
"this",
"->",
"cacheResults",
"(",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
",",
"$",
"cacheKey",
",",
"function",
"(",
")",
"use",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"columns",
",",
"$",
"with",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"with",
"(",
"$",
"with",
")",
"->",
"where",
"(",
"$",
"attribute",
",",
"'='",
",",
"$",
"value",
")",
"->",
"first",
"(",
"$",
"columns",
")",
";",
"}",
")",
";",
"}"
] |
Find the entity by the given attribute.
@param string $attribute
@param string $value
@param array $columns
@param array $with
|
[
"Find",
"the",
"entity",
"by",
"the",
"given",
"attribute",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L35-L44
|
221,198
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.findOrFail
|
public function findOrFail($id, $columns = ['*'], $with = [])
{
$cacheKey = $this->generateKey([$id, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($id, $columns, $with) {
return $this->model->with($with)
->findOrFail($id, $columns);
});
}
|
php
|
public function findOrFail($id, $columns = ['*'], $with = [])
{
$cacheKey = $this->generateKey([$id, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($id, $columns, $with) {
return $this->model->with($with)
->findOrFail($id, $columns);
});
}
|
[
"public",
"function",
"findOrFail",
"(",
"$",
"id",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
",",
"$",
"with",
"=",
"[",
"]",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"generateKey",
"(",
"[",
"$",
"id",
",",
"$",
"columns",
",",
"$",
"with",
"]",
")",
";",
"return",
"$",
"this",
"->",
"cacheResults",
"(",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
",",
"$",
"cacheKey",
",",
"function",
"(",
")",
"use",
"(",
"$",
"id",
",",
"$",
"columns",
",",
"$",
"with",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"with",
"(",
"$",
"with",
")",
"->",
"findOrFail",
"(",
"$",
"id",
",",
"$",
"columns",
")",
";",
"}",
")",
";",
"}"
] |
Find an entity by its primary key or fail if it doesn't exist.
@param int $id
@param array $columns
@param array $with
|
[
"Find",
"an",
"entity",
"by",
"its",
"primary",
"key",
"or",
"fail",
"if",
"it",
"doesn",
"t",
"exist",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L69-L77
|
221,199
|
caffeinated/repository
|
src/Repositories/EloquentRepository.php
|
EloquentRepository.findWhereBetween
|
public function findWhereBetween($attribute, $values, $columns = ['*'], $with = [])
{
$values = $this->castRequest($values);
$cacheKey = $this->generateKey([$attribute, $values, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $values, $columns, $with) {
return $this->model->with($with)
->whereBetween($attribute, $values)
->get($columns);
});
}
|
php
|
public function findWhereBetween($attribute, $values, $columns = ['*'], $with = [])
{
$values = $this->castRequest($values);
$cacheKey = $this->generateKey([$attribute, $values, $columns, $with]);
return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($attribute, $values, $columns, $with) {
return $this->model->with($with)
->whereBetween($attribute, $values)
->get($columns);
});
}
|
[
"public",
"function",
"findWhereBetween",
"(",
"$",
"attribute",
",",
"$",
"values",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
",",
"$",
"with",
"=",
"[",
"]",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"castRequest",
"(",
"$",
"values",
")",
";",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"generateKey",
"(",
"[",
"$",
"attribute",
",",
"$",
"values",
",",
"$",
"columns",
",",
"$",
"with",
"]",
")",
";",
"return",
"$",
"this",
"->",
"cacheResults",
"(",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
",",
"$",
"cacheKey",
",",
"function",
"(",
")",
"use",
"(",
"$",
"attribute",
",",
"$",
"values",
",",
"$",
"columns",
",",
"$",
"with",
")",
"{",
"return",
"$",
"this",
"->",
"model",
"->",
"with",
"(",
"$",
"with",
")",
"->",
"whereBetween",
"(",
"$",
"attribute",
",",
"$",
"values",
")",
"->",
"get",
"(",
"$",
"columns",
")",
";",
"}",
")",
";",
"}"
] |
Find all entities matching whereBetween conditions.
@param string $attribute
@param array $values
@param array $columns
@param array $with
|
[
"Find",
"all",
"entities",
"matching",
"whereBetween",
"conditions",
"."
] |
697718c3084910e81efabb36a9435347a3984754
|
https://github.com/caffeinated/repository/blob/697718c3084910e81efabb36a9435347a3984754/src/Repositories/EloquentRepository.php#L117-L127
|
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.