repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.next | public function next()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() + 1) : null;
} | php | public function next()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() + 1) : null;
} | [
"public",
"function",
"next",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"!==",
"null",
"?",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getChildByIndex",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
"+",
"1",
")",
":"... | Retrieve next node.
@return NodeContract|null | [
"Retrieve",
"next",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L213-L216 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.moveNodeAsChild | public function moveNodeAsChild(NodeContract $child)
{
if ($child->getParent() !== null) {
$child->getParent()->removeChild($child);
$this->addChild($child);
}
} | php | public function moveNodeAsChild(NodeContract $child)
{
if ($child->getParent() !== null) {
$child->getParent()->removeChild($child);
$this->addChild($child);
}
} | [
"public",
"function",
"moveNodeAsChild",
"(",
"NodeContract",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"getParent",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"child",
"->",
"getParent",
"(",
")",
"->",
"removeChild",
"(",
"$",
"child",
")",... | Move the node from the old location to a new one as a child of $this.
@param NodeContract $child
@return $this | [
"Move",
"the",
"node",
"from",
"the",
"old",
"location",
"to",
"a",
"new",
"one",
"as",
"a",
"child",
"of",
"$this",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L225-L231 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.getChildrenBetweenIndexes | public function getChildrenBetweenIndexes(int $start, int $end)
{
return array_slice($this->children, $start, $end - $start + 1);
} | php | public function getChildrenBetweenIndexes(int $start, int $end)
{
return array_slice($this->children, $start, $end - $start + 1);
} | [
"public",
"function",
"getChildrenBetweenIndexes",
"(",
"int",
"$",
"start",
",",
"int",
"$",
"end",
")",
"{",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"start",
",",
"$",
"end",
"-",
"$",
"start",
"+",
"1",
")",
";",
"}"... | Retrieve children between indexes.
@param int $start
@param int $end
@return array | [
"Retrieve",
"children",
"between",
"indexes",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L257-L260 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.replaceChild | public function replaceChild($index, $subs)
{
$first = array_slice($this->children, 0, $index);
$second = $index + 1 >= count($this->children) ? [] : array_slice($this->children, $index + 1, count($this->children) - ($index + 1));
$this->children = [];
foreach (array_merge($first, $subs, $second) as $child) {
if ($child) {
$this->addChild($child);
}
}
$this->flush();
return $this;
} | php | public function replaceChild($index, $subs)
{
$first = array_slice($this->children, 0, $index);
$second = $index + 1 >= count($this->children) ? [] : array_slice($this->children, $index + 1, count($this->children) - ($index + 1));
$this->children = [];
foreach (array_merge($first, $subs, $second) as $child) {
if ($child) {
$this->addChild($child);
}
}
$this->flush();
return $this;
} | [
"public",
"function",
"replaceChild",
"(",
"$",
"index",
",",
"$",
"subs",
")",
"{",
"$",
"first",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"children",
",",
"0",
",",
"$",
"index",
")",
";",
"$",
"second",
"=",
"$",
"index",
"+",
"1",
">=",
"c... | Replace a child by others.
@param int $index
@param array $subs
@return $this | [
"Replace",
"a",
"child",
"by",
"others",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L270-L285 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.removeChildren | public function removeChildren($children)
{
array_splice($this->children, $children[0]->getIndex(), count($children));
$this->flush();
return $this;
} | php | public function removeChildren($children)
{
array_splice($this->children, $children[0]->getIndex(), count($children));
$this->flush();
return $this;
} | [
"public",
"function",
"removeChildren",
"(",
"$",
"children",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"children",
"[",
"0",
"]",
"->",
"getIndex",
"(",
")",
",",
"count",
"(",
"$",
"children",
")",
")",
";",
"$",
"this... | Remove children.
@param array $children
@return $this | [
"Remove",
"children",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L321-L327 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.addChildBeforeNodeByIndex | public function addChildBeforeNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$child, $this->getChildByIndex($index)]);
} | php | public function addChildBeforeNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$child, $this->getChildByIndex($index)]);
} | [
"public",
"function",
"addChildBeforeNodeByIndex",
"(",
"NodeContract",
"$",
"child",
",",
"int",
"$",
"index",
")",
"{",
"return",
"$",
"this",
"->",
"replaceChild",
"(",
"$",
"index",
",",
"[",
"$",
"child",
",",
"$",
"this",
"->",
"getChildByIndex",
"("... | Add children before node.
@param NodeContract $child
@param int $index
@return $this | [
"Add",
"children",
"before",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L337-L340 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.addChildAfterNodeByIndex | public function addChildAfterNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$this->getChildByIndex($index), $child]);
} | php | public function addChildAfterNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$this->getChildByIndex($index), $child]);
} | [
"public",
"function",
"addChildAfterNodeByIndex",
"(",
"NodeContract",
"$",
"child",
",",
"int",
"$",
"index",
")",
"{",
"return",
"$",
"this",
"->",
"replaceChild",
"(",
"$",
"index",
",",
"[",
"$",
"this",
"->",
"getChildByIndex",
"(",
"$",
"index",
")",... | Add children after node.
@param NodeContract $child
@param int $index
@return $this | [
"Add",
"children",
"after",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L350-L353 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.removeChildByKey | public function removeChildByKey($index, $resort = true)
{
array_splice($this->children, $index, 1);
if ($resort) {
$this->flush();
}
return $this;
} | php | public function removeChildByKey($index, $resort = true)
{
array_splice($this->children, $index, 1);
if ($resort) {
$this->flush();
}
return $this;
} | [
"public",
"function",
"removeChildByKey",
"(",
"$",
"index",
",",
"$",
"resort",
"=",
"true",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"index",
",",
"1",
")",
";",
"if",
"(",
"$",
"resort",
")",
"{",
"$",
"this",
"->"... | Remove child by index.
@param int $index
@param bool $resort
@return $this | [
"Remove",
"child",
"by",
"index",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L379-L388 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.flush | public function flush()
{
$n = 0;
$children = [];
foreach ($this->children as $k => $child) {
if ($child !== null) {
$child->setIndex($n);
$child->setParent($this);
$children[] = $child;
++$n;
}
}
$this->children = $children;
return $this;
} | php | public function flush()
{
$n = 0;
$children = [];
foreach ($this->children as $k => $child) {
if ($child !== null) {
$child->setIndex($n);
$child->setParent($this);
$children[] = $child;
++$n;
}
}
$this->children = $children;
return $this;
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"n",
"=",
"0",
";",
"$",
"children",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"k",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"!==",
"null",
"... | Reset parent and index of each node.
@return $this | [
"Reset",
"parent",
"and",
"index",
"of",
"each",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L395-L411 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.swapParentAndDelete | public function swapParentAndDelete(NodeContract $old_parent, NodeContract $new_parent)
{
$new_parent->replaceChild($old_parent->getIndex(), [$this]);
return $this;
} | php | public function swapParentAndDelete(NodeContract $old_parent, NodeContract $new_parent)
{
$new_parent->replaceChild($old_parent->getIndex(), [$this]);
return $this;
} | [
"public",
"function",
"swapParentAndDelete",
"(",
"NodeContract",
"$",
"old_parent",
",",
"NodeContract",
"$",
"new_parent",
")",
"{",
"$",
"new_parent",
"->",
"replaceChild",
"(",
"$",
"old_parent",
"->",
"getIndex",
"(",
")",
",",
"[",
"$",
"this",
"]",
")... | Swap parent and delete.
@param NodeContract $old_parent
@param NodeContract $new_parent
@return $this | [
"Swap",
"parent",
"and",
"delete",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L421-L426 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.toArray | public function toArray()
{
return [
'type' => get_class($this),
'value' => $this->getValue(),
'children' => array_map(function ($node) {
return $node->jsonSerialize();
}, $this->getChildren()),
];
} | php | public function toArray()
{
return [
'type' => get_class($this),
'value' => $this->getValue(),
'children' => array_map(function ($node) {
return $node->jsonSerialize();
}, $this->getChildren()),
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'type'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"'children'",
"=>",
"array_map",
"(",
"function",
"(",
"$",
"node",
... | Array representation of node.
@return array | [
"Array",
"representation",
"of",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L443-L452 |
railken/search-query | src/Languages/BoomTree/Nodes/Node.php | Node.valueToString | public function valueToString($recursive = true)
{
if ($this->countChildren() === 0) {
return $this->getValue();
}
return implode(' ', array_map(function ($node) use ($recursive) {
return $recursive ? $node->valueToString() : $node->getValue();
}, $this->getChildren()));
} | php | public function valueToString($recursive = true)
{
if ($this->countChildren() === 0) {
return $this->getValue();
}
return implode(' ', array_map(function ($node) use ($recursive) {
return $recursive ? $node->valueToString() : $node->getValue();
}, $this->getChildren()));
} | [
"public",
"function",
"valueToString",
"(",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"countChildren",
"(",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"}",
"return",
"implode",
"(",... | To string.
@param bool $recursive
@return string | [
"To",
"string",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L461-L470 |
txj123/zilf | src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php | Zend_Validate_File_Extension.getExtension | public function getExtension($asArray = false)
{
$asArray = (bool) $asArray;
$extension = (string) $this->_extension;
if ($asArray) {
$extension = explode(',', $extension);
}
return $extension;
} | php | public function getExtension($asArray = false)
{
$asArray = (bool) $asArray;
$extension = (string) $this->_extension;
if ($asArray) {
$extension = explode(',', $extension);
}
return $extension;
} | [
"public",
"function",
"getExtension",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"asArray",
"=",
"(",
"bool",
")",
"$",
"asArray",
";",
"$",
"extension",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_extension",
";",
"if",
"(",
"$",
"asArray",... | Returns the set file extension
@param boolean $asArray Returns the values as array, when false an concated string is returned
@return string | [
"Returns",
"the",
"set",
"file",
"extension"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php#L91-L100 |
txj123/zilf | src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php | Zend_Validate_File_Extension.isValid | public function isValid($value, $file = null)
{
// Is file readable ?
if (!@is_readable($value)) {
$this->_throw($file, self::NOT_FOUND);
return false;
}
if ($file !== null) {
$info['extension'] = substr($file['name'], strpos($file['name'], '.') + 1);
} else {
$info = @pathinfo($value);
}
$extensions = $this->getExtension(true);
if ($this->_case and (in_array($info['extension'], $extensions))) {
return true;
} else if (!$this->_case) {
foreach ($extensions as $extension) {
if (strtolower($extension) == strtolower($info['extension'])) {
return true;
}
}
}
$this->_throw($file, self::FALSE_EXTENSION);
return false;
} | php | public function isValid($value, $file = null)
{
// Is file readable ?
if (!@is_readable($value)) {
$this->_throw($file, self::NOT_FOUND);
return false;
}
if ($file !== null) {
$info['extension'] = substr($file['name'], strpos($file['name'], '.') + 1);
} else {
$info = @pathinfo($value);
}
$extensions = $this->getExtension(true);
if ($this->_case and (in_array($info['extension'], $extensions))) {
return true;
} else if (!$this->_case) {
foreach ($extensions as $extension) {
if (strtolower($extension) == strtolower($info['extension'])) {
return true;
}
}
}
$this->_throw($file, self::FALSE_EXTENSION);
return false;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"$",
"file",
"=",
"null",
")",
"{",
"// Is file readable ?",
"if",
"(",
"!",
"@",
"is_readable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
... | Defined by Zend_Validate_Interface
Returns true if and only if the fileextension of $value is included in the
set extension list
@param string $value Real file to check for extension
@param array $file File data from Zend_File_Transfer
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php#L159-L187 |
txj123/zilf | src/Zilf/Helpers/BaseInflector.php | BaseInflector.camel2words | public static function camel2words($name, $ucwords = true)
{
$label = trim(
strtolower(
str_replace(
[
'-',
'_',
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name)
)
)
);
return $ucwords ? ucwords($label) : $label;
} | php | public static function camel2words($name, $ucwords = true)
{
$label = trim(
strtolower(
str_replace(
[
'-',
'_',
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name)
)
)
);
return $ucwords ? ucwords($label) : $label;
} | [
"public",
"static",
"function",
"camel2words",
"(",
"$",
"name",
",",
"$",
"ucwords",
"=",
"true",
")",
"{",
"$",
"label",
"=",
"trim",
"(",
"strtolower",
"(",
"str_replace",
"(",
"[",
"'-'",
",",
"'_'",
",",
"'.'",
",",
"]",
",",
"' '",
",",
"preg... | Converts a CamelCase name into space-separated words.
For example, 'PostTag' will be converted to 'Post Tag'.
@param string $name the string to be converted
@param boolean $ucwords whether to capitalize the first letter in each word
@return string the resulting words | [
"Converts",
"a",
"CamelCase",
"name",
"into",
"space",
"-",
"separated",
"words",
".",
"For",
"example",
"PostTag",
"will",
"be",
"converted",
"to",
"Post",
"Tag",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/BaseInflector.php#L356-L371 |
txj123/zilf | src/Zilf/Helpers/BaseInflector.php | BaseInflector.slug | public static function slug($string, $replacement = '-', $lowercase = true)
{
$string = static::transliterate($string);
$string = preg_replace('/[^a-zA-Z0-9=\s—–-]+/u', '', $string);
$string = preg_replace('/[=\s—–-]+/u', $replacement, $string);
$string = trim($string, $replacement);
return $lowercase ? strtolower($string) : $string;
} | php | public static function slug($string, $replacement = '-', $lowercase = true)
{
$string = static::transliterate($string);
$string = preg_replace('/[^a-zA-Z0-9=\s—–-]+/u', '', $string);
$string = preg_replace('/[=\s—–-]+/u', $replacement, $string);
$string = trim($string, $replacement);
return $lowercase ? strtolower($string) : $string;
} | [
"public",
"static",
"function",
"slug",
"(",
"$",
"string",
",",
"$",
"replacement",
"=",
"'-'",
",",
"$",
"lowercase",
"=",
"true",
")",
"{",
"$",
"string",
"=",
"static",
"::",
"transliterate",
"(",
"$",
"string",
")",
";",
"$",
"string",
"=",
"pre... | Returns a string with all spaces converted to given replacement,
non word characters removed and the rest of characters transliterated.
If intl extension isn't available uses fallback that converts latin characters only
and removes the rest. You may customize characters map via $transliteration property
of the helper.
@param string $string An arbitrary string to convert
@param string $replacement The replacement to use for spaces
@param boolean $lowercase whether to return the string in lowercase or not. Defaults to `true`.
@return string The converted string. | [
"Returns",
"a",
"string",
"with",
"all",
"spaces",
"converted",
"to",
"given",
"replacement",
"non",
"word",
"characters",
"removed",
"and",
"the",
"rest",
"of",
"characters",
"transliterated",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/BaseInflector.php#L473-L481 |
txj123/zilf | src/Zilf/Helpers/BaseInflector.php | BaseInflector.transliterate | public static function transliterate($string, $transliterator = null)
{
if (static::hasIntl()) {
if ($transliterator === null) {
$transliterator = static::$transliterator;
}
return transliterator_transliterate($transliterator, $string);
} else {
return strtr($string, static::$transliteration);
}
} | php | public static function transliterate($string, $transliterator = null)
{
if (static::hasIntl()) {
if ($transliterator === null) {
$transliterator = static::$transliterator;
}
return transliterator_transliterate($transliterator, $string);
} else {
return strtr($string, static::$transliteration);
}
} | [
"public",
"static",
"function",
"transliterate",
"(",
"$",
"string",
",",
"$",
"transliterator",
"=",
"null",
")",
"{",
"if",
"(",
"static",
"::",
"hasIntl",
"(",
")",
")",
"{",
"if",
"(",
"$",
"transliterator",
"===",
"null",
")",
"{",
"$",
"translite... | Returns transliterated version of a string.
If intl extension isn't available uses fallback that converts latin characters only
and removes the rest. You may customize characters map via $transliteration property
of the helper.
@param string $string input string
@param string|\Transliterator $transliterator either a [[Transliterator]] or a string
from which a [[Transliterator]] can be built.
@return string
@since 2.0.7 this method is public. | [
"Returns",
"transliterated",
"version",
"of",
"a",
"string",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/BaseInflector.php#L496-L507 |
txj123/zilf | src/Zilf/Routing/RoutingServiceProvider.php | RoutingServiceProvider.register | public function register()
{
Zilf::$container->register('router', function () {
$route = new Router();
$config = Zilf::$container->getShare('config');
$route->lazy($config['app.url_lazy_route'])
->autoSearchController($config['app.controller_auto_search'])
->mergeRuleRegex($config['app.route_rule_merge']);
return $route;
});
Zilf::$container->register('ruleName', function () {
return new RuleName();
});
} | php | public function register()
{
Zilf::$container->register('router', function () {
$route = new Router();
$config = Zilf::$container->getShare('config');
$route->lazy($config['app.url_lazy_route'])
->autoSearchController($config['app.controller_auto_search'])
->mergeRuleRegex($config['app.route_rule_merge']);
return $route;
});
Zilf::$container->register('ruleName', function () {
return new RuleName();
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"Zilf",
"::",
"$",
"container",
"->",
"register",
"(",
"'router'",
",",
"function",
"(",
")",
"{",
"$",
"route",
"=",
"new",
"Router",
"(",
")",
";",
"$",
"config",
"=",
"Zilf",
"::",
"$",
"container",... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RoutingServiceProvider.php#L16-L31 |
txj123/zilf | src/Zilf/Finder/Finder.php | Finder.in | public function in($dirs)
{
$resolvedDirs = array();
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $dir;
} elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, $glob);
} else {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
}
}
$this->dirs = array_merge($this->dirs, $resolvedDirs);
return $this;
} | php | public function in($dirs)
{
$resolvedDirs = array();
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $dir;
} elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, $glob);
} else {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
}
}
$this->dirs = array_merge($this->dirs, $resolvedDirs);
return $this;
} | [
"public",
"function",
"in",
"(",
"$",
"dirs",
")",
"{",
"$",
"resolvedDirs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"r... | Searches files and directories which match defined rules.
@param string|array $dirs A directory path or an array of directories
@return $this
@throws \InvalidArgumentException if one of the directories does not exist | [
"Searches",
"files",
"and",
"directories",
"which",
"match",
"defined",
"rules",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Finder.php#L536-L553 |
txj123/zilf | src/Zilf/Finder/Finder.php | Finder.append | public function append($iterator)
{
if ($iterator instanceof \IteratorAggregate) {
$this->iterators[] = $iterator->getIterator();
} elseif ($iterator instanceof \Iterator) {
$this->iterators[] = $iterator;
} elseif ($iterator instanceof \Traversable || is_array($iterator)) {
$it = new \ArrayIterator();
foreach ($iterator as $file) {
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
}
$this->iterators[] = $it;
} else {
throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
}
return $this;
} | php | public function append($iterator)
{
if ($iterator instanceof \IteratorAggregate) {
$this->iterators[] = $iterator->getIterator();
} elseif ($iterator instanceof \Iterator) {
$this->iterators[] = $iterator;
} elseif ($iterator instanceof \Traversable || is_array($iterator)) {
$it = new \ArrayIterator();
foreach ($iterator as $file) {
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
}
$this->iterators[] = $it;
} else {
throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
}
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"iterator",
")",
"{",
"if",
"(",
"$",
"iterator",
"instanceof",
"\\",
"IteratorAggregate",
")",
"{",
"$",
"this",
"->",
"iterators",
"[",
"]",
"=",
"$",
"iterator",
"->",
"getIterator",
"(",
")",
";",
"}",
"els... | Appends an existing set of files/directories to the finder.
The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
@param mixed $iterator
@return $this
@throws \InvalidArgumentException When the given argument is not iterable. | [
"Appends",
"an",
"existing",
"set",
"of",
"files",
"/",
"directories",
"to",
"the",
"finder",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Finder.php#L597-L614 |
Salamek/raven-nette | src/SentryLogger.php | SentryLogger.setUserContext | public function setUserContext($userId = null, $email = null, array $data = null)
{
$this->raven->set_user_data($userId, $email, $data);
} | php | public function setUserContext($userId = null, $email = null, array $data = null)
{
$this->raven->set_user_data($userId, $email, $data);
} | [
"public",
"function",
"setUserContext",
"(",
"$",
"userId",
"=",
"null",
",",
"$",
"email",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"raven",
"->",
"set_user_data",
"(",
"$",
"userId",
",",
"$",
"email",
",",
... | Set logged in user into raven context
@param null $userId
@param null $email
@param array|NULL $data
@return null | [
"Set",
"logged",
"in",
"user",
"into",
"raven",
"context"
] | train | https://github.com/Salamek/raven-nette/blob/222de5a0d372f7191aa226775d29e13b609baa56/src/SentryLogger.php#L114-L117 |
crysalead/sql-dialect | src/Statement/Behavior/HasLimit.php | HasLimit.limit | public function limit($limit = 0, $offset = 0)
{
if (!$limit) {
return $this;
}
if ($offset) {
$limit .= " OFFSET {$offset}";
}
$this->_parts['limit'] = $limit;
return $this;
} | php | public function limit($limit = 0, $offset = 0)
{
if (!$limit) {
return $this;
}
if ($offset) {
$limit .= " OFFSET {$offset}";
}
$this->_parts['limit'] = $limit;
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"limit",
".=",
"\" OFFSET {$of... | Adds a limit statement to the query.
@param integer $limit The limit value.
@param integer $offset The offset value.
@return object Returns `$this`. | [
"Adds",
"a",
"limit",
"statement",
"to",
"the",
"query",
"."
] | train | https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasLimit.php#L13-L23 |
txj123/zilf | src/Zilf/Console/Scheduling/Schedule.php | Schedule.command | public function command($command, array $parameters = [])
{
if (class_exists($command)) {
$command = (new $command)->getName();
}
return $this->exec(
Application::formatCommandString($command), $parameters
);
} | php | public function command($command, array $parameters = [])
{
if (class_exists($command)) {
$command = (new $command)->getName();
}
return $this->exec(
Application::formatCommandString($command), $parameters
);
} | [
"public",
"function",
"command",
"(",
"$",
"command",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"command",
")",
")",
"{",
"$",
"command",
"=",
"(",
"new",
"$",
"command",
")",
"->",
"getName",
"(... | Add a new Artisan command event to the schedule.
@param string $command
@param array $parameters
@return \Zilf\Console\Scheduling\Event | [
"Add",
"a",
"new",
"Artisan",
"command",
"event",
"to",
"the",
"schedule",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Scheduling/Schedule.php#L76-L85 |
txj123/zilf | src/Zilf/Console/Scheduling/Schedule.php | Schedule.job | public function job($job, $queue = null)
{
return $this->call(
function () use ($job, $queue) {
$job = is_string($job) ? resolve($job) : $job;
if ($job instanceof ShouldQueue) {
dispatch($job)->onQueue($queue);
} else {
dispatch_now($job);
}
}
)->name(is_string($job) ? $job : get_class($job));
} | php | public function job($job, $queue = null)
{
return $this->call(
function () use ($job, $queue) {
$job = is_string($job) ? resolve($job) : $job;
if ($job instanceof ShouldQueue) {
dispatch($job)->onQueue($queue);
} else {
dispatch_now($job);
}
}
)->name(is_string($job) ? $job : get_class($job));
} | [
"public",
"function",
"job",
"(",
"$",
"job",
",",
"$",
"queue",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"job",
",",
"$",
"queue",
")",
"{",
"$",
"job",
"=",
"is_string",
"(",
"$",... | Add a new job callback event to the schedule.
@param object|string $job
@param string|null $queue
@return \Zilf\Console\Scheduling\CallbackEvent | [
"Add",
"a",
"new",
"job",
"callback",
"event",
"to",
"the",
"schedule",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Scheduling/Schedule.php#L94-L107 |
txj123/zilf | src/Zilf/Console/Scheduling/Schedule.php | Schedule.exec | public function exec($command, array $parameters = [])
{
if (count($parameters)) {
$command .= ' '.$this->compileParameters($parameters);
}
$this->events[] = $event = new Event($this->eventMutex, $command);
return $event;
} | php | public function exec($command, array $parameters = [])
{
if (count($parameters)) {
$command .= ' '.$this->compileParameters($parameters);
}
$this->events[] = $event = new Event($this->eventMutex, $command);
return $event;
} | [
"public",
"function",
"exec",
"(",
"$",
"command",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"command",
".=",
"' '",
".",
"$",
"this",
"->",
"compileParameters",
"(",
"... | Add a new command event to the schedule.
@param string $command
@param array $parameters
@return \Zilf\Console\Scheduling\Event | [
"Add",
"a",
"new",
"command",
"event",
"to",
"the",
"schedule",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Scheduling/Schedule.php#L116-L125 |
Lansoweb/LosLog | src/Loggable.php | Loggable.losLogMe | public function losLogMe()
{
$ret = [];
$ret[get_class($this)] = [];
foreach (get_object_vars($this) as $name => $content) {
if (! is_object($content)) {
$ret[$name] = ['type' => gettype($content), 'content' => $content];
} else {
$ret[$name] = ['type' => gettype($content), 'class' => get_class($content)];
}
}
return $ret;
} | php | public function losLogMe()
{
$ret = [];
$ret[get_class($this)] = [];
foreach (get_object_vars($this) as $name => $content) {
if (! is_object($content)) {
$ret[$name] = ['type' => gettype($content), 'content' => $content];
} else {
$ret[$name] = ['type' => gettype($content), 'class' => get_class($content)];
}
}
return $ret;
} | [
"public",
"function",
"losLogMe",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"ret",
"[",
"get_class",
"(",
"$",
"this",
")",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"name",
"=>",
"$... | Function to collect properties values.
@return array Array with the properties and values from the object | [
"Function",
"to",
"collect",
"properties",
"values",
"."
] | train | https://github.com/Lansoweb/LosLog/blob/1d7d24db66a8f77da2b7e33bb10d6665133c9199/src/Loggable.php#L34-L47 |
txj123/zilf | src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/InArray.php | Zend_Validate_InArray.isValid | public function isValid($value)
{
$this->_setValue($value);
if (!in_array($value, $this->_haystack, $this->_strict)) {
$this->_error();
return false;
}
return true;
} | php | public function isValid($value)
{
$this->_setValue($value);
if (!in_array($value, $this->_haystack, $this->_strict)) {
$this->_error();
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"_haystack",
",",
"$",
"this",
"->",
"_strict",
")",
... | Defined by Zend_Validate_Interface
Returns true if and only if $value is contained in the haystack option. If the strict
option is true, then the type of $value is also checked.
@param mixed $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/InArray.php#L128-L136 |
dave-redfern/laravel-doctrine-tenancy | src/Http/Middleware/AuthenticateTenant.php | AuthenticateTenant.handle | public function handle($request, Closure $next)
{
$owner = $creator = null;
/** @var TenantContract $tenant */
$tenant = app('auth.tenant');
/** @var TenantParticipantContract $owner */
if (null !== $tenantOwnerId = $request->route('tenant_owner_id')) {
if ($tenant->getTenantOwnerId() && $tenantOwnerId != $tenant->getTenantOwnerId()) {
abort(500, sprintf(
'Selected tenant_owner_id "%s" in route parameters does not match the resolved owner "%s: %s"',
$tenantOwnerId, $tenant->getTenantOwnerId(), $tenant->getTenantOwner()->getName()
));
}
$owner = $this->repository->find($tenantOwnerId);
}
/** @var TenantParticipantContract $creator */
if (null !== $tenantCreatorId = $request->route('tenant_creator_id')) {
$creator = $this->repository->find($tenantCreatorId);
}
/** @var BelongsToTenantContract $user */
$user = $this->auth->user();
if (!$user instanceof BelongsToTenantContract) {
abort(500, sprintf('The Authenticatable User entity does not implement BelongsToTenant contract.'));
}
if (!$creator || !$user->belongsToTenant($creator)) {
return redirect()->route('tenant.access_denied');
}
if ($owner && $creator->getTenantOwner() !== $owner) {
return redirect()->route('tenant.invalid_tenant_hierarchy');
}
// remove the tenant parameters, TenantAware URL generator has access to Tenant
$request->route()->forgetParameter('tenant_owner_id');
$request->route()->forgetParameter('tenant_creator_id');
$tenant->updateTenancy($user, $creator->getTenantOwner(), $creator);
return $next($request);
} | php | public function handle($request, Closure $next)
{
$owner = $creator = null;
/** @var TenantContract $tenant */
$tenant = app('auth.tenant');
/** @var TenantParticipantContract $owner */
if (null !== $tenantOwnerId = $request->route('tenant_owner_id')) {
if ($tenant->getTenantOwnerId() && $tenantOwnerId != $tenant->getTenantOwnerId()) {
abort(500, sprintf(
'Selected tenant_owner_id "%s" in route parameters does not match the resolved owner "%s: %s"',
$tenantOwnerId, $tenant->getTenantOwnerId(), $tenant->getTenantOwner()->getName()
));
}
$owner = $this->repository->find($tenantOwnerId);
}
/** @var TenantParticipantContract $creator */
if (null !== $tenantCreatorId = $request->route('tenant_creator_id')) {
$creator = $this->repository->find($tenantCreatorId);
}
/** @var BelongsToTenantContract $user */
$user = $this->auth->user();
if (!$user instanceof BelongsToTenantContract) {
abort(500, sprintf('The Authenticatable User entity does not implement BelongsToTenant contract.'));
}
if (!$creator || !$user->belongsToTenant($creator)) {
return redirect()->route('tenant.access_denied');
}
if ($owner && $creator->getTenantOwner() !== $owner) {
return redirect()->route('tenant.invalid_tenant_hierarchy');
}
// remove the tenant parameters, TenantAware URL generator has access to Tenant
$request->route()->forgetParameter('tenant_owner_id');
$request->route()->forgetParameter('tenant_creator_id');
$tenant->updateTenancy($user, $creator->getTenantOwner(), $creator);
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"$",
"owner",
"=",
"$",
"creator",
"=",
"null",
";",
"/** @var TenantContract $tenant */",
"$",
"tenant",
"=",
"app",
"(",
"'auth.tenant'",
")",
";",
"/** @var Tenant... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | train | https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Http/Middleware/AuthenticateTenant.php#L72-L116 |
railken/search-query | src/Languages/BoomTree/Resolvers/BaseResolver.php | BaseResolver.resolve | public function resolve(NodeContract $node)
{
$children = $node->getChildren();
if (count($children) > 0) {
$this->resolve($node->getChildByIndex(0));
}
if ($node instanceof Nodes\TextNode) {
foreach ($this->regex as $regex) {
$margin = 0;
preg_match_all($regex, $node->getValue(), $matches, PREG_OFFSET_CAPTURE);
$positions = [];
foreach ($matches[0] as $match) {
$value = $match[0]; // Value
$start = $match[1]; // Offset
if ($value !== '') {
$length = strlen($value);
$new_node = new $this->node();
$new_node->setValue($this->parseValue($value));
$positions[] = [
'from' => $start,
'to' => $start + $length,
'node' => $new_node,
];
}
}
if (count($positions) > 0) {
$nodes = $this->splitMultipleNode(Nodes\TextNode::class, $node, $positions);
return $this->resolve($nodes[0]->getParent());
}
}
}
return $node->next() !== null ? $this->resolve($node->next()) : null;
} | php | public function resolve(NodeContract $node)
{
$children = $node->getChildren();
if (count($children) > 0) {
$this->resolve($node->getChildByIndex(0));
}
if ($node instanceof Nodes\TextNode) {
foreach ($this->regex as $regex) {
$margin = 0;
preg_match_all($regex, $node->getValue(), $matches, PREG_OFFSET_CAPTURE);
$positions = [];
foreach ($matches[0] as $match) {
$value = $match[0]; // Value
$start = $match[1]; // Offset
if ($value !== '') {
$length = strlen($value);
$new_node = new $this->node();
$new_node->setValue($this->parseValue($value));
$positions[] = [
'from' => $start,
'to' => $start + $length,
'node' => $new_node,
];
}
}
if (count($positions) > 0) {
$nodes = $this->splitMultipleNode(Nodes\TextNode::class, $node, $positions);
return $this->resolve($nodes[0]->getParent());
}
}
}
return $node->next() !== null ? $this->resolve($node->next()) : null;
} | [
"public",
"function",
"resolve",
"(",
"NodeContract",
"$",
"node",
")",
"{",
"$",
"children",
"=",
"$",
"node",
"->",
"getChildren",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"children",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"resolve",
"("... | Resolve node.
@param NodeContract $node
@return NodeContract|null | [
"Resolve",
"node",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/BaseResolver.php#L35-L77 |
txj123/zilf | src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Upload.php | Zend_Validate_File_Upload.setFiles | public function setFiles($files = array())
{
if (count($files) === 0) {
$this->_files = $_FILES;
} else {
$this->_files = $files;
}
return $this;
} | php | public function setFiles($files = array())
{
if (count($files) === 0) {
$this->_files = $_FILES;
} else {
$this->_files = $files;
}
return $this;
} | [
"public",
"function",
"setFiles",
"(",
"$",
"files",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"files",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"_files",
"=",
"$",
"_FILES",
";",
"}",
"else",
"{",
"$",
"this",
"->",
... | Sets the minimum filesize
@param array $files The files to check in syntax of Zend_File_Transfer
@return Zend_Validate_File_Upload Provides a fluent interface | [
"Sets",
"the",
"minimum",
"filesize"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Upload.php#L131-L139 |
txj123/zilf | src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Upload.php | Zend_Validate_File_Upload.isValid | public function isValid($value)
{
if (array_key_exists($value, $this->_files)) {
$files[$value] = $this->_files[$value];
} else {
foreach ($this->_files as $file => $content) {
if ($content['name'] === $value) {
$files[$file] = $this->_files[$file];
}
if ($content['tmp_name'] === $value) {
$files[$file] = $this->_files[$file];
}
}
}
if (empty($files)) {
$this->_error(self::FILE_NOT_FOUND);
return false;
}
foreach ($files as $file => $content) {
$this->_value = $file;
switch($content['error']) {
case 0:
if (!is_uploaded_file($content['tmp_name'])) {
$this->_error(self::ATTACK);
}
break;
case 1:
$this->_error(self::INI_SIZE);
break;
case 2:
$this->_error(self::FORM_SIZE);
break;
case 3:
$this->_error(self::PARTIAL);
break;
case 4:
$this->_error(self::NO_FILE);
break;
case 6:
$this->_error(self::NO_TMP_DIR);
break;
case 7:
$this->_error(self::CANT_WRITE);
break;
case 8:
$this->_error(self::EXTENSION);
break;
default:
$this->_error(self::UNKNOWN);
break;
}
}
if (count($this->_messages) > 0) {
return false;
} else {
return true;
}
} | php | public function isValid($value)
{
if (array_key_exists($value, $this->_files)) {
$files[$value] = $this->_files[$value];
} else {
foreach ($this->_files as $file => $content) {
if ($content['name'] === $value) {
$files[$file] = $this->_files[$file];
}
if ($content['tmp_name'] === $value) {
$files[$file] = $this->_files[$file];
}
}
}
if (empty($files)) {
$this->_error(self::FILE_NOT_FOUND);
return false;
}
foreach ($files as $file => $content) {
$this->_value = $file;
switch($content['error']) {
case 0:
if (!is_uploaded_file($content['tmp_name'])) {
$this->_error(self::ATTACK);
}
break;
case 1:
$this->_error(self::INI_SIZE);
break;
case 2:
$this->_error(self::FORM_SIZE);
break;
case 3:
$this->_error(self::PARTIAL);
break;
case 4:
$this->_error(self::NO_FILE);
break;
case 6:
$this->_error(self::NO_TMP_DIR);
break;
case 7:
$this->_error(self::CANT_WRITE);
break;
case 8:
$this->_error(self::EXTENSION);
break;
default:
$this->_error(self::UNKNOWN);
break;
}
}
if (count($this->_messages) > 0) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"_files",
")",
")",
"{",
"$",
"files",
"[",
"$",
"value",
"]",
"=",
"$",
"this",
"->",
"_files",
"[",
"$",
"va... | Defined by Zend_Validate_Interface
Returns true if and only if the file was uploaded without errors
@param string $value Single file to check for upload errors, when giving null the $_FILES array
from initialization will be used
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Upload.php#L150-L219 |
txj123/zilf | src/Zilf/Console/Kernel.php | Kernel.defineConsoleSchedule | protected function defineConsoleSchedule()
{
Zilf::$container->register(Schedule::class,function (){
return new Schedule();
});
$schedule = Zilf::$container->getShare(Schedule::class);
$this->schedule($schedule);
} | php | protected function defineConsoleSchedule()
{
Zilf::$container->register(Schedule::class,function (){
return new Schedule();
});
$schedule = Zilf::$container->getShare(Schedule::class);
$this->schedule($schedule);
} | [
"protected",
"function",
"defineConsoleSchedule",
"(",
")",
"{",
"Zilf",
"::",
"$",
"container",
"->",
"register",
"(",
"Schedule",
"::",
"class",
",",
"function",
"(",
")",
"{",
"return",
"new",
"Schedule",
"(",
")",
";",
"}",
")",
";",
"$",
"schedule",... | Define the application's command schedule.
@return void | [
"Define",
"the",
"application",
"s",
"command",
"schedule",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Kernel.php#L79-L88 |
txj123/zilf | src/Zilf/Console/Kernel.php | Kernel.getArtisan | protected function getArtisan()
{
if (is_null($this->artisan)) {
return $this->artisan = (new Artisan(Zilf::VERSION))
->resolveCommands($this->commands);
}
return $this->artisan;
} | php | protected function getArtisan()
{
if (is_null($this->artisan)) {
return $this->artisan = (new Artisan(Zilf::VERSION))
->resolveCommands($this->commands);
}
return $this->artisan;
} | [
"protected",
"function",
"getArtisan",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"artisan",
")",
")",
"{",
"return",
"$",
"this",
"->",
"artisan",
"=",
"(",
"new",
"Artisan",
"(",
"Zilf",
"::",
"VERSION",
")",
")",
"->",
"resolveCo... | Get the Artisan application instance.
@return \Zilf\Console\Application | [
"Get",
"the",
"Artisan",
"application",
"instance",
"."
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Kernel.php#L288-L296 |
oxygen-cms/core | src/Html/Toolbar/Factory/FormToolbarItemFactory.php | FormToolbarItemFactory.create | public function create(array $parameters) {
$toolbarItem = new FormToolbarItem($parameters['action']);
unset($parameters['action']);
foreach($parameters as $key => $value) {
$toolbarItem->$key = $value;
}
return $toolbarItem;
} | php | public function create(array $parameters) {
$toolbarItem = new FormToolbarItem($parameters['action']);
unset($parameters['action']);
foreach($parameters as $key => $value) {
$toolbarItem->$key = $value;
}
return $toolbarItem;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"toolbarItem",
"=",
"new",
"FormToolbarItem",
"(",
"$",
"parameters",
"[",
"'action'",
"]",
")",
";",
"unset",
"(",
"$",
"parameters",
"[",
"'action'",
"]",
")",
";",
"foreac... | Creates a new toolbar item using the passed parameters.
@param array $parameters Passed parameters
@return FormToolbarItem | [
"Creates",
"a",
"new",
"toolbar",
"item",
"using",
"the",
"passed",
"parameters",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/Factory/FormToolbarItemFactory.php#L16-L23 |
oxygen-cms/core | src/Html/Toolbar/DropdownToolbarItem.php | DropdownToolbarItem.shouldRender | public function shouldRender(array $arguments = []) {
foreach($this->items as $item) {
if($item->shouldRender($arguments)) {
$this->itemsToDisplay[] = $item;
}
}
$this->shouldRenderButton = $this->button !== null && $this->button->shouldRender($arguments);
// if there any items in the dropdown then we'll display it
// or if the primary action should be displayed
return !empty($this->itemsToDisplay) || $this->shouldRenderButton;
} | php | public function shouldRender(array $arguments = []) {
foreach($this->items as $item) {
if($item->shouldRender($arguments)) {
$this->itemsToDisplay[] = $item;
}
}
$this->shouldRenderButton = $this->button !== null && $this->button->shouldRender($arguments);
// if there any items in the dropdown then we'll display it
// or if the primary action should be displayed
return !empty($this->itemsToDisplay) || $this->shouldRenderButton;
} | [
"public",
"function",
"shouldRender",
"(",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"shouldRender",
"(",
"$",
"arguments",
")",
")",
"... | Determines if the button should be rendered.
@param array $arguments
@return boolean | [
"Determines",
"if",
"the",
"button",
"should",
"be",
"rendered",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/DropdownToolbarItem.php#L110-L122 |
oxygen-cms/core | src/Html/Toolbar/DropdownToolbarItem.php | DropdownToolbarItem.render | public function render(array $arguments = [], $renderer = null) {
if(empty($this->itemsToDisplay)) {
return $this->button->render($arguments);
}
return $this->baseRender($arguments, $renderer);
} | php | public function render(array $arguments = [], $renderer = null) {
if(empty($this->itemsToDisplay)) {
return $this->button->render($arguments);
}
return $this->baseRender($arguments, $renderer);
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"renderer",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"itemsToDisplay",
")",
")",
"{",
"return",
"$",
"this",
"->",
"button",
"->",
"r... | Renders the object.
@param array $arguments
@param RendererInterface|callable $renderer
@throws \Exception
@return string the rendered object | [
"Renders",
"the",
"object",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/DropdownToolbarItem.php#L132-L138 |
dave-redfern/laravel-doctrine-tenancy | src/Console/AbstractTenantCommand.php | AbstractTenantCommand.resolveTenantRoutes | protected function resolveTenantRoutes($domain)
{
if (null === $dt = $this->repository->findOneByDomain($domain)) {
return $this->error(
sprintf('No tenant found for "%s", are you sure you entered the correct domain?', $domain)
);
}
/** @var Tenant $tenant */
$tenant = app('auth.tenant');
$tenant->updateTenancy(new NullUser(), $dt->getTenantOwner(), $dt);
$this->resolver->boot($this->router);
return $this->routes = $this->router->getRoutes();
} | php | protected function resolveTenantRoutes($domain)
{
if (null === $dt = $this->repository->findOneByDomain($domain)) {
return $this->error(
sprintf('No tenant found for "%s", are you sure you entered the correct domain?', $domain)
);
}
/** @var Tenant $tenant */
$tenant = app('auth.tenant');
$tenant->updateTenancy(new NullUser(), $dt->getTenantOwner(), $dt);
$this->resolver->boot($this->router);
return $this->routes = $this->router->getRoutes();
} | [
"protected",
"function",
"resolveTenantRoutes",
"(",
"$",
"domain",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"dt",
"=",
"$",
"this",
"->",
"repository",
"->",
"findOneByDomain",
"(",
"$",
"domain",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"... | @param string $domain
@return RouteCollection | [
"@param",
"string",
"$domain"
] | train | https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Console/AbstractTenantCommand.php#L89-L103 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.getInstance | public static function getInstance($name)
{
$model = sprintf('\\%sAdmin', Str::studly($name));
$model = new $model;
return $model;
} | php | public static function getInstance($name)
{
$model = sprintf('\\%sAdmin', Str::studly($name));
$model = new $model;
return $model;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"name",
")",
"{",
"$",
"model",
"=",
"sprintf",
"(",
"'\\\\%sAdmin'",
",",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
")",
";",
"$",
"model",
"=",
"new",
"$",
"model",
";",
"return",
"$",
... | Get a model instance.
@param string $name
@access public
@return string
@static | [
"Get",
"a",
"model",
"instance",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L164-L170 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.buildList | public function buildList()
{
$this->setListMapper(new ListMapper);
$this->configureList($this->getListMapper());
$this->setListBuilder(new ListBuilder($this->getListMapper()));
$this->getListBuilder()
->setModel($this->getModel())
->build();
return $this;
} | php | public function buildList()
{
$this->setListMapper(new ListMapper);
$this->configureList($this->getListMapper());
$this->setListBuilder(new ListBuilder($this->getListMapper()));
$this->getListBuilder()
->setModel($this->getModel())
->build();
return $this;
} | [
"public",
"function",
"buildList",
"(",
")",
"{",
"$",
"this",
"->",
"setListMapper",
"(",
"new",
"ListMapper",
")",
";",
"$",
"this",
"->",
"configureList",
"(",
"$",
"this",
"->",
"getListMapper",
"(",
")",
")",
";",
"$",
"this",
"->",
"setListBuilder"... | Configures the list fields and builds the list data from that.
@access public
@return Admin | [
"Configures",
"the",
"list",
"fields",
"and",
"builds",
"the",
"list",
"data",
"from",
"that",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L317-L328 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.setListMapper | public function setListMapper(ListMapper $mapper)
{
$this->listMapper = $mapper;
$mapper->setAdmin($this);
return $this;
} | php | public function setListMapper(ListMapper $mapper)
{
$this->listMapper = $mapper;
$mapper->setAdmin($this);
return $this;
} | [
"public",
"function",
"setListMapper",
"(",
"ListMapper",
"$",
"mapper",
")",
"{",
"$",
"this",
"->",
"listMapper",
"=",
"$",
"mapper",
";",
"$",
"mapper",
"->",
"setAdmin",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the ListMapper object.
@param ListMapper $mapper
@access public
@return Admin | [
"Set",
"the",
"ListMapper",
"object",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L338-L343 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.buildForm | public function buildForm($identifier = null)
{
$this->setFormMapper(new FormMapper);
$this->configureForm($this->getFormMapper());
$this->setFormBuilder(new FormBuilder($this->getFormMapper()));
$this->getFormBuilder()
->setModel($this->getModel())
->setIdentifier($identifier)
->setContext($identifier === null ? FormBuilder::CONTEXT_CREATE : FormBuilder::CONTEXT_EDIT)
->build();
return $this;
} | php | public function buildForm($identifier = null)
{
$this->setFormMapper(new FormMapper);
$this->configureForm($this->getFormMapper());
$this->setFormBuilder(new FormBuilder($this->getFormMapper()));
$this->getFormBuilder()
->setModel($this->getModel())
->setIdentifier($identifier)
->setContext($identifier === null ? FormBuilder::CONTEXT_CREATE : FormBuilder::CONTEXT_EDIT)
->build();
return $this;
} | [
"public",
"function",
"buildForm",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setFormMapper",
"(",
"new",
"FormMapper",
")",
";",
"$",
"this",
"->",
"configureForm",
"(",
"$",
"this",
"->",
"getFormMapper",
"(",
")",
")",
";",
"... | Configures the list fields and builds the list data from that.
@access public
@return Admin | [
"Configures",
"the",
"list",
"fields",
"and",
"builds",
"the",
"list",
"data",
"from",
"that",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L400-L413 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.setFormMapper | public function setFormMapper(FormMapper $mapper)
{
$this->formMapper = $mapper;
$mapper->setAdmin($this);
return $this;
} | php | public function setFormMapper(FormMapper $mapper)
{
$this->formMapper = $mapper;
$mapper->setAdmin($this);
return $this;
} | [
"public",
"function",
"setFormMapper",
"(",
"FormMapper",
"$",
"mapper",
")",
"{",
"$",
"this",
"->",
"formMapper",
"=",
"$",
"mapper",
";",
"$",
"mapper",
"->",
"setAdmin",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the FormMapper object.
@param FormMapper $mapper
@access public
@return Admin | [
"Set",
"the",
"FormMapper",
"object",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L423-L428 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.buildFilters | public function buildFilters()
{
$this->setFilterMapper(new FilterMapper);
$this->configureFilters($this->getFilterMapper());
$this->setFilterBuilder(new FilterBuilder($this->getFilterMapper()));
$this->getFilterBuilder()
->build();
return $this;
} | php | public function buildFilters()
{
$this->setFilterMapper(new FilterMapper);
$this->configureFilters($this->getFilterMapper());
$this->setFilterBuilder(new FilterBuilder($this->getFilterMapper()));
$this->getFilterBuilder()
->build();
return $this;
} | [
"public",
"function",
"buildFilters",
"(",
")",
"{",
"$",
"this",
"->",
"setFilterMapper",
"(",
"new",
"FilterMapper",
")",
";",
"$",
"this",
"->",
"configureFilters",
"(",
"$",
"this",
"->",
"getFilterMapper",
"(",
")",
")",
";",
"$",
"this",
"->",
"set... | Configures the filter fields and builds the filter data from that.
@access public
@return Admin | [
"Configures",
"the",
"filter",
"fields",
"and",
"builds",
"the",
"filter",
"data",
"from",
"that",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L485-L495 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Admin.php | Admin.buildScopes | public function buildScopes()
{
$this->setScopeMapper(new ScopeMapper);
$this->configureScopes($this->getScopeMapper());
$this->setScopeBuilder(new FilterBuilder($this->getScopeMapper()));
$this->getScopeBuilder()
->build();
return $this;
} | php | public function buildScopes()
{
$this->setScopeMapper(new ScopeMapper);
$this->configureScopes($this->getScopeMapper());
$this->setScopeBuilder(new FilterBuilder($this->getScopeMapper()));
$this->getScopeBuilder()
->build();
return $this;
} | [
"public",
"function",
"buildScopes",
"(",
")",
"{",
"$",
"this",
"->",
"setScopeMapper",
"(",
"new",
"ScopeMapper",
")",
";",
"$",
"this",
"->",
"configureScopes",
"(",
"$",
"this",
"->",
"getScopeMapper",
"(",
")",
")",
";",
"$",
"this",
"->",
"setScope... | Configures the scopes and builds the scope data from that.
@access public
@return Admin | [
"Configures",
"the",
"scopes",
"and",
"builds",
"the",
"scope",
"data",
"from",
"that",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L567-L577 |
FbF/Laravel-Comments | src/controllers/CommentsController.php | CommentsController.create | public function create()
{
$return = Input::get('return');
if (empty($return))
{
return Redirect::to('/');
}
try {
$commentable = Input::get('commentable');
if (empty($commentable))
{
throw new Exception();
}
$commentable = Crypt::decrypt($commentable);
if (strpos($commentable, '.') == false)
{
throw new Exception();
}
list($commentableType, $commentableId) = explode('.', $commentable);
if (!class_exists($commentableType))
{
throw new Exception();
}
$data = array(
'commentable_type' => $commentableType,
'commentable_id' => $commentableId,
'comment' => Input::get('comment'),
'user_id' => Auth::user()->id,
);
$rules = $this->comment->getRules($commentableType);
$validator = Validator::make($data, $rules);
if ($validator->fails())
{
return Redirect::to($return)->withErrors($validator);
}
$this->comment->fill($data);
$this->comment->save();
$newCommentId = $this->comment->id;
return Redirect::to($return.'#C'.$newCommentId);
} catch (\Exception $e) {
return Redirect::to($return.'#'.trans('laravel-comments::messages.add_form_anchor'))
->with('laravel-comments::error', trans('laravel-comments::messages.unexpected_error'));
}
} | php | public function create()
{
$return = Input::get('return');
if (empty($return))
{
return Redirect::to('/');
}
try {
$commentable = Input::get('commentable');
if (empty($commentable))
{
throw new Exception();
}
$commentable = Crypt::decrypt($commentable);
if (strpos($commentable, '.') == false)
{
throw new Exception();
}
list($commentableType, $commentableId) = explode('.', $commentable);
if (!class_exists($commentableType))
{
throw new Exception();
}
$data = array(
'commentable_type' => $commentableType,
'commentable_id' => $commentableId,
'comment' => Input::get('comment'),
'user_id' => Auth::user()->id,
);
$rules = $this->comment->getRules($commentableType);
$validator = Validator::make($data, $rules);
if ($validator->fails())
{
return Redirect::to($return)->withErrors($validator);
}
$this->comment->fill($data);
$this->comment->save();
$newCommentId = $this->comment->id;
return Redirect::to($return.'#C'.$newCommentId);
} catch (\Exception $e) {
return Redirect::to($return.'#'.trans('laravel-comments::messages.add_form_anchor'))
->with('laravel-comments::error', trans('laravel-comments::messages.unexpected_error'));
}
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"return",
"=",
"Input",
"::",
"get",
"(",
"'return'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"return",
")",
")",
"{",
"return",
"Redirect",
"::",
"to",
"(",
"'/'",
")",
";",
"}",
"try",
"{",
... | Saves a comment
@throws Exception
@return \Redirect | [
"Saves",
"a",
"comment"
] | train | https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/controllers/CommentsController.php#L36-L83 |
railken/search-query | src/Languages/BoomTree/Resolvers/FunctionResolver.php | FunctionResolver.resolveNextNode | public function resolveNextNode(NodeContract $node, NodeContract $new_node)
{
if ($new_node->next() === null) {
throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
}
// Nothing ...
if (!$new_node->getParent() || ($new_node->next() instanceof Nodes\GroupNode)) {
$children = [];
foreach ($new_node->next()->getChildren() as $child) {
if (!(trim($child->getValue()) === ',' && $child instanceof Nodes\TextNode)) {
$children[] = $child;
}
}
$new_node->setChildren($children);
if ($new_node->getParent() !== null) {
$new_node->getParent()->removeChild($new_node->next());
}
} else {
throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
}
} | php | public function resolveNextNode(NodeContract $node, NodeContract $new_node)
{
if ($new_node->next() === null) {
throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
}
// Nothing ...
if (!$new_node->getParent() || ($new_node->next() instanceof Nodes\GroupNode)) {
$children = [];
foreach ($new_node->next()->getChildren() as $child) {
if (!(trim($child->getValue()) === ',' && $child instanceof Nodes\TextNode)) {
$children[] = $child;
}
}
$new_node->setChildren($children);
if ($new_node->getParent() !== null) {
$new_node->getParent()->removeChild($new_node->next());
}
} else {
throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
}
} | [
"public",
"function",
"resolveNextNode",
"(",
"NodeContract",
"$",
"node",
",",
"NodeContract",
"$",
"new_node",
")",
"{",
"if",
"(",
"$",
"new_node",
"->",
"next",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"QuerySyntaxException"... | Resolve next node match.
@param NodeContract $node
@param NodeContract $new_node | [
"Resolve",
"next",
"node",
"match",
"."
] | train | https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/FunctionResolver.php#L43-L67 |
white-frame/dynatable | src/DynatableServiceProvider.php | DynatableServiceProvider.boot | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'white-frame-dynatable');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'dynatable');
if (wf()) {
Widget::register('dynatable', \WhiteFrame\Dynatable\Widgets\DynatableWidget::class);
}
$this->registerRepositoryMacros();
} | php | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'white-frame-dynatable');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'dynatable');
if (wf()) {
Widget::register('dynatable', \WhiteFrame\Dynatable\Widgets\DynatableWidget::class);
}
$this->registerRepositoryMacros();
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/../resources/views'",
",",
"'white-frame-dynatable'",
")",
";",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"__DIR__",
".",
"'/../resources/lang'",
",",
... | Perform post-registration booting of services.
@return void | [
"Perform",
"post",
"-",
"registration",
"booting",
"of",
"services",
"."
] | train | https://github.com/white-frame/dynatable/blob/823bcab67e0dc890a4545361dfdc22f48065b2f6/src/DynatableServiceProvider.php#L35-L45 |
maniaplanet/dedicated-server-api | libraries/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php | GbxRemote.setTimeouts | function setTimeouts($read = 0, $write = 0)
{
if ($read) {
$this->readTimeout['sec'] = (int)($read / 1000);
$this->readTimeout['usec'] = ($read % 1000) * 1000;
}
if ($write) {
$this->writeTimeout['sec'] = (int)($write / 1000);
$this->writeTimeout['usec'] = ($write % 1000) * 1000;
}
} | php | function setTimeouts($read = 0, $write = 0)
{
if ($read) {
$this->readTimeout['sec'] = (int)($read / 1000);
$this->readTimeout['usec'] = ($read % 1000) * 1000;
}
if ($write) {
$this->writeTimeout['sec'] = (int)($write / 1000);
$this->writeTimeout['usec'] = ($write % 1000) * 1000;
}
} | [
"function",
"setTimeouts",
"(",
"$",
"read",
"=",
"0",
",",
"$",
"write",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"read",
")",
"{",
"$",
"this",
"->",
"readTimeout",
"[",
"'sec'",
"]",
"=",
"(",
"int",
")",
"(",
"$",
"read",
"/",
"1000",
")",
";"... | Change timeouts
@param int $read read timeout (in ms), 0 to leave unchanged
@param int $write write timeout (in ms), 0 to leave unchanged | [
"Change",
"timeouts"
] | train | https://github.com/maniaplanet/dedicated-server-api/blob/c42664b21739fd6335cf2ecfe1907a0eca07c1da/libraries/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php#L123-L133 |
damonjones/Vebra-PHP-API-Wrapper | lib/YDD/Vebra/Model/BranchSummary.php | BranchSummary.getClientId | public function getClientId()
{
if ($this->url) {
return (int) substr($this->url, strrpos($this->url, '/') + 1);
}
} | php | public function getClientId()
{
if ($this->url) {
return (int) substr($this->url, strrpos($this->url, '/') + 1);
}
} | [
"public",
"function",
"getClientId",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"url",
")",
"{",
"return",
"(",
"int",
")",
"substr",
"(",
"$",
"this",
"->",
"url",
",",
"strrpos",
"(",
"$",
"this",
"->",
"url",
",",
"'/'",
")",
"+",
"1",
")"... | get ClientId
@return int $clientId | [
"get",
"ClientId"
] | train | https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/Model/BranchSummary.php#L126-L131 |
Josantonius/PHP-File | src/File.php | File.exists | public static function exists($file)
{
if (filter_var($file, FILTER_VALIDATE_URL)) {
$stream = stream_context_create(['http' => ['method' => 'HEAD']]);
if ($content = @fopen($file, 'r', null, $stream)) {
$headers = stream_get_meta_data($content);
fclose($content);
$status = substr($headers['wrapper_data'][0], 9, 3);
return $status >= 200 && $status < 400;
}
return false;
}
return file_exists($file) && is_file($file);
} | php | public static function exists($file)
{
if (filter_var($file, FILTER_VALIDATE_URL)) {
$stream = stream_context_create(['http' => ['method' => 'HEAD']]);
if ($content = @fopen($file, 'r', null, $stream)) {
$headers = stream_get_meta_data($content);
fclose($content);
$status = substr($headers['wrapper_data'][0], 9, 3);
return $status >= 200 && $status < 400;
}
return false;
}
return file_exists($file) && is_file($file);
} | [
"public",
"static",
"function",
"exists",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"file",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"$",
"stream",
"=",
"stream_context_create",
"(",
"[",
"'http'",
"=>",
"[",
"'method'",
"=>",
"'HE... | Check if a file exists in a path or url.
@since 1.1.3
@param string $file → path or file url
@return bool | [
"Check",
"if",
"a",
"file",
"exists",
"in",
"a",
"path",
"or",
"url",
"."
] | train | https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L27-L43 |
Josantonius/PHP-File | src/File.php | File.copyDirRecursively | public static function copyDirRecursively($from, $to)
{
if (! $path = self::getFilesFromDir($from)) {
return false;
}
self::createDir($to = rtrim($to, '/') . '/');
foreach ($path as $file) {
if ($file->isFile()) {
if (! copy($file->getRealPath(), $to . $file->getFilename())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::copyDirRecursively($file->getRealPath(), $to . $path);
}
}
return true;
} | php | public static function copyDirRecursively($from, $to)
{
if (! $path = self::getFilesFromDir($from)) {
return false;
}
self::createDir($to = rtrim($to, '/') . '/');
foreach ($path as $file) {
if ($file->isFile()) {
if (! copy($file->getRealPath(), $to . $file->getFilename())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::copyDirRecursively($file->getRealPath(), $to . $path);
}
}
return true;
} | [
"public",
"static",
"function",
"copyDirRecursively",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"if",
"(",
"!",
"$",
"path",
"=",
"self",
"::",
"getFilesFromDir",
"(",
"$",
"from",
")",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"createDi... | Copy directory recursively.
@since 1.1.4
@param string $fromPath → path from copy
@param string $toPath → path to copy
@return bool | [
"Copy",
"directory",
"recursively",
"."
] | train | https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L83-L102 |
Josantonius/PHP-File | src/File.php | File.deleteDirRecursively | public static function deleteDirRecursively($path)
{
if (! $paths = self::getFilesFromDir($path)) {
return false;
}
foreach ($paths as $file) {
if ($file->isFile()) {
if (! self::delete($file->getRealPath())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::deleteDirRecursively($file->getRealPath());
self::deleteEmptyDir($file->getRealPath());
}
}
return self::deleteEmptyDir($path);
} | php | public static function deleteDirRecursively($path)
{
if (! $paths = self::getFilesFromDir($path)) {
return false;
}
foreach ($paths as $file) {
if ($file->isFile()) {
if (! self::delete($file->getRealPath())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::deleteDirRecursively($file->getRealPath());
self::deleteEmptyDir($file->getRealPath());
}
}
return self::deleteEmptyDir($path);
} | [
"public",
"static",
"function",
"deleteDirRecursively",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"paths",
"=",
"self",
"::",
"getFilesFromDir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"paths",
"as",
... | Delete directory recursively.
@since 1.1.3
@param string $path → path to delete
@return bool | [
"Delete",
"directory",
"recursively",
"."
] | train | https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L127-L145 |
silverstripe/comment-notifications | src/Extensions/CommentNotifiable.php | CommentNotifiable.notificationRecipients | public function notificationRecipients($comment)
{
$list = [];
if ($adminEmail = Email::config()->admin_email) {
$list[] = $adminEmail;
}
$this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
return $list;
} | php | public function notificationRecipients($comment)
{
$list = [];
if ($adminEmail = Email::config()->admin_email) {
$list[] = $adminEmail;
}
$this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
return $list;
} | [
"public",
"function",
"notificationRecipients",
"(",
"$",
"comment",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"adminEmail",
"=",
"Email",
"::",
"config",
"(",
")",
"->",
"admin_email",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"a... | Return the list of members or emails to send comment notifications to
@param Comment $comment
@return array|Traversable | [
"Return",
"the",
"list",
"of",
"members",
"or",
"emails",
"to",
"send",
"comment",
"notifications",
"to"
] | train | https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L44-L55 |
silverstripe/comment-notifications | src/Extensions/CommentNotifiable.php | CommentNotifiable.notificationSubject | public function notificationSubject($comment, $recipient)
{
$subject = $this->owner->config()->default_notification_subject;
$this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
return $subject;
} | php | public function notificationSubject($comment, $recipient)
{
$subject = $this->owner->config()->default_notification_subject;
$this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
return $subject;
} | [
"public",
"function",
"notificationSubject",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"subject",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_subject",
";",
"$",
"this",
"->",
"owner",
"->",
"invo... | Gets the email subject line for comment notifications
@param Comment $comment Comment
@param Member|string $recipient
@return string | [
"Gets",
"the",
"email",
"subject",
"line",
"for",
"comment",
"notifications"
] | train | https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L64-L71 |
silverstripe/comment-notifications | src/Extensions/CommentNotifiable.php | CommentNotifiable.notificationSender | public function notificationSender($comment, $recipient)
{
$sender = $this->owner->config()->default_notification_sender;
// Do hostname substitution
$host = isset($_SERVER['HTTP_HOST'])
? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
: 'localhost';
$sender = preg_replace('/{host}/', $host, $sender);
$this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
return $sender;
} | php | public function notificationSender($comment, $recipient)
{
$sender = $this->owner->config()->default_notification_sender;
// Do hostname substitution
$host = isset($_SERVER['HTTP_HOST'])
? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
: 'localhost';
$sender = preg_replace('/{host}/', $host, $sender);
$this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
return $sender;
} | [
"public",
"function",
"notificationSender",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"sender",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_sender",
";",
"// Do hostname substitution",
"$",
"host",
"=... | Get the sender email address to use for email notifications
@param Comment $comment
@param Member|string $recipient
@return string | [
"Get",
"the",
"sender",
"email",
"address",
"to",
"use",
"for",
"email",
"notifications"
] | train | https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L80-L93 |
silverstripe/comment-notifications | src/Extensions/CommentNotifiable.php | CommentNotifiable.notificationTemplate | public function notificationTemplate($comment, $recipient)
{
$template = $this->owner->config()->default_notification_template;
$this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
return $template;
} | php | public function notificationTemplate($comment, $recipient)
{
$template = $this->owner->config()->default_notification_template;
$this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
return $template;
} | [
"public",
"function",
"notificationTemplate",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_template",
";",
"$",
"this",
"->",
"owner",
"->",
"i... | Determine the template to use for this email
@param Comment $comment
@param Member|string $recipient
@return string Template name (excluding .ss extension) | [
"Determine",
"the",
"template",
"to",
"use",
"for",
"this",
"email"
] | train | https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L102-L109 |
oxygen-cms/core | src/Html/Editor/Editor.php | Editor.getCreateScript | public function getCreateScript() {
static::$includeScripts = true;
$text = '<script>';
$text .= 'editors = ( typeof editors != "undefined" && editors instanceof Array ) ? editors : [];';
$text .= 'editors.push({';
$text .= 'name: "' . $this->name . '",';
$text .= 'stylesheets: ' . json_encode($this->stylesheets) . ',';
foreach($this->options as $key => $value) {
$text .= $key . ': "' . $value . '",';
}
$text .= '});</script>';
return $text;
} | php | public function getCreateScript() {
static::$includeScripts = true;
$text = '<script>';
$text .= 'editors = ( typeof editors != "undefined" && editors instanceof Array ) ? editors : [];';
$text .= 'editors.push({';
$text .= 'name: "' . $this->name . '",';
$text .= 'stylesheets: ' . json_encode($this->stylesheets) . ',';
foreach($this->options as $key => $value) {
$text .= $key . ': "' . $value . '",';
}
$text .= '});</script>';
return $text;
} | [
"public",
"function",
"getCreateScript",
"(",
")",
"{",
"static",
"::",
"$",
"includeScripts",
"=",
"true",
";",
"$",
"text",
"=",
"'<script>'",
";",
"$",
"text",
".=",
"'editors = ( typeof editors != \"undefined\" && editors instanceof Array ) ? editors : [];'",
";",
"... | Returns the JavaScript code used to
initialise a Editor for the given information.
@return string | [
"Returns",
"the",
"JavaScript",
"code",
"used",
"to",
"initialise",
"a",
"Editor",
"for",
"the",
"given",
"information",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Editor/Editor.php#L161-L177 |
krafthaus/bauhaus | src/KraftHaus/Bauhaus/Field/BelongsToField.php | BelongsToField.render | public function render()
{
if ($this->getDisplayField() === null) {
throw new \InvalidArgumentException(sprintf('Please provide a display field for the `%s` relation via the display(); method.', $this->getName()));
}
switch ($this->getContext()) {
case BaseField::CONTEXT_LIST:
$value = $this->getValue();
return $value->{$this->getDisplayField()};
break;
case BaseField::CONTEXT_FILTER:
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
$primaryKey = $baseModel->getKeyName();
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
$items = [];
foreach ($relatedModel::all() as $item) {
$items[$item->{$primaryKey}] = $item->{$this->getDisplayField()};
}
$column = Str::singular($relatedModel->getTable()) . '_id';
if (Input::has($column)) {
$this->setValue(Input::get($column));
}
return View::make('krafthaus/bauhaus::models.fields._belongs_to')
->with('field', $this)
->with('items', $items);
break;
case BaseField::CONTEXT_FORM:
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
$primaryKey = $baseModel->getKeyName();
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
$items = [];
foreach ($relatedModel::all() as $item) {
$items[$item->{$primaryKey}] = $item->{$this->getDisplayField()};
}
if ($this->getValue() !== null) {
$this->setValue($this->getValue()->{$primaryKey});
}
return View::make('krafthaus/bauhaus::models.fields._belongs_to')
->with('field', $this)
->with('items', $items);
break;
}
return $this->getValue();
} | php | public function render()
{
if ($this->getDisplayField() === null) {
throw new \InvalidArgumentException(sprintf('Please provide a display field for the `%s` relation via the display(); method.', $this->getName()));
}
switch ($this->getContext()) {
case BaseField::CONTEXT_LIST:
$value = $this->getValue();
return $value->{$this->getDisplayField()};
break;
case BaseField::CONTEXT_FILTER:
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
$primaryKey = $baseModel->getKeyName();
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
$items = [];
foreach ($relatedModel::all() as $item) {
$items[$item->{$primaryKey}] = $item->{$this->getDisplayField()};
}
$column = Str::singular($relatedModel->getTable()) . '_id';
if (Input::has($column)) {
$this->setValue(Input::get($column));
}
return View::make('krafthaus/bauhaus::models.fields._belongs_to')
->with('field', $this)
->with('items', $items);
break;
case BaseField::CONTEXT_FORM:
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
$primaryKey = $baseModel->getKeyName();
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
$items = [];
foreach ($relatedModel::all() as $item) {
$items[$item->{$primaryKey}] = $item->{$this->getDisplayField()};
}
if ($this->getValue() !== null) {
$this->setValue($this->getValue()->{$primaryKey});
}
return View::make('krafthaus/bauhaus::models.fields._belongs_to')
->with('field', $this)
->with('items', $items);
break;
}
return $this->getValue();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDisplayField",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Please provide a display field for the `%s` relation via the d... | Render the field.
@access public
@return mixed|string | [
"Render",
"the",
"field",
"."
] | train | https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/BelongsToField.php#L32-L90 |
Superbalist/php-pubsub-http | src/HTTPPubSubAdapter.php | HTTPPubSubAdapter.createRequest | protected function createRequest($method, $endpoint, $body = null, array $headers = [])
{
$uri = rtrim($this->uri, '/') . '/' . trim($endpoint, '/');
$headers = array_merge($this->getGlobalHeaders(), $headers);
return new Request($method, $uri, $headers, $body);
} | php | protected function createRequest($method, $endpoint, $body = null, array $headers = [])
{
$uri = rtrim($this->uri, '/') . '/' . trim($endpoint, '/');
$headers = array_merge($this->getGlobalHeaders(), $headers);
return new Request($method, $uri, $headers, $body);
} | [
"protected",
"function",
"createRequest",
"(",
"$",
"method",
",",
"$",
"endpoint",
",",
"$",
"body",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"uri",
",",
"'/'",
")",
".... | Create an HTTP request object.
@param string $method
@param string $endpoint
@param mixed $body
@param array $headers
@return Request | [
"Create",
"an",
"HTTP",
"request",
"object",
"."
] | train | https://github.com/Superbalist/php-pubsub-http/blob/fd7e7d7a3b2bc858b79117a9fc3af2cb2e9e83f1/src/HTTPPubSubAdapter.php#L124-L129 |
Superbalist/php-pubsub-http | src/HTTPPubSubAdapter.php | HTTPPubSubAdapter.sendRequest | protected function sendRequest(RequestInterface $request)
{
$response = $this->client->send($request);
/* @var \Psr\Http\Message\ResponseInterface $response */
return json_decode($response->getBody(), true);
} | php | protected function sendRequest(RequestInterface $request)
{
$response = $this->client->send($request);
/* @var \Psr\Http\Message\ResponseInterface $response */
return json_decode($response->getBody(), true);
} | [
"protected",
"function",
"sendRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"/* @var \\Psr\\Http\\Message\\ResponseInterface $response */",
"return",
"json... | Send an HTTP request.
@param RequestInterface $request
@return array | [
"Send",
"an",
"HTTP",
"request",
"."
] | train | https://github.com/Superbalist/php-pubsub-http/blob/fd7e7d7a3b2bc858b79117a9fc3af2cb2e9e83f1/src/HTTPPubSubAdapter.php#L138-L144 |
Superbalist/php-pubsub-http | src/HTTPPubSubAdapter.php | HTTPPubSubAdapter.post | public function post($endpoint, array $data = [])
{
$body = json_encode($data);
$request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
return $this->sendRequest($request);
} | php | public function post($endpoint, array $data = [])
{
$body = json_encode($data);
$request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
return $this->sendRequest($request);
} | [
"public",
"function",
"post",
"(",
"$",
"endpoint",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"body",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'POST'",
",",
"$",
... | Make an HTTP POST request.
@param string $endpoint
@param array $data
@return mixed | [
"Make",
"an",
"HTTP",
"POST",
"request",
"."
] | train | https://github.com/Superbalist/php-pubsub-http/blob/fd7e7d7a3b2bc858b79117a9fc3af2cb2e9e83f1/src/HTTPPubSubAdapter.php#L154-L159 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.run | public function run()
{
$table = \Input::get('table');
$field = \Input::get('field');
$name = \Input::get('name');
$rowId = \Input::get('id');
$dataContainer = $this->initializeDataContainer($table, $field);
$this->loadRow($table, $rowId, $dataContainer);
$template = $this->prepareTemplate();
$template->table = $table;
$template->field = $field;
$template->name = $name;
$template->icon = $dataContainer->activeRecord->$field;
$template->icons = $this->generateIcons($field);
$template->output();
} | php | public function run()
{
$table = \Input::get('table');
$field = \Input::get('field');
$name = \Input::get('name');
$rowId = \Input::get('id');
$dataContainer = $this->initializeDataContainer($table, $field);
$this->loadRow($table, $rowId, $dataContainer);
$template = $this->prepareTemplate();
$template->table = $table;
$template->field = $field;
$template->name = $name;
$template->icon = $dataContainer->activeRecord->$field;
$template->icons = $this->generateIcons($field);
$template->output();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"table",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'table'",
")",
";",
"$",
"field",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'field'",
")",
";",
"$",
"name",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'n... | Run the controller.
@throws \RuntimeException If an invalid call is made.
@return void
@SuppressWarnings(PHPMD.Superglobals) | [
"Run",
"the",
"controller",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L51-L70 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.prepareTemplate | private function prepareTemplate()
{
$template = new \BackendTemplate('be_iconwizard');
$template->headline = $GLOBALS['TL_LANG']['MSC']['iconWizard'][1];
$template->searchLabel = $GLOBALS['TL_LANG']['MSC']['iconWizardSearch'][0];
$template->searchPlaceholder = $GLOBALS['TL_LANG']['MSC']['iconWizardSearch'][1];
$template->reset = $GLOBALS['TL_LANG']['MSC']['iconWizardReset'][0];
$template->resetTitle = $GLOBALS['TL_LANG']['MSC']['iconWizardReset'][1];
$template->theme = $this->getTheme();
$template->base = $this->Environment->base;
$template->language = $GLOBALS['TL_LANGUAGE'];
$template->title = $GLOBALS['TL_CONFIG']['websiteTitle'];
$template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
$template->error = (\Input::get('act') == 'error') ? $GLOBALS['TL_LANG']['ERR']['general'] : '';
$template->skipNavigation = $GLOBALS['TL_LANG']['MSC']['skipNavigation'];
$template->request = ampersand($this->Environment->request);
$template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
$template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
$template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
return $template;
} | php | private function prepareTemplate()
{
$template = new \BackendTemplate('be_iconwizard');
$template->headline = $GLOBALS['TL_LANG']['MSC']['iconWizard'][1];
$template->searchLabel = $GLOBALS['TL_LANG']['MSC']['iconWizardSearch'][0];
$template->searchPlaceholder = $GLOBALS['TL_LANG']['MSC']['iconWizardSearch'][1];
$template->reset = $GLOBALS['TL_LANG']['MSC']['iconWizardReset'][0];
$template->resetTitle = $GLOBALS['TL_LANG']['MSC']['iconWizardReset'][1];
$template->theme = $this->getTheme();
$template->base = $this->Environment->base;
$template->language = $GLOBALS['TL_LANGUAGE'];
$template->title = $GLOBALS['TL_CONFIG']['websiteTitle'];
$template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$template->pageOffset = \Input::cookie('BE_PAGE_OFFSET');
$template->error = (\Input::get('act') == 'error') ? $GLOBALS['TL_LANG']['ERR']['general'] : '';
$template->skipNavigation = $GLOBALS['TL_LANG']['MSC']['skipNavigation'];
$template->request = ampersand($this->Environment->request);
$template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
$template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode'];
$template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode'];
return $template;
} | [
"private",
"function",
"prepareTemplate",
"(",
")",
"{",
"$",
"template",
"=",
"new",
"\\",
"BackendTemplate",
"(",
"'be_iconwizard'",
")",
";",
"$",
"template",
"->",
"headline",
"=",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'iconWi... | Prepare the template.
@return \BackendTemplate
@SuppressWarnings(PHPMD.Superglobals) | [
"Prepare",
"the",
"template",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L78-L101 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.initializeDataContainer | private function initializeDataContainer($table, $field)
{
// Define the current ID
if (!defined('CURRENT_ID')) {
define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
}
static::loadDataContainer($table);
$this->dca = &$GLOBALS['TL_DCA'][$table];
$driverClass = 'DC_' . $this->dca['config']['dataContainer'];
$dataContainer = new $driverClass($table);
$dataContainer->field = $field;
if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
}
$values = $dataContainer->activeRecord->$field;
// Call the load_callback
if (is_array($this->dca['fields'][$field]['load_callback'])) {
foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
$values = $this->triggerCallback($callback, array($values, $dataContainer));
}
}
// support options callback
if (isset($this->dca['fields'][$field]['options_callback'])) {
$this->dca['fields'][$field]['options'] = $this->triggerCallback(
$this->dca['fields'][$field]['options_callback'],
array($dataContainer)
);
}
return $dataContainer;
} | php | private function initializeDataContainer($table, $field)
{
// Define the current ID
if (!defined('CURRENT_ID')) {
define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
}
static::loadDataContainer($table);
$this->dca = &$GLOBALS['TL_DCA'][$table];
$driverClass = 'DC_' . $this->dca['config']['dataContainer'];
$dataContainer = new $driverClass($table);
$dataContainer->field = $field;
if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
}
$values = $dataContainer->activeRecord->$field;
// Call the load_callback
if (is_array($this->dca['fields'][$field]['load_callback'])) {
foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
$values = $this->triggerCallback($callback, array($values, $dataContainer));
}
}
// support options callback
if (isset($this->dca['fields'][$field]['options_callback'])) {
$this->dca['fields'][$field]['options'] = $this->triggerCallback(
$this->dca['fields'][$field]['options_callback'],
array($dataContainer)
);
}
return $dataContainer;
} | [
"private",
"function",
"initializeDataContainer",
"(",
"$",
"table",
",",
"$",
"field",
")",
"{",
"// Define the current ID",
"if",
"(",
"!",
"defined",
"(",
"'CURRENT_ID'",
")",
")",
"{",
"define",
"(",
"'CURRENT_ID'",
",",
"$",
"table",
"?",
"\\",
"Session... | Initialize the data container driver.
@param string $table The table name.
@param string $field The field name.
@return \DataContainer
@throws \RuntimeException If the field does not exists.
@SuppressWarnings(PHPMD.Superglobals) | [
"Initialize",
"the",
"data",
"container",
"driver",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L113-L150 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.loadRow | private function loadRow($table, $rowId, $dataContainer)
{
$dataContainer->activeRecord = $this->Database
->prepare(sprintf('SELECT * FROM %s WHERE id=?', $table))
->limit(1)
->execute($rowId);
if ($dataContainer->activeRecord->numRows != 1) {
throw new \RuntimeException('Selected entry does not exists');
}
} | php | private function loadRow($table, $rowId, $dataContainer)
{
$dataContainer->activeRecord = $this->Database
->prepare(sprintf('SELECT * FROM %s WHERE id=?', $table))
->limit(1)
->execute($rowId);
if ($dataContainer->activeRecord->numRows != 1) {
throw new \RuntimeException('Selected entry does not exists');
}
} | [
"private",
"function",
"loadRow",
"(",
"$",
"table",
",",
"$",
"rowId",
",",
"$",
"dataContainer",
")",
"{",
"$",
"dataContainer",
"->",
"activeRecord",
"=",
"$",
"this",
"->",
"Database",
"->",
"prepare",
"(",
"sprintf",
"(",
"'SELECT * FROM %s WHERE id=?'",
... | Load the data row.
@param string $table The table name.
@param int $rowId The row id.
@param \DataContainer $dataContainer The data container.
@return void
@throws \RuntimeException If no data row is found. | [
"Load",
"the",
"data",
"row",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L162-L172 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.generateIcons | private function generateIcons($field)
{
$icons = array();
$iconTemplate = isset($this->dca['fields'][$field]['eval']['iconTemplate']) ?
$this->dca['fields'][$field]['eval']['iconTemplate'] :
$GLOBALS['TL_CONFIG']['iconWizardIconTemplate'];
foreach ((array) $this->dca['fields'][$field]['options'] as $groupName => $groupIcons) {
foreach ($groupIcons as $icon) {
$icons[$groupName][] = array(
'title' => $icon,
'generated' => sprintf($iconTemplate, $icon),
);
}
}
return $icons;
} | php | private function generateIcons($field)
{
$icons = array();
$iconTemplate = isset($this->dca['fields'][$field]['eval']['iconTemplate']) ?
$this->dca['fields'][$field]['eval']['iconTemplate'] :
$GLOBALS['TL_CONFIG']['iconWizardIconTemplate'];
foreach ((array) $this->dca['fields'][$field]['options'] as $groupName => $groupIcons) {
foreach ($groupIcons as $icon) {
$icons[$groupName][] = array(
'title' => $icon,
'generated' => sprintf($iconTemplate, $icon),
);
}
}
return $icons;
} | [
"private",
"function",
"generateIcons",
"(",
"$",
"field",
")",
"{",
"$",
"icons",
"=",
"array",
"(",
")",
";",
"$",
"iconTemplate",
"=",
"isset",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'eval'",
"]",
"[",... | Generate the icons.
@param string $field The icons.
@return array
@SuppressWarnings(PHPMD.Superglobals) | [
"Generate",
"the",
"icons",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L182-L200 |
netzmacht/contao-icon-wizard | src/WizardController.php | WizardController.triggerCallback | private function triggerCallback($callback, $arguments)
{
if (is_array($callback)) {
$this->import($callback[0]);
return call_user_func_array(array($this->{$callback[0]}, $callback[1]), $arguments);
} elseif (is_callable($callback)) {
return call_user_func_array($callback, $arguments);
}
return null;
} | php | private function triggerCallback($callback, $arguments)
{
if (is_array($callback)) {
$this->import($callback[0]);
return call_user_func_array(array($this->{$callback[0]}, $callback[1]), $arguments);
} elseif (is_callable($callback)) {
return call_user_func_array($callback, $arguments);
}
return null;
} | [
"private",
"function",
"triggerCallback",
"(",
"$",
"callback",
",",
"$",
"arguments",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"this",
"->",
"import",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
";",
"return",
"call_u... | Trigger callback.
@param array|callable $callback Callback to trigger.
@param array $arguments Callback arguments.
@return mixed | [
"Trigger",
"callback",
"."
] | train | https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L210-L220 |
txj123/zilf | src/Zilf/Routing/RuleName.php | RuleName.set | public function set($name, $value, $first = false)
{
if ($first && isset($this->item[$name])) {
array_unshift($this->item[$name], $value);
} else {
$this->item[$name][] = $value;
}
} | php | public function set($name, $value, $first = false)
{
if ($first && isset($this->item[$name])) {
array_unshift($this->item[$name], $value);
} else {
$this->item[$name][] = $value;
}
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"first",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"first",
"&&",
"isset",
"(",
"$",
"this",
"->",
"item",
"[",
"$",
"name",
"]",
")",
")",
"{",
"array_unshift",
"(",
"$"... | 注册路由标识
@access public
@param string $name 路由标识
@param array $value 路由规则
@param bool $first 是否置顶
@return void | [
"注册路由标识"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RuleName.php#L27-L34 |
txj123/zilf | src/Zilf/Routing/RuleName.php | RuleName.setRule | public function setRule($rule, $route)
{
$this->rule[$route->getDomain()][$rule][$route->getMethod()] = $route;
} | php | public function setRule($rule, $route)
{
$this->rule[$route->getDomain()][$rule][$route->getMethod()] = $route;
} | [
"public",
"function",
"setRule",
"(",
"$",
"rule",
",",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"rule",
"[",
"$",
"route",
"->",
"getDomain",
"(",
")",
"]",
"[",
"$",
"rule",
"]",
"[",
"$",
"route",
"->",
"getMethod",
"(",
")",
"]",
"=",
"$"... | 注册路由规则
@access public
@param string $rule 路由规则
@param RuleItem $route 路由
@return void | [
"注册路由规则"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RuleName.php#L43-L46 |
txj123/zilf | src/Zilf/Routing/RuleName.php | RuleName.getRule | public function getRule($rule, $domain = null)
{
return isset($this->rule[$domain][$rule]) ? $this->rule[$domain][$rule] : [];
} | php | public function getRule($rule, $domain = null)
{
return isset($this->rule[$domain][$rule]) ? $this->rule[$domain][$rule] : [];
} | [
"public",
"function",
"getRule",
"(",
"$",
"rule",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"rule",
"[",
"$",
"domain",
"]",
"[",
"$",
"rule",
"]",
")",
"?",
"$",
"this",
"->",
"rule",
"[",
"$",
"dom... | 根据路由规则获取路由对象(列表)
@access public
@param string $name 路由标识
@param string $domain 域名
@return array | [
"根据路由规则获取路由对象(列表)"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RuleName.php#L55-L58 |
txj123/zilf | src/Zilf/Routing/RuleName.php | RuleName.getRuleList | public function getRuleList($domain = null)
{
$list = [];
foreach ($this->rule as $ruleDomain => $rules) {
foreach ($rules as $rule => $items) {
foreach ($items as $item) {
$val['domain'] = $ruleDomain;
foreach (['method', 'rule', 'name', 'route', 'pattern', 'option'] as $param) {
$call = 'get' . $param;
$val[$param] = $item->$call();
}
$list[$ruleDomain][] = $val;
}
}
}
if ($domain) {
return isset($list[$domain]) ? $list[$domain] : [];
}
return $list;
} | php | public function getRuleList($domain = null)
{
$list = [];
foreach ($this->rule as $ruleDomain => $rules) {
foreach ($rules as $rule => $items) {
foreach ($items as $item) {
$val['domain'] = $ruleDomain;
foreach (['method', 'rule', 'name', 'route', 'pattern', 'option'] as $param) {
$call = 'get' . $param;
$val[$param] = $item->$call();
}
$list[$ruleDomain][] = $val;
}
}
}
if ($domain) {
return isset($list[$domain]) ? $list[$domain] : [];
}
return $list;
} | [
"public",
"function",
"getRuleList",
"(",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rule",
"as",
"$",
"ruleDomain",
"=>",
"$",
"rules",
")",
"{",
"foreach",
"(",
"$",
"rules",
"as",
... | 获取全部路由列表
@access public
@param string $domain 域名
@return array | [
"获取全部路由列表"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RuleName.php#L66-L90 |
txj123/zilf | src/Zilf/Routing/RuleName.php | RuleName.get | public function get($name = null, $domain = null, $method = '*')
{
if (is_null($name)) {
return $this->item;
}
$name = strtolower($name);
$method = strtolower($method);
if (isset($this->item[$name])) {
if (is_null($domain)) {
$result = $this->item[$name];
} else {
$result = [];
foreach ($this->item[$name] as $item) {
if ($item[2] == $domain && ('*' == $item[4] || $method == $item[4])) {
$result[] = $item;
}
}
}
} else {
$result = null;
}
return $result;
} | php | public function get($name = null, $domain = null, $method = '*')
{
if (is_null($name)) {
return $this->item;
}
$name = strtolower($name);
$method = strtolower($method);
if (isset($this->item[$name])) {
if (is_null($domain)) {
$result = $this->item[$name];
} else {
$result = [];
foreach ($this->item[$name] as $item) {
if ($item[2] == $domain && ('*' == $item[4] || $method == $item[4])) {
$result[] = $item;
}
}
}
} else {
$result = null;
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"method",
"=",
"'*'",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"item",
";",
"}",
"$",
... | 根据路由标识获取路由信息(用于URL生成)
@access public
@param string $name 路由标识
@param string $domain 域名
@return array|null | [
"根据路由标识获取路由信息(用于URL生成)"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/RuleName.php#L110-L135 |
FbF/Laravel-Comments | src/models/Comment.php | Comment.getOnTitleAttribute | public function getOnTitleAttribute()
{
$commentable = $this->commentable;
if ( ! is_object($commentable) || ! method_exists($commentable, 'getAttributes') )
{
return FALSE;
}
$attributes = $commentable->getAttributes();
if (method_exists($commentable, 'getCommentableTitle'))
{
$on = $commentable->getCommentableTitle();
}
elseif (array_key_exists('title', $attributes))
{
$on = $attributes['title'];
}
elseif (array_key_exists('name', $attributes))
{
$on = $attributes['name'];
}
else
{
throw new \Exception(sprintf('%s model does not have title or name attribute, nor implements getCommentableTitle() method', get_class($commentable)));
}
return \Str::limit($on, 50);
} | php | public function getOnTitleAttribute()
{
$commentable = $this->commentable;
if ( ! is_object($commentable) || ! method_exists($commentable, 'getAttributes') )
{
return FALSE;
}
$attributes = $commentable->getAttributes();
if (method_exists($commentable, 'getCommentableTitle'))
{
$on = $commentable->getCommentableTitle();
}
elseif (array_key_exists('title', $attributes))
{
$on = $attributes['title'];
}
elseif (array_key_exists('name', $attributes))
{
$on = $attributes['name'];
}
else
{
throw new \Exception(sprintf('%s model does not have title or name attribute, nor implements getCommentableTitle() method', get_class($commentable)));
}
return \Str::limit($on, 50);
} | [
"public",
"function",
"getOnTitleAttribute",
"(",
")",
"{",
"$",
"commentable",
"=",
"$",
"this",
"->",
"commentable",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"commentable",
")",
"||",
"!",
"method_exists",
"(",
"$",
"commentable",
",",
"'getAttributes'"... | Returns a string representing the record that the comment was on. This is normally the name or title field of the
commentable model. E.g. the title of the Blog Post. The method checks to see if the commentable model has a method
called getCommentableTitle() first, else it checks for a field called title and then one called name. If none of
the cases are met, an exception is thrown.
@return string
@throws \Exception | [
"Returns",
"a",
"string",
"representing",
"the",
"record",
"that",
"the",
"comment",
"was",
"on",
".",
"This",
"is",
"normally",
"the",
"name",
"or",
"title",
"field",
"of",
"the",
"commentable",
"model",
".",
"E",
".",
"g",
".",
"the",
"title",
"of",
... | train | https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L56-L86 |
FbF/Laravel-Comments | src/models/Comment.php | Comment.getRules | public function getRules($commentableType)
{
$commentableObj = new $commentableType;
$table = $commentableObj->getTable();
$key = $commentableObj->getKeyName();
$rules = array(
'commentable_type' => 'required|in:'.implode(',', Config::get('laravel-comments::commentables')),
'commentable_id' => 'required|exists:'.$table.','.$key,
'comment' => 'required',
);
return $rules;
} | php | public function getRules($commentableType)
{
$commentableObj = new $commentableType;
$table = $commentableObj->getTable();
$key = $commentableObj->getKeyName();
$rules = array(
'commentable_type' => 'required|in:'.implode(',', Config::get('laravel-comments::commentables')),
'commentable_id' => 'required|exists:'.$table.','.$key,
'comment' => 'required',
);
return $rules;
} | [
"public",
"function",
"getRules",
"(",
"$",
"commentableType",
")",
"{",
"$",
"commentableObj",
"=",
"new",
"$",
"commentableType",
";",
"$",
"table",
"=",
"$",
"commentableObj",
"->",
"getTable",
"(",
")",
";",
"$",
"key",
"=",
"$",
"commentableObj",
"->"... | Returns the validation rules for the comment
@param string $commentableType The namespaced model that is being commented on
@return array | [
"Returns",
"the",
"validation",
"rules",
"for",
"the",
"comment"
] | train | https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L105-L116 |
FbF/Laravel-Comments | src/models/Comment.php | Comment.getUrl | public function getUrl()
{
$commentable = $this->commentable;
$url = false;
if (method_exists($commentable, 'getUrl'))
{
$url = $commentable->getUrl();
}
return \URL::to($url.'#C'.$this->id);
} | php | public function getUrl()
{
$commentable = $this->commentable;
$url = false;
if (method_exists($commentable, 'getUrl'))
{
$url = $commentable->getUrl();
}
return \URL::to($url.'#C'.$this->id);
} | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"commentable",
"=",
"$",
"this",
"->",
"commentable",
";",
"$",
"url",
"=",
"false",
";",
"if",
"(",
"method_exists",
"(",
"$",
"commentable",
",",
"'getUrl'",
")",
")",
"{",
"$",
"url",
"=",
"$",
... | Returns the URL of the comment constructed based on the URL of the commentable object, plus the anchor of the
comment
@return string | [
"Returns",
"the",
"URL",
"of",
"the",
"comment",
"constructed",
"based",
"on",
"the",
"URL",
"of",
"the",
"commentable",
"object",
"plus",
"the",
"anchor",
"of",
"the",
"comment"
] | train | https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L124-L135 |
FbF/Laravel-Comments | src/models/Comment.php | Comment.getDate | public function getDate()
{
$date = $this->created_at;
if (Lang::has('laravel-comments::messages.date_timezone'))
{
$oldTimezone = date_default_timezone_get();
$newTimezone = Lang::get('laravel-comments::messages.date_timezone');
$date->setTimezone($newTimezone);
date_default_timezone_set($newTimezone);
}
$locale = \App::getLocale();
if (Lang::has('laravel-comments::messages.date_locale'))
{
$locale = Lang::get('laravel-comments::messages.date_locale');
}
setlocale(LC_TIME, $locale);
$dateFormat = trans('laravel-comments::messages.date_format');
if ($dateFormat == 'laravel-comments::messages.date_format')
{
$dateFormat = '%e %B %Y at %H:%M';
}
$date = $date->formatLocalized($dateFormat);
if (Lang::has('laravel-comments::messages.date_timezone'))
{
date_default_timezone_set($oldTimezone);
}
return $date;
} | php | public function getDate()
{
$date = $this->created_at;
if (Lang::has('laravel-comments::messages.date_timezone'))
{
$oldTimezone = date_default_timezone_get();
$newTimezone = Lang::get('laravel-comments::messages.date_timezone');
$date->setTimezone($newTimezone);
date_default_timezone_set($newTimezone);
}
$locale = \App::getLocale();
if (Lang::has('laravel-comments::messages.date_locale'))
{
$locale = Lang::get('laravel-comments::messages.date_locale');
}
setlocale(LC_TIME, $locale);
$dateFormat = trans('laravel-comments::messages.date_format');
if ($dateFormat == 'laravel-comments::messages.date_format')
{
$dateFormat = '%e %B %Y at %H:%M';
}
$date = $date->formatLocalized($dateFormat);
if (Lang::has('laravel-comments::messages.date_timezone'))
{
date_default_timezone_set($oldTimezone);
}
return $date;
} | [
"public",
"function",
"getDate",
"(",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"created_at",
";",
"if",
"(",
"Lang",
"::",
"has",
"(",
"'laravel-comments::messages.date_timezone'",
")",
")",
"{",
"$",
"oldTimezone",
"=",
"date_default_timezone_get",
"(",... | Returns the locale formatted date, in the locale's timezone, both of which can be overridden in the language file
@return string | [
"Returns",
"the",
"locale",
"formatted",
"date",
"in",
"the",
"locale",
"s",
"timezone",
"both",
"of",
"which",
"can",
"be",
"overridden",
"in",
"the",
"language",
"file"
] | train | https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L142-L169 |
txj123/zilf | src/Zilf/Routing/Dispatch/Url.php | Url.parseUrl | protected function parseUrl($url)
{
$depr = $this->rule->getConfig('app.pathinfo_depr');
$bind = $this->rule->getRouter()->getBind();
if (!empty($bind) && preg_match('/^[a-z]/is', $bind)) {
$bind = str_replace('/', $depr, $bind);
// 如果有模块/控制器绑定
$url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
}
list($path, $var) = $this->rule->parseUrlPath($url);
return $path;
// // 解析模块
// $module = array_shift($path);
//
// if ($this->param['auto_search']) {
// $controller = $this->autoFindController($module, $path);
// } else {
// // 解析控制器
// $controller = !empty($path) ? array_shift($path) : null;
// }
//
// // 解析操作
// $action = !empty($path) ? array_shift($path) : null;
//
// // 解析额外参数
// if ($path) {
// if ($this->rule->getConfig('url_param_type')) {
// $var += $path;
// } else {
// preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
// $var[$match[1]] = strip_tags($match[2]);
// }, implode('|', $path));
// }
// }
//
// $panDomain = Request::panDomain();
//
// if ($panDomain && $key = array_search('*', $var)) {
// // 泛域名赋值
// $var[$key] = $panDomain;
// }
//
// // 设置当前请求的参数
// Request::setRouteVars($var);
//
// // 封装路由
// $route = [$module, $controller, $action];
//
// if ($this->hasDefinedRoute($route, $bind)) {
// throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url));
// }
//
// return $route;
} | php | protected function parseUrl($url)
{
$depr = $this->rule->getConfig('app.pathinfo_depr');
$bind = $this->rule->getRouter()->getBind();
if (!empty($bind) && preg_match('/^[a-z]/is', $bind)) {
$bind = str_replace('/', $depr, $bind);
// 如果有模块/控制器绑定
$url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
}
list($path, $var) = $this->rule->parseUrlPath($url);
return $path;
// // 解析模块
// $module = array_shift($path);
//
// if ($this->param['auto_search']) {
// $controller = $this->autoFindController($module, $path);
// } else {
// // 解析控制器
// $controller = !empty($path) ? array_shift($path) : null;
// }
//
// // 解析操作
// $action = !empty($path) ? array_shift($path) : null;
//
// // 解析额外参数
// if ($path) {
// if ($this->rule->getConfig('url_param_type')) {
// $var += $path;
// } else {
// preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
// $var[$match[1]] = strip_tags($match[2]);
// }, implode('|', $path));
// }
// }
//
// $panDomain = Request::panDomain();
//
// if ($panDomain && $key = array_search('*', $var)) {
// // 泛域名赋值
// $var[$key] = $panDomain;
// }
//
// // 设置当前请求的参数
// Request::setRouteVars($var);
//
// // 封装路由
// $route = [$module, $controller, $action];
//
// if ($this->hasDefinedRoute($route, $bind)) {
// throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url));
// }
//
// return $route;
} | [
"protected",
"function",
"parseUrl",
"(",
"$",
"url",
")",
"{",
"$",
"depr",
"=",
"$",
"this",
"->",
"rule",
"->",
"getConfig",
"(",
"'app.pathinfo_depr'",
")",
";",
"$",
"bind",
"=",
"$",
"this",
"->",
"rule",
"->",
"getRouter",
"(",
")",
"->",
"get... | 解析URL地址
@access protected
@param string $url URL
@return array | [
"解析URL地址"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch/Url.php#L30-L87 |
txj123/zilf | src/Zilf/Routing/Dispatch/Url.php | Url.hasDefinedRoute | protected function hasDefinedRoute($route, $bind)
{
list($module, $controller, $action) = $route;
// 检查地址是否被定义过路由
$name = strtolower($module . '/' . $controller . '/' . $action);
$name2 = '';
if (empty($module) || $module == $bind) {
$name2 = strtolower($controller . '/' . $action);
}
$host = Request::getHost();
$method = Request::getMethod();
if ($this->rule->getRouter()->getName($name, $host, $method) || $this->rule->getRouter()->getName($name2, $host, $method)) {
return true;
}
return false;
} | php | protected function hasDefinedRoute($route, $bind)
{
list($module, $controller, $action) = $route;
// 检查地址是否被定义过路由
$name = strtolower($module . '/' . $controller . '/' . $action);
$name2 = '';
if (empty($module) || $module == $bind) {
$name2 = strtolower($controller . '/' . $action);
}
$host = Request::getHost();
$method = Request::getMethod();
if ($this->rule->getRouter()->getName($name, $host, $method) || $this->rule->getRouter()->getName($name2, $host, $method)) {
return true;
}
return false;
} | [
"protected",
"function",
"hasDefinedRoute",
"(",
"$",
"route",
",",
"$",
"bind",
")",
"{",
"list",
"(",
"$",
"module",
",",
"$",
"controller",
",",
"$",
"action",
")",
"=",
"$",
"route",
";",
"// 检查地址是否被定义过路由",
"$",
"name",
"=",
"strtolower",
"(",
"$",... | 检查URL是否已经定义过路由
@access protected
@param string $route 路由信息
@param string $bind 绑定信息
@return bool | [
"检查URL是否已经定义过路由"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch/Url.php#L96-L118 |
txj123/zilf | src/Zilf/Routing/Dispatch/Url.php | Url.autoFindController | protected function autoFindController($module, &$path)
{
$dir = $this->app->getAppPath() . ($module ? $module . '/' : '') . $this->rule->getConfig('url_controller_layer');
$suffix = $this->app->getSuffix() || $this->rule->getConfig('controller_suffix') ? ucfirst($this->rule->getConfig('url_controller_layer')) : '';
$item = [];
$find = false;
foreach ($path as $val) {
$item[] = $val;
$file = $dir . '/' . str_replace('.', '/', $val) . $suffix . '.php';
$file = pathinfo($file, PATHINFO_DIRNAME) . '/' . Loader::parseName(pathinfo($file, PATHINFO_FILENAME), 1) . '.php';
if (is_file($file)) {
$find = true;
break;
} else {
$dir .= '/' . Loader::parseName($val);
}
}
if ($find) {
$controller = implode('.', $item);
$path = array_slice($path, count($item));
} else {
$controller = array_shift($path);
}
return $controller;
} | php | protected function autoFindController($module, &$path)
{
$dir = $this->app->getAppPath() . ($module ? $module . '/' : '') . $this->rule->getConfig('url_controller_layer');
$suffix = $this->app->getSuffix() || $this->rule->getConfig('controller_suffix') ? ucfirst($this->rule->getConfig('url_controller_layer')) : '';
$item = [];
$find = false;
foreach ($path as $val) {
$item[] = $val;
$file = $dir . '/' . str_replace('.', '/', $val) . $suffix . '.php';
$file = pathinfo($file, PATHINFO_DIRNAME) . '/' . Loader::parseName(pathinfo($file, PATHINFO_FILENAME), 1) . '.php';
if (is_file($file)) {
$find = true;
break;
} else {
$dir .= '/' . Loader::parseName($val);
}
}
if ($find) {
$controller = implode('.', $item);
$path = array_slice($path, count($item));
} else {
$controller = array_shift($path);
}
return $controller;
} | [
"protected",
"function",
"autoFindController",
"(",
"$",
"module",
",",
"&",
"$",
"path",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"app",
"->",
"getAppPath",
"(",
")",
".",
"(",
"$",
"module",
"?",
"$",
"module",
".",
"'/'",
":",
"''",
")",
... | 自动定位控制器类
@access protected
@param string $module 模块名
@param array $path URL
@return string | [
"自动定位控制器类"
] | train | https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Dispatch/Url.php#L127-L155 |
oxygen-cms/core | src/Action/Factory/ActionFactory.php | ActionFactory.create | public function create(array $parameters, $controller = null) {
$parameters = $this->parseParameters($parameters, $controller);
$action = new Action(
$parameters['name'],
$parameters['pattern'],
$parameters['uses'],
$parameters['group']
);
$this->setProperties($action, $parameters);
return $action;
} | php | public function create(array $parameters, $controller = null) {
$parameters = $this->parseParameters($parameters, $controller);
$action = new Action(
$parameters['name'],
$parameters['pattern'],
$parameters['uses'],
$parameters['group']
);
$this->setProperties($action, $parameters);
return $action;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"parameters",
",",
"$",
"controller",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parseParameters",
"(",
"$",
"parameters",
",",
"$",
"controller",
")",
";",
"$",
"action",
"=",
... | Creates a new Action using the passed parameters.
@param array $parameters Passed parameters
@param string $controller Default controller to use if none is provided
@return mixed | [
"Creates",
"a",
"new",
"Action",
"using",
"the",
"passed",
"parameters",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Factory/ActionFactory.php#L18-L31 |
oxygen-cms/core | src/Action/Factory/ActionFactory.php | ActionFactory.parseParameters | protected function parseParameters(array $parameters, $controller) {
if(!isset($parameters['uses']) || $parameters['uses'] === null) {
if($controller === null) {
throw new InvalidArgumentException('No `uses` key provided for Action');
} else {
$parameters['uses'] = $controller . '@' . $parameters['name'];
}
}
return $parameters;
} | php | protected function parseParameters(array $parameters, $controller) {
if(!isset($parameters['uses']) || $parameters['uses'] === null) {
if($controller === null) {
throw new InvalidArgumentException('No `uses` key provided for Action');
} else {
$parameters['uses'] = $controller . '@' . $parameters['name'];
}
}
return $parameters;
} | [
"protected",
"function",
"parseParameters",
"(",
"array",
"$",
"parameters",
",",
"$",
"controller",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'uses'",
"]",
")",
"||",
"$",
"parameters",
"[",
"'uses'",
"]",
"===",
"null",
")",
"{... | Sets properties on the action from an input array.
@param array $parameters
@param $controller
@return array | [
"Sets",
"properties",
"on",
"the",
"action",
"from",
"an",
"input",
"array",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Factory/ActionFactory.php#L40-L50 |
oxygen-cms/core | src/Action/Factory/ActionFactory.php | ActionFactory.setProperties | protected function setProperties($action, $properties) {
unset($properties['name'], $properties['pattern'], $properties['uses'], $properties['group']);
foreach($properties as $key => $value) {
$action->$key = $value;
}
} | php | protected function setProperties($action, $properties) {
unset($properties['name'], $properties['pattern'], $properties['uses'], $properties['group']);
foreach($properties as $key => $value) {
$action->$key = $value;
}
} | [
"protected",
"function",
"setProperties",
"(",
"$",
"action",
",",
"$",
"properties",
")",
"{",
"unset",
"(",
"$",
"properties",
"[",
"'name'",
"]",
",",
"$",
"properties",
"[",
"'pattern'",
"]",
",",
"$",
"properties",
"[",
"'uses'",
"]",
",",
"$",
"p... | Sets properties on the action from an input array.
@param Action $action Action to set the properties on
@param array $properties Properties to set | [
"Sets",
"properties",
"on",
"the",
"action",
"from",
"an",
"input",
"array",
"."
] | train | https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Factory/ActionFactory.php#L58-L64 |
ko-ko-ko/php-assert | src/Assert.php | Assert.assert | public static function assert($value, $name = 'value')
{
if (is_object($value)) {
throw new InvalidNotObjectException($name);
}
if (!is_string($name)) {
throw new InvalidStringException('name', $name);
}
if (empty(self::$validator)) {
self::$validator = new static;
}
self::$validator->name = $name;
self::$validator->value = $value;
return self::$validator;
} | php | public static function assert($value, $name = 'value')
{
if (is_object($value)) {
throw new InvalidNotObjectException($name);
}
if (!is_string($name)) {
throw new InvalidStringException('name', $name);
}
if (empty(self::$validator)) {
self::$validator = new static;
}
self::$validator->name = $name;
self::$validator->value = $value;
return self::$validator;
} | [
"public",
"static",
"function",
"assert",
"(",
"$",
"value",
",",
"$",
"name",
"=",
"'value'",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNotObjectException",
"(",
"$",
"name",
")",
";",
"}",
"if",
"("... | Creates validator instance for variable, first fail check will throw an exception
@param int|float|string|resource|array|null $value
@param string $name
@return static
@throws InvalidNotObjectException
@throws InvalidStringException | [
"Creates",
"validator",
"instance",
"for",
"variable",
"first",
"fail",
"check",
"will",
"throw",
"an",
"exception"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L68-L86 |
ko-ko-ko/php-assert | src/Assert.php | Assert.lengthBetween | public function lengthBetween($from, $to)
{
if (!is_int($from)) {
throw new InvalidIntException('from', $from);
} elseif (!is_int($to)) {
throw new InvalidIntException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessException('from', $from, $to);
} elseif ($from < 0) {
throw new NumberNotGreaterException('from', $from, 0);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
}
$length = strlen($this->value);
if ($length < $from || $length > $to) {
throw new LengthNotBetweenException($this->name, $this->value, $from, $to);
}
return $this;
} | php | public function lengthBetween($from, $to)
{
if (!is_int($from)) {
throw new InvalidIntException('from', $from);
} elseif (!is_int($to)) {
throw new InvalidIntException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessException('from', $from, $to);
} elseif ($from < 0) {
throw new NumberNotGreaterException('from', $from, 0);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
}
$length = strlen($this->value);
if ($length < $from || $length > $to) {
throw new LengthNotBetweenException($this->name, $this->value, $from, $to);
}
return $this;
} | [
"public",
"function",
"lengthBetween",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"from",
")",
")",
"{",
"throw",
"new",
"InvalidIntException",
"(",
"'from'",
",",
"$",
"from",
")",
";",
"}",
"elseif",
"(",
"!",... | Soft check if value has length $from <= $length <= to. Runs only after string validation
@param int $from
@param int $to
@return $this
@throws InvalidIntException
@throws LengthNotBetweenException
@throws NumberNotPositiveException
@throws NumberNotGreaterException
@throws NumberNotLessException
@throws InvalidStringException | [
"Soft",
"check",
"if",
"value",
"has",
"length",
"$from",
"<",
"=",
"$length",
"<",
"=",
"to",
".",
"Runs",
"only",
"after",
"string",
"validation"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L195-L218 |
ko-ko-ko/php-assert | src/Assert.php | Assert.lengthLess | public function lengthLess($length)
{
if (!is_int($length)) {
throw new InvalidIntException('length', $length);
} elseif ($length < 0) {
throw new NumberNotPositiveException('length', $length);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (strlen($this->value) > $length) {
throw new LengthNotLessException($this->name, $this->value, $length);
}
return $this;
} | php | public function lengthLess($length)
{
if (!is_int($length)) {
throw new InvalidIntException('length', $length);
} elseif ($length < 0) {
throw new NumberNotPositiveException('length', $length);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (strlen($this->value) > $length) {
throw new LengthNotLessException($this->name, $this->value, $length);
}
return $this;
} | [
"public",
"function",
"lengthLess",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"length",
")",
")",
"{",
"throw",
"new",
"InvalidIntException",
"(",
"'length'",
",",
"$",
"length",
")",
";",
"}",
"elseif",
"(",
"$",
"length",
"<... | Soft check if value has length less than $length. Runs only after string validation
@param int $length
@return $this
@throws InvalidIntException
@throws LengthNotLessException
@throws NumberNotPositiveException
@throws InvalidStringException | [
"Soft",
"check",
"if",
"value",
"has",
"length",
"less",
"than",
"$length",
".",
"Runs",
"only",
"after",
"string",
"validation"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L230-L245 |
ko-ko-ko/php-assert | src/Assert.php | Assert.lengthGreater | public function lengthGreater($length)
{
if (!is_int($length)) {
throw new InvalidIntException('length', $length);
} elseif ($length < 0) {
throw new NumberNotPositiveException('length', $length);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (strlen($this->value) < $length) {
throw new LengthNotGreaterException($this->name, $this->value, $length);
}
return $this;
} | php | public function lengthGreater($length)
{
if (!is_int($length)) {
throw new InvalidIntException('length', $length);
} elseif ($length < 0) {
throw new NumberNotPositiveException('length', $length);
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (strlen($this->value) < $length) {
throw new LengthNotGreaterException($this->name, $this->value, $length);
}
return $this;
} | [
"public",
"function",
"lengthGreater",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"length",
")",
")",
"{",
"throw",
"new",
"InvalidIntException",
"(",
"'length'",
",",
"$",
"length",
")",
";",
"}",
"elseif",
"(",
"$",
"length",
... | Soft check if value has length less than $length. Runs only after notEmpty and string validations
@param int $length
@return $this
@throws InvalidIntException
@throws LengthNotGreaterException
@throws NumberNotPositiveException
@throws InvalidStringException | [
"Soft",
"check",
"if",
"value",
"has",
"length",
"less",
"than",
"$length",
".",
"Runs",
"only",
"after",
"notEmpty",
"and",
"string",
"validations"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L257-L272 |
ko-ko-ko/php-assert | src/Assert.php | Assert.inArray | public function inArray($range)
{
if (!is_array($range)) {
throw new InvalidArrayException('range', $range);
} elseif (empty($range)) {
throw new InvalidNotEmptyException('range');
}
if (!in_array($this->value, $range, true)) {
throw new ValueNotInArrayException($this->name, $this->value, $range);
}
return $this;
} | php | public function inArray($range)
{
if (!is_array($range)) {
throw new InvalidArrayException('range', $range);
} elseif (empty($range)) {
throw new InvalidNotEmptyException('range');
}
if (!in_array($this->value, $range, true)) {
throw new ValueNotInArrayException($this->name, $this->value, $range);
}
return $this;
} | [
"public",
"function",
"inArray",
"(",
"$",
"range",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"range",
")",
")",
"{",
"throw",
"new",
"InvalidArrayException",
"(",
"'range'",
",",
"$",
"range",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
... | Check if value is in array (in_array strict)
@param array $range
@return $this
@throws InvalidArrayException
@throws InvalidNotEmptyException
@throws ValueNotInArrayException | [
"Check",
"if",
"value",
"is",
"in",
"array",
"(",
"in_array",
"strict",
")"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L283-L296 |
ko-ko-ko/php-assert | src/Assert.php | Assert.isArray | public function isArray()
{
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
return $this;
} | php | public function isArray()
{
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
return $this;
} | [
"public",
"function",
"isArray",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArrayException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"re... | Check if value is array
@return $this
@throws InvalidArrayException | [
"Check",
"if",
"value",
"is",
"array"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L304-L311 |
ko-ko-ko/php-assert | src/Assert.php | Assert.hasKey | public function hasKey($key)
{
if (!is_string($key) && !is_int($key)) {
throw new InvalidIntOrStringException('key', $key);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (!array_key_exists($key, $this->value)) {
throw new ArrayKeyNotExistsException($this->name, $key);
}
return $this;
} | php | public function hasKey($key)
{
if (!is_string($key) && !is_int($key)) {
throw new InvalidIntOrStringException('key', $key);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (!array_key_exists($key, $this->value)) {
throw new ArrayKeyNotExistsException($this->name, $key);
}
return $this;
} | [
"public",
"function",
"hasKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
"&&",
"!",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrStringException",
"(",
"'key'",
",",
"$",
"key",
")",
";... | Check if array key exists
@param string|int $key
@return $this
@throws ArrayKeyNotExistsException
@throws InvalidArrayException
@throws InvalidIntOrStringException | [
"Check",
"if",
"array",
"key",
"exists"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L322-L337 |
ko-ko-ko/php-assert | src/Assert.php | Assert.count | public function count($count)
{
if (!is_int($count)) {
throw new InvalidIntException('count', $count);
} elseif ($count < 0) {
throw new NumberNotGreaterException('count', $count, 0);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (count($this->value) !== $count) {
throw new InvalidArrayCountException($this->name, $this->value, $count);
}
return $this;
} | php | public function count($count)
{
if (!is_int($count)) {
throw new InvalidIntException('count', $count);
} elseif ($count < 0) {
throw new NumberNotGreaterException('count', $count, 0);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (count($this->value) !== $count) {
throw new InvalidArrayCountException($this->name, $this->value, $count);
}
return $this;
} | [
"public",
"function",
"count",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"throw",
"new",
"InvalidIntException",
"(",
"'count'",
",",
"$",
"count",
")",
";",
"}",
"elseif",
"(",
"$",
"count",
"<",
"0",
... | Check if array elements count is same as $count
@param int $count
@return $this
@throws InvalidArrayCountException
@throws InvalidArrayException
@throws InvalidIntException
@throws NumberNotGreaterException | [
"Check",
"if",
"array",
"elements",
"count",
"is",
"same",
"as",
"$count"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L349-L366 |
ko-ko-ko/php-assert | src/Assert.php | Assert.between | public function between($from, $to)
{
if (!is_int($from) && !is_float($from)) {
throw new InvalidIntOrFloatException('from', $from);
} elseif (!is_int($to) && !is_float($to)) {
throw new InvalidIntOrFloatException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessStrictlyException('from', $from, $to);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value < $from || $this->value > $to) {
throw new NumberNotBetweenException($this->name, $this->value, $from, $to);
}
return $this;
} | php | public function between($from, $to)
{
if (!is_int($from) && !is_float($from)) {
throw new InvalidIntOrFloatException('from', $from);
} elseif (!is_int($to) && !is_float($to)) {
throw new InvalidIntOrFloatException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessStrictlyException('from', $from, $to);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value < $from || $this->value > $to) {
throw new NumberNotBetweenException($this->name, $this->value, $from, $to);
}
return $this;
} | [
"public",
"function",
"between",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"from",
")",
"&&",
"!",
"is_float",
"(",
"$",
"from",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'from'",
",",
... | Soft check that $from <= value <= $to
@param float|int $from
@param float|int $to
@return $this
@throws NumberNotBetweenException
@throws InvalidIntOrFloatException
@throws NumberNotLessStrictlyException | [
"Soft",
"check",
"that",
"$from",
"<",
"=",
"value",
"<",
"=",
"$to"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L378-L395 |
ko-ko-ko/php-assert | src/Assert.php | Assert.betweenStrict | public function betweenStrict($from, $to)
{
if (!is_int($from) && !is_float($from)) {
throw new InvalidIntOrFloatException('from', $from);
} elseif (!is_int($to) && !is_float($to)) {
throw new InvalidIntOrFloatException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessStrictlyException('from', $from, $to);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= $from || $this->value >= $to) {
throw new NumberNotBetweenStrictlyException($this->name, $this->value, $from, $to);
}
return $this;
} | php | public function betweenStrict($from, $to)
{
if (!is_int($from) && !is_float($from)) {
throw new InvalidIntOrFloatException('from', $from);
} elseif (!is_int($to) && !is_float($to)) {
throw new InvalidIntOrFloatException('to', $to);
} elseif ($from > $to) {
throw new NumberNotLessStrictlyException('from', $from, $to);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= $from || $this->value >= $to) {
throw new NumberNotBetweenStrictlyException($this->name, $this->value, $from, $to);
}
return $this;
} | [
"public",
"function",
"betweenStrict",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"from",
")",
"&&",
"!",
"is_float",
"(",
"$",
"from",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'from'",
"... | Strict check that $from < value < $to
@param float|int $from
@param float|int $to
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotBetweenStrictlyException
@throws NumberNotLessStrictlyException | [
"Strict",
"check",
"that",
"$from",
"<",
"value",
"<",
"$to"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L407-L424 |
ko-ko-ko/php-assert | src/Assert.php | Assert.bool | public function bool()
{
if (!is_bool($this->value)) {
throw new InvalidBoolException($this->name, $this->value);
}
return $this;
} | php | public function bool()
{
if (!is_bool($this->value)) {
throw new InvalidBoolException($this->name, $this->value);
}
return $this;
} | [
"public",
"function",
"bool",
"(",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidBoolException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return"... | Check if value is boolean (is_bool)
@return $this
@throws InvalidBoolException | [
"Check",
"if",
"value",
"is",
"boolean",
"(",
"is_bool",
")"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L432-L439 |
ko-ko-ko/php-assert | src/Assert.php | Assert.digit | public function digit()
{
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (!ctype_digit($this->value)) {
throw new InvalidDigitException($this->name, $this->value);
}
return $this;
} | php | public function digit()
{
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (!ctype_digit($this->value)) {
throw new InvalidDigitException($this->name, $this->value);
}
return $this;
} | [
"public",
"function",
"digit",
"(",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"el... | Check if value is digit (ctype_digit)
@return $this
@throws InvalidDigitException
@throws InvalidStringException | [
"Check",
"if",
"value",
"is",
"digit",
"(",
"ctype_digit",
")"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L448-L457 |
ko-ko-ko/php-assert | src/Assert.php | Assert.float | public function float()
{
if (!is_float($this->value)) {
throw new InvalidFloatException($this->name, $this->value);
}
return $this;
} | php | public function float()
{
if (!is_float($this->value)) {
throw new InvalidFloatException($this->name, $this->value);
}
return $this;
} | [
"public",
"function",
"float",
"(",
")",
"{",
"if",
"(",
"!",
"is_float",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidFloatException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"retu... | Check if value is float (is_float)
@return $this
@throws InvalidFloatException | [
"Check",
"if",
"value",
"is",
"float",
"(",
"is_float",
")"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L495-L502 |
ko-ko-ko/php-assert | src/Assert.php | Assert.int | public function int()
{
if (!is_int($this->value)) {
throw new InvalidIntException($this->name, $this->value);
}
return $this;
} | php | public function int()
{
if (!is_int($this->value)) {
throw new InvalidIntException($this->name, $this->value);
}
return $this;
} | [
"public",
"function",
"int",
"(",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidIntException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
... | Check if value is integer (is_int)
@return $this
@throws InvalidIntException | [
"Check",
"if",
"value",
"is",
"integer",
"(",
"is_int",
")"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L510-L517 |
ko-ko-ko/php-assert | src/Assert.php | Assert.less | public function less($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value > $number) {
throw new NumberNotLessException($this->name, $this->value, $number);
}
return $this;
} | php | public function less($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value > $number) {
throw new NumberNotLessException($this->name, $this->value, $number);
}
return $this;
} | [
"public",
"function",
"less",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"number",
")",
"&&",
"!",
"is_float",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'number'",
",",
"$",
"number",
... | Soft check that value <= $max
@param float|int $number
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotLessException | [
"Soft",
"check",
"that",
"value",
"<",
"=",
"$max"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L527-L540 |
ko-ko-ko/php-assert | src/Assert.php | Assert.greater | public function greater($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value < $number) {
throw new NumberNotGreaterException($this->name, $this->value, $number);
}
return $this;
} | php | public function greater($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value < $number) {
throw new NumberNotGreaterException($this->name, $this->value, $number);
}
return $this;
} | [
"public",
"function",
"greater",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"number",
")",
"&&",
"!",
"is_float",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'number'",
",",
"$",
"number... | Soft check that value >= $min
@param float|int $number
@return $this
@throws NumberNotGreaterException
@throws InvalidIntOrFloatException | [
"Soft",
"check",
"that",
"value",
">",
"=",
"$min"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L550-L563 |
ko-ko-ko/php-assert | src/Assert.php | Assert.lessStrict | public function lessStrict($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value >= $number) {
throw new NumberNotLessStrictlyException($this->name, $this->value, $number);
}
return $this;
} | php | public function lessStrict($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value >= $number) {
throw new NumberNotLessStrictlyException($this->name, $this->value, $number);
}
return $this;
} | [
"public",
"function",
"lessStrict",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"number",
")",
"&&",
"!",
"is_float",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'number'",
",",
"$",
"num... | Strict check that value < $max
@param float|int $number
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotLessStrictlyException | [
"Strict",
"check",
"that",
"value",
"<",
"$max"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L573-L586 |
ko-ko-ko/php-assert | src/Assert.php | Assert.greaterStrict | public function greaterStrict($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= $number) {
throw new NumberNotGreaterStrictlyException($this->name, $this->value, $number);
}
return $this;
} | php | public function greaterStrict($number)
{
if (!is_int($number) && !is_float($number)) {
throw new InvalidIntOrFloatException('number', $number);
}
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= $number) {
throw new NumberNotGreaterStrictlyException($this->name, $this->value, $number);
}
return $this;
} | [
"public",
"function",
"greaterStrict",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"number",
")",
"&&",
"!",
"is_float",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"'number'",
",",
"$",
"... | Strict check that value > $min
@param float|int $number
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotGreaterStrictlyException | [
"Strict",
"check",
"that",
"value",
">",
"$min"
] | train | https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L596-L609 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.