repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getParent | public function getParent(ConnectionInterface $con = null)
{
if (null === $this->aNestedSetParent && $this->hasParent()) {
$this->aNestedSetParent = ChildCategoryQuery::create()
->ancestorsOf($this)
->orderByLevel(true)
->findOne($con);
}
return $this->aNestedSetParent;
} | php | public function getParent(ConnectionInterface $con = null)
{
if (null === $this->aNestedSetParent && $this->hasParent()) {
$this->aNestedSetParent = ChildCategoryQuery::create()
->ancestorsOf($this)
->orderByLevel(true)
->findOne($con);
}
return $this->aNestedSetParent;
} | [
"public",
"function",
"getParent",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"aNestedSetParent",
"&&",
"$",
"this",
"->",
"hasParent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"aNestedSetParent",
"=",
"ChildCategoryQuery",
"::",
"create",
"(",
")",
"->",
"ancestorsOf",
"(",
"$",
"this",
")",
"->",
"orderByLevel",
"(",
"true",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}",
"return",
"$",
"this",
"->",
"aNestedSetParent",
";",
"}"
] | Gets parent node for the current object if it exists
The result is cached so further calls to the same method don't issue any queries
@param ConnectionInterface $con Connection to use.
@return ChildCategory|null Propel object if exists else null | [
"Gets",
"parent",
"node",
"for",
"the",
"current",
"object",
"if",
"it",
"exists",
"The",
"result",
"is",
"cached",
"so",
"further",
"calls",
"to",
"the",
"same",
"method",
"don",
"t",
"issue",
"any",
"queries"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2839-L2849 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.hasPrevSibling | public function hasPrevSibling(ConnectionInterface $con = null)
{
if (!ChildCategoryQuery::isValid($this)) {
return false;
}
return ChildCategoryQuery::create()
->filterByTreeRight($this->getLeftValue() - 1)
->exists($con);
} | php | public function hasPrevSibling(ConnectionInterface $con = null)
{
if (!ChildCategoryQuery::isValid($this)) {
return false;
}
return ChildCategoryQuery::create()
->filterByTreeRight($this->getLeftValue() - 1)
->exists($con);
} | [
"public",
"function",
"hasPrevSibling",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"ChildCategoryQuery",
"::",
"isValid",
"(",
"$",
"this",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
")",
"->",
"filterByTreeRight",
"(",
"$",
"this",
"->",
"getLeftValue",
"(",
")",
"-",
"1",
")",
"->",
"exists",
"(",
"$",
"con",
")",
";",
"}"
] | Determines if the node has previous sibling
@param ConnectionInterface $con Connection to use.
@return bool | [
"Determines",
"if",
"the",
"node",
"has",
"previous",
"sibling"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2857-L2866 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getPrevSibling | public function getPrevSibling(ConnectionInterface $con = null)
{
return ChildCategoryQuery::create()
->filterByTreeRight($this->getLeftValue() - 1)
->findOne($con);
} | php | public function getPrevSibling(ConnectionInterface $con = null)
{
return ChildCategoryQuery::create()
->filterByTreeRight($this->getLeftValue() - 1)
->findOne($con);
} | [
"public",
"function",
"getPrevSibling",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
")",
"->",
"filterByTreeRight",
"(",
"$",
"this",
"->",
"getLeftValue",
"(",
")",
"-",
"1",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Gets previous sibling for the given node if it exists
@param ConnectionInterface $con Connection to use.
@return ChildCategory|null Propel object if exists else null | [
"Gets",
"previous",
"sibling",
"for",
"the",
"given",
"node",
"if",
"it",
"exists"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2874-L2879 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.hasNextSibling | public function hasNextSibling(ConnectionInterface $con = null)
{
if (!ChildCategoryQuery::isValid($this)) {
return false;
}
return ChildCategoryQuery::create()
->filterByTreeLeft($this->getRightValue() + 1)
->exists($con);
} | php | public function hasNextSibling(ConnectionInterface $con = null)
{
if (!ChildCategoryQuery::isValid($this)) {
return false;
}
return ChildCategoryQuery::create()
->filterByTreeLeft($this->getRightValue() + 1)
->exists($con);
} | [
"public",
"function",
"hasNextSibling",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"ChildCategoryQuery",
"::",
"isValid",
"(",
"$",
"this",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
")",
"->",
"filterByTreeLeft",
"(",
"$",
"this",
"->",
"getRightValue",
"(",
")",
"+",
"1",
")",
"->",
"exists",
"(",
"$",
"con",
")",
";",
"}"
] | Determines if the node has next sibling
@param ConnectionInterface $con Connection to use.
@return bool | [
"Determines",
"if",
"the",
"node",
"has",
"next",
"sibling"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2887-L2896 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getNextSibling | public function getNextSibling(ConnectionInterface $con = null)
{
return ChildCategoryQuery::create()
->filterByTreeLeft($this->getRightValue() + 1)
->findOne($con);
} | php | public function getNextSibling(ConnectionInterface $con = null)
{
return ChildCategoryQuery::create()
->filterByTreeLeft($this->getRightValue() + 1)
->findOne($con);
} | [
"public",
"function",
"getNextSibling",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
")",
"->",
"filterByTreeLeft",
"(",
"$",
"this",
"->",
"getRightValue",
"(",
")",
"+",
"1",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Gets next sibling for the given node if it exists
@param ConnectionInterface $con Connection to use.
@return ChildCategory|null Propel object if exists else null | [
"Gets",
"next",
"sibling",
"for",
"the",
"given",
"node",
"if",
"it",
"exists"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2904-L2909 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getChildren | public function getChildren(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collNestedSetChildren || null !== $criteria) {
if ($this->isLeaf() || ($this->isNew() && null === $this->collNestedSetChildren)) {
// return empty collection
$this->initNestedSetChildren();
} else {
$collNestedSetChildren = ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->orderByBranch()
->find($con);
if (null !== $criteria) {
return $collNestedSetChildren;
}
$this->collNestedSetChildren = $collNestedSetChildren;
}
}
return $this->collNestedSetChildren;
} | php | public function getChildren(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collNestedSetChildren || null !== $criteria) {
if ($this->isLeaf() || ($this->isNew() && null === $this->collNestedSetChildren)) {
// return empty collection
$this->initNestedSetChildren();
} else {
$collNestedSetChildren = ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->orderByBranch()
->find($con);
if (null !== $criteria) {
return $collNestedSetChildren;
}
$this->collNestedSetChildren = $collNestedSetChildren;
}
}
return $this->collNestedSetChildren;
} | [
"public",
"function",
"getChildren",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collNestedSetChildren",
"||",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLeaf",
"(",
")",
"||",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collNestedSetChildren",
")",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initNestedSetChildren",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collNestedSetChildren",
"=",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"childrenOf",
"(",
"$",
"this",
")",
"->",
"orderByBranch",
"(",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"return",
"$",
"collNestedSetChildren",
";",
"}",
"$",
"this",
"->",
"collNestedSetChildren",
"=",
"$",
"collNestedSetChildren",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collNestedSetChildren",
";",
"}"
] | Gets the children of the given node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ObjectCollection|ChildCategory[] List of ChildCategory objects | [
"Gets",
"the",
"children",
"of",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L2974-L2993 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.countChildren | public function countChildren(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collNestedSetChildren || null !== $criteria) {
if ($this->isLeaf() || ($this->isNew() && null === $this->collNestedSetChildren)) {
return 0;
} else {
return ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->count($con);
}
} else {
return count($this->collNestedSetChildren);
}
} | php | public function countChildren(Criteria $criteria = null, ConnectionInterface $con = null)
{
if (null === $this->collNestedSetChildren || null !== $criteria) {
if ($this->isLeaf() || ($this->isNew() && null === $this->collNestedSetChildren)) {
return 0;
} else {
return ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->count($con);
}
} else {
return count($this->collNestedSetChildren);
}
} | [
"public",
"function",
"countChildren",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collNestedSetChildren",
"||",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLeaf",
"(",
")",
"||",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collNestedSetChildren",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"childrenOf",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"}",
"else",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"collNestedSetChildren",
")",
";",
"}",
"}"
] | Gets number of children for the given node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return int Number of children | [
"Gets",
"number",
"of",
"children",
"for",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3002-L3015 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getFirstChild | public function getFirstChild(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
return null;
} else {
return ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->orderByBranch()
->findOne($con);
}
} | php | public function getFirstChild(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
return null;
} else {
return ChildCategoryQuery::create(null, $criteria)
->childrenOf($this)
->orderByBranch()
->findOne($con);
}
} | [
"public",
"function",
"getFirstChild",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLeaf",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"childrenOf",
"(",
"$",
"this",
")",
"->",
"orderByBranch",
"(",
")",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}",
"}"
] | Gets the first child of the given node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ChildCategory|null First child or null if this is a leaf | [
"Gets",
"the",
"first",
"child",
"of",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3024-L3034 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getSiblings | public function getSiblings($includeNode = false, Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isRoot()) {
return array();
} else {
$query = ChildCategoryQuery::create(null, $criteria)
->childrenOf($this->getParent($con))
->orderByBranch();
if (!$includeNode) {
$query->prune($this);
}
return $query->find($con);
}
} | php | public function getSiblings($includeNode = false, Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isRoot()) {
return array();
} else {
$query = ChildCategoryQuery::create(null, $criteria)
->childrenOf($this->getParent($con))
->orderByBranch();
if (!$includeNode) {
$query->prune($this);
}
return $query->find($con);
}
} | [
"public",
"function",
"getSiblings",
"(",
"$",
"includeNode",
"=",
"false",
",",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRoot",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"childrenOf",
"(",
"$",
"this",
"->",
"getParent",
"(",
"$",
"con",
")",
")",
"->",
"orderByBranch",
"(",
")",
";",
"if",
"(",
"!",
"$",
"includeNode",
")",
"{",
"$",
"query",
"->",
"prune",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"query",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}",
"}"
] | Gets the siblings of the given node
@param boolean $includeNode Whether to include the current node or not
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ObjectCollection|ChildCategory[] List of ChildCategory objects | [
"Gets",
"the",
"siblings",
"of",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3064-L3078 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getDescendants | public function getDescendants(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
return array();
} else {
return ChildCategoryQuery::create(null, $criteria)
->descendantsOf($this)
->orderByBranch()
->find($con);
}
} | php | public function getDescendants(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
return array();
} else {
return ChildCategoryQuery::create(null, $criteria)
->descendantsOf($this)
->orderByBranch()
->find($con);
}
} | [
"public",
"function",
"getDescendants",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLeaf",
"(",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"else",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"descendantsOf",
"(",
"$",
"this",
")",
"->",
"orderByBranch",
"(",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}",
"}"
] | Gets descendants for the given node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ObjectCollection|ChildCategory[] List of ChildCategory objects | [
"Gets",
"descendants",
"for",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3087-L3097 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.countDescendants | public function countDescendants(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
// save one query
return 0;
} else {
return ChildCategoryQuery::create(null, $criteria)
->descendantsOf($this)
->count($con);
}
} | php | public function countDescendants(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isLeaf()) {
// save one query
return 0;
} else {
return ChildCategoryQuery::create(null, $criteria)
->descendantsOf($this)
->count($con);
}
} | [
"public",
"function",
"countDescendants",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLeaf",
"(",
")",
")",
"{",
"// save one query",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"descendantsOf",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"}"
] | Gets number of descendants for the given node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return int Number of descendants | [
"Gets",
"number",
"of",
"descendants",
"for",
"the",
"given",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3106-L3116 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getBranch | public function getBranch(Criteria $criteria = null, ConnectionInterface $con = null)
{
return ChildCategoryQuery::create(null, $criteria)
->branchOf($this)
->orderByBranch()
->find($con);
} | php | public function getBranch(Criteria $criteria = null, ConnectionInterface $con = null)
{
return ChildCategoryQuery::create(null, $criteria)
->branchOf($this)
->orderByBranch()
->find($con);
} | [
"public",
"function",
"getBranch",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"branchOf",
"(",
"$",
"this",
")",
"->",
"orderByBranch",
"(",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}"
] | Gets descendants for the given node, plus the current node
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ObjectCollection|ChildCategory[] List of ChildCategory objects | [
"Gets",
"descendants",
"for",
"the",
"given",
"node",
"plus",
"the",
"current",
"node"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3125-L3131 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/Base/Category.php | Category.getAncestors | public function getAncestors(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isRoot()) {
// save one query
return array();
} else {
return ChildCategoryQuery::create(null, $criteria)
->ancestorsOf($this)
->orderByBranch()
->find($con);
}
} | php | public function getAncestors(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($this->isRoot()) {
// save one query
return array();
} else {
return ChildCategoryQuery::create(null, $criteria)
->ancestorsOf($this)
->orderByBranch()
->find($con);
}
} | [
"public",
"function",
"getAncestors",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRoot",
"(",
")",
")",
"{",
"// save one query",
"return",
"array",
"(",
")",
";",
"}",
"else",
"{",
"return",
"ChildCategoryQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"ancestorsOf",
"(",
"$",
"this",
")",
"->",
"orderByBranch",
"(",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}",
"}"
] | Gets ancestors for the given node, starting with the root node
Use it for breadcrumb paths for instance
@param Criteria $criteria Criteria to filter results.
@param ConnectionInterface $con Connection to use.
@return ObjectCollection|ChildCategory[] List of ChildCategory objects | [
"Gets",
"ancestors",
"for",
"the",
"given",
"node",
"starting",
"with",
"the",
"root",
"node",
"Use",
"it",
"for",
"breadcrumb",
"paths",
"for",
"instance"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Base/Category.php#L3141-L3152 | train |
t3v/t3v_core | Classes/Controller/AbstractController.php | AbstractController.assignOriginalArguments | protected function assignOriginalArguments() {
$originalRequest = $this->request->getOriginalRequest();
if (!empty($originalRequest)) {
$originalArguments = $originalRequest->getArguments();
$this->view->assign('originalArguments', $originalArguments);
}
} | php | protected function assignOriginalArguments() {
$originalRequest = $this->request->getOriginalRequest();
if (!empty($originalRequest)) {
$originalArguments = $originalRequest->getArguments();
$this->view->assign('originalArguments', $originalArguments);
}
} | [
"protected",
"function",
"assignOriginalArguments",
"(",
")",
"{",
"$",
"originalRequest",
"=",
"$",
"this",
"->",
"request",
"->",
"getOriginalRequest",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"originalRequest",
")",
")",
"{",
"$",
"originalArguments",
"=",
"$",
"originalRequest",
"->",
"getArguments",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assign",
"(",
"'originalArguments'",
",",
"$",
"originalArguments",
")",
";",
"}",
"}"
] | Assigns the arguments from the original request. | [
"Assigns",
"the",
"arguments",
"from",
"the",
"original",
"request",
"."
] | 8c04b7688cc2773f11fcc87fda3f7cd53d80a980 | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Controller/AbstractController.php#L23-L31 | train |
lanfisis/deflection | src/Deflection/Element/Docblock.php | Docblock.setDescription | public function setDescription($text, $length = 80)
{
$description = array();
$split = str_split($text, $length);
array_walk($split, function ($value) use (&$description) {
$description[] = $value;
});
$this->description = $description;
return $this;
} | php | public function setDescription($text, $length = 80)
{
$description = array();
$split = str_split($text, $length);
array_walk($split, function ($value) use (&$description) {
$description[] = $value;
});
$this->description = $description;
return $this;
} | [
"public",
"function",
"setDescription",
"(",
"$",
"text",
",",
"$",
"length",
"=",
"80",
")",
"{",
"$",
"description",
"=",
"array",
"(",
")",
";",
"$",
"split",
"=",
"str_split",
"(",
"$",
"text",
",",
"$",
"length",
")",
";",
"array_walk",
"(",
"$",
"split",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"&",
"$",
"description",
")",
"{",
"$",
"description",
"[",
"]",
"=",
"$",
"value",
";",
"}",
")",
";",
"$",
"this",
"->",
"description",
"=",
"$",
"description",
";",
"return",
"$",
"this",
";",
"}"
] | Set description at top of docblock
@param string $text Description
@param int $length Length to split line
@return \Deflection\Element\Docblock | [
"Set",
"description",
"at",
"top",
"of",
"docblock"
] | 31deaf7f085d6456d8a323e7ac3cc9914fbe49a9 | https://github.com/lanfisis/deflection/blob/31deaf7f085d6456d8a323e7ac3cc9914fbe49a9/src/Deflection/Element/Docblock.php#L52-L61 | train |
lanfisis/deflection | src/Deflection/Element/Docblock.php | Docblock.addVar | public function addVar($name, $type = '', $description = '')
{
$this->var_types[$name] = $type == '' ? $type : $type.' ';
$this->var_descriptions[$name] = $description;
return $this;
} | php | public function addVar($name, $type = '', $description = '')
{
$this->var_types[$name] = $type == '' ? $type : $type.' ';
$this->var_descriptions[$name] = $description;
return $this;
} | [
"public",
"function",
"addVar",
"(",
"$",
"name",
",",
"$",
"type",
"=",
"''",
",",
"$",
"description",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"var_types",
"[",
"$",
"name",
"]",
"=",
"$",
"type",
"==",
"''",
"?",
"$",
"type",
":",
"$",
"type",
".",
"' '",
";",
"$",
"this",
"->",
"var_descriptions",
"[",
"$",
"name",
"]",
"=",
"$",
"description",
";",
"return",
"$",
"this",
";",
"}"
] | Add a var on a docblock
@param string $name Var name
@param string $type Var type like string, boolean, ...
@param string $description Var description
@return \Deflection\Element\Docblock | [
"Add",
"a",
"var",
"on",
"a",
"docblock"
] | 31deaf7f085d6456d8a323e7ac3cc9914fbe49a9 | https://github.com/lanfisis/deflection/blob/31deaf7f085d6456d8a323e7ac3cc9914fbe49a9/src/Deflection/Element/Docblock.php#L72-L77 | train |
OxfordInfoLabs/kinikit-core | src/Util/DateTimeUtils.php | DateTimeUtils.convertDate | public static function convertDate($sourceFormat, $targetFormat, $value) {
$dateObject = date_create_from_format($sourceFormat, $value);
if ($dateObject) {
return $dateObject->format($targetFormat);
} else {
return null;
}
} | php | public static function convertDate($sourceFormat, $targetFormat, $value) {
$dateObject = date_create_from_format($sourceFormat, $value);
if ($dateObject) {
return $dateObject->format($targetFormat);
} else {
return null;
}
} | [
"public",
"static",
"function",
"convertDate",
"(",
"$",
"sourceFormat",
",",
"$",
"targetFormat",
",",
"$",
"value",
")",
"{",
"$",
"dateObject",
"=",
"date_create_from_format",
"(",
"$",
"sourceFormat",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"dateObject",
")",
"{",
"return",
"$",
"dateObject",
"->",
"format",
"(",
"$",
"targetFormat",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Convert a date from one format to another
@param $sourceFormat
@param $targetFormat
@param $value | [
"Convert",
"a",
"date",
"from",
"one",
"format",
"to",
"another"
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/DateTimeUtils.php#L19-L26 | train |
OxfordInfoLabs/kinikit-core | src/Util/DateTimeUtils.php | DateTimeUtils.convertSecondsToElapsedTime | public static function convertSecondsToElapsedTime($seconds) {
// Hours component
$hours = floor($seconds / 3600);
// Minutes component
$remainder = $seconds - ($hours * 3600);
$minutes = floor($remainder / 60);
// Seconds component
$seconds = round($remainder - ($minutes * 60));
return sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes) . ":" . sprintf("%02d", $seconds);
} | php | public static function convertSecondsToElapsedTime($seconds) {
// Hours component
$hours = floor($seconds / 3600);
// Minutes component
$remainder = $seconds - ($hours * 3600);
$minutes = floor($remainder / 60);
// Seconds component
$seconds = round($remainder - ($minutes * 60));
return sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes) . ":" . sprintf("%02d", $seconds);
} | [
"public",
"static",
"function",
"convertSecondsToElapsedTime",
"(",
"$",
"seconds",
")",
"{",
"// Hours component",
"$",
"hours",
"=",
"floor",
"(",
"$",
"seconds",
"/",
"3600",
")",
";",
"// Minutes component",
"$",
"remainder",
"=",
"$",
"seconds",
"-",
"(",
"$",
"hours",
"*",
"3600",
")",
";",
"$",
"minutes",
"=",
"floor",
"(",
"$",
"remainder",
"/",
"60",
")",
";",
"// Seconds component",
"$",
"seconds",
"=",
"round",
"(",
"$",
"remainder",
"-",
"(",
"$",
"minutes",
"*",
"60",
")",
")",
";",
"return",
"sprintf",
"(",
"\"%02d\"",
",",
"$",
"hours",
")",
".",
"\":\"",
".",
"sprintf",
"(",
"\"%02d\"",
",",
"$",
"minutes",
")",
".",
"\":\"",
".",
"sprintf",
"(",
"\"%02d\"",
",",
"$",
"seconds",
")",
";",
"}"
] | Convert seconds to an elapsed time value
@param $seconds | [
"Convert",
"seconds",
"to",
"an",
"elapsed",
"time",
"value"
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/DateTimeUtils.php#L34-L49 | train |
ringoteam/RingoPhpRedmonBundle | Controller/Controller.php | Controller.getCurrentInstance | protected function getCurrentInstance()
{
$instance = $this->getRequest()->getSession()->get('instance');
if($instance) {
// Update of instance to have last logs created
$instance = $this->getManager()->find($instance->getId());
}
return $instance;
} | php | protected function getCurrentInstance()
{
$instance = $this->getRequest()->getSession()->get('instance');
if($instance) {
// Update of instance to have last logs created
$instance = $this->getManager()->find($instance->getId());
}
return $instance;
} | [
"protected",
"function",
"getCurrentInstance",
"(",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"'instance'",
")",
";",
"if",
"(",
"$",
"instance",
")",
"{",
"// Update of instance to have last logs created",
"$",
"instance",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"find",
"(",
"$",
"instance",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] | Get the current instance if exists
@return mixed | [
"Get",
"the",
"current",
"instance",
"if",
"exists"
] | 9aab989a9bee9e6152ec19f8a30bc24f3bde6012 | https://github.com/ringoteam/RingoPhpRedmonBundle/blob/9aab989a9bee9e6152ec19f8a30bc24f3bde6012/Controller/Controller.php#L39-L48 | train |
ringoteam/RingoPhpRedmonBundle | Controller/Controller.php | Controller.getWorker | protected function getWorker()
{
$instance = $this->getCurrentInstance();
if($instance) {
// Initialized with the current instance
$worker = $this->get('ringo_php_redmon.instance_worker')->setInstance($instance);
// We return worker only if the server is up
if($worker->ping()) {
return $worker;
}
// If we can't ping the server, current instance is removed from session
$this->getRequest()->getSession()->set('instance', null);
return false;
}
return false;
} | php | protected function getWorker()
{
$instance = $this->getCurrentInstance();
if($instance) {
// Initialized with the current instance
$worker = $this->get('ringo_php_redmon.instance_worker')->setInstance($instance);
// We return worker only if the server is up
if($worker->ping()) {
return $worker;
}
// If we can't ping the server, current instance is removed from session
$this->getRequest()->getSession()->set('instance', null);
return false;
}
return false;
} | [
"protected",
"function",
"getWorker",
"(",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getCurrentInstance",
"(",
")",
";",
"if",
"(",
"$",
"instance",
")",
"{",
"// Initialized with the current instance",
"$",
"worker",
"=",
"$",
"this",
"->",
"get",
"(",
"'ringo_php_redmon.instance_worker'",
")",
"->",
"setInstance",
"(",
"$",
"instance",
")",
";",
"// We return worker only if the server is up",
"if",
"(",
"$",
"worker",
"->",
"ping",
"(",
")",
")",
"{",
"return",
"$",
"worker",
";",
"}",
"// If we can't ping the server, current instance is removed from session",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'instance'",
",",
"null",
")",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] | Get instance worker initialized with current instance
@return boolean | [
"Get",
"instance",
"worker",
"initialized",
"with",
"current",
"instance"
] | 9aab989a9bee9e6152ec19f8a30bc24f3bde6012 | https://github.com/ringoteam/RingoPhpRedmonBundle/blob/9aab989a9bee9e6152ec19f8a30bc24f3bde6012/Controller/Controller.php#L55-L72 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.getConfig | public function getConfig($refresh = false)
{
return $this->getCache('plugins-config', $refresh, function () {
return [
'wei' => [
'aliases' => $this->getWeiAliases(),
],
'app' => [
'controllerMap' => $this->getAppControllerMap(),
],
'plugin' => [
'pluginClasses' => $this->getPluginClasses(true),
],
];
});
} | php | public function getConfig($refresh = false)
{
return $this->getCache('plugins-config', $refresh, function () {
return [
'wei' => [
'aliases' => $this->getWeiAliases(),
],
'app' => [
'controllerMap' => $this->getAppControllerMap(),
],
'plugin' => [
'pluginClasses' => $this->getPluginClasses(true),
],
];
});
} | [
"public",
"function",
"getConfig",
"(",
"$",
"refresh",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getCache",
"(",
"'plugins-config'",
",",
"$",
"refresh",
",",
"function",
"(",
")",
"{",
"return",
"[",
"'wei'",
"=>",
"[",
"'aliases'",
"=>",
"$",
"this",
"->",
"getWeiAliases",
"(",
")",
",",
"]",
",",
"'app'",
"=>",
"[",
"'controllerMap'",
"=>",
"$",
"this",
"->",
"getAppControllerMap",
"(",
")",
",",
"]",
",",
"'plugin'",
"=>",
"[",
"'pluginClasses'",
"=>",
"$",
"this",
"->",
"getPluginClasses",
"(",
"true",
")",
",",
"]",
",",
"]",
";",
"}",
")",
";",
"}"
] | Receive plugin relatives service configs
@param bool $refresh
@return array | [
"Receive",
"plugin",
"relatives",
"service",
"configs"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L119-L134 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.getPluginClasses | protected function getPluginClasses($refresh = false)
{
if ($refresh || !$this->pluginClasses) {
$this->pluginClasses = [];
$files = $this->globByDirs($this->dirs, '/Plugin.php');
foreach ($files as $file) {
$class = $this->guessClassName($file);
$name = explode('\\', $class)[1];
$name = $this->dash($name);
$this->pluginClasses[$name] = $class;
}
ksort($this->pluginClasses);
}
return $this->pluginClasses;
} | php | protected function getPluginClasses($refresh = false)
{
if ($refresh || !$this->pluginClasses) {
$this->pluginClasses = [];
$files = $this->globByDirs($this->dirs, '/Plugin.php');
foreach ($files as $file) {
$class = $this->guessClassName($file);
$name = explode('\\', $class)[1];
$name = $this->dash($name);
$this->pluginClasses[$name] = $class;
}
ksort($this->pluginClasses);
}
return $this->pluginClasses;
} | [
"protected",
"function",
"getPluginClasses",
"(",
"$",
"refresh",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"refresh",
"||",
"!",
"$",
"this",
"->",
"pluginClasses",
")",
"{",
"$",
"this",
"->",
"pluginClasses",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"globByDirs",
"(",
"$",
"this",
"->",
"dirs",
",",
"'/Plugin.php'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"guessClassName",
"(",
"$",
"file",
")",
";",
"$",
"name",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"class",
")",
"[",
"1",
"]",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"dash",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"pluginClasses",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"}",
"ksort",
"(",
"$",
"this",
"->",
"pluginClasses",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pluginClasses",
";",
"}"
] | Get all plugin classes
@param bool $refresh
@return array
@throws Exception | [
"Get",
"all",
"plugin",
"classes"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L163-L180 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.parseResource | public function parseResource($resource)
{
$pluginId = $file = null;
if (isset($resource[0]) && $resource[0] == '@') {
list($pluginId, $file) = explode('/', $resource, 2);
$pluginId = substr($pluginId, 1);
}
// @deprecated
if (strpos($resource, ':') !== false) {
wei()->logger->warning('deprecated view', $resource);
list($pluginId, $file) = explode(':', $resource, 2);
}
if ($pluginId) {
$plugin = $this->getOneById($pluginId);
$path = $plugin->getBasePath() . '/resources';
return ['path' => $path, 'file' => $file];
} else {
return ['path' => null, 'file' => $resource];
}
} | php | public function parseResource($resource)
{
$pluginId = $file = null;
if (isset($resource[0]) && $resource[0] == '@') {
list($pluginId, $file) = explode('/', $resource, 2);
$pluginId = substr($pluginId, 1);
}
// @deprecated
if (strpos($resource, ':') !== false) {
wei()->logger->warning('deprecated view', $resource);
list($pluginId, $file) = explode(':', $resource, 2);
}
if ($pluginId) {
$plugin = $this->getOneById($pluginId);
$path = $plugin->getBasePath() . '/resources';
return ['path' => $path, 'file' => $file];
} else {
return ['path' => null, 'file' => $resource];
}
} | [
"public",
"function",
"parseResource",
"(",
"$",
"resource",
")",
"{",
"$",
"pluginId",
"=",
"$",
"file",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"resource",
"[",
"0",
"]",
")",
"&&",
"$",
"resource",
"[",
"0",
"]",
"==",
"'@'",
")",
"{",
"list",
"(",
"$",
"pluginId",
",",
"$",
"file",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"resource",
",",
"2",
")",
";",
"$",
"pluginId",
"=",
"substr",
"(",
"$",
"pluginId",
",",
"1",
")",
";",
"}",
"// @deprecated",
"if",
"(",
"strpos",
"(",
"$",
"resource",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"wei",
"(",
")",
"->",
"logger",
"->",
"warning",
"(",
"'deprecated view'",
",",
"$",
"resource",
")",
";",
"list",
"(",
"$",
"pluginId",
",",
"$",
"file",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"resource",
",",
"2",
")",
";",
"}",
"if",
"(",
"$",
"pluginId",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"getOneById",
"(",
"$",
"pluginId",
")",
";",
"$",
"path",
"=",
"$",
"plugin",
"->",
"getBasePath",
"(",
")",
".",
"'/resources'",
";",
"return",
"[",
"'path'",
"=>",
"$",
"path",
",",
"'file'",
"=>",
"$",
"file",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"'path'",
"=>",
"null",
",",
"'file'",
"=>",
"$",
"resource",
"]",
";",
"}",
"}"
] | Parse a resource and return the components contains path and file
@param string $resource
@return array|false Returns false when resource is not starts with @ | [
"Parse",
"a",
"resource",
"and",
"return",
"the",
"components",
"contains",
"path",
"and",
"file"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L206-L228 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.install | public function install($id)
{
$plugin = $this->getById($id);
if (!$plugin) {
return ['code' => -1, 'message' => 'Plugin not found'];
}
if ($this->isInstalled($id)) {
return ['code' => -2, 'message' => 'Plugin has been installed'];
}
$ret = $plugin->install();
if ($ret['code'] !== 1) {
return $ret;
}
$pluginIds = $this->getInstalledIds();
$pluginIds[] = $id;
$this->setInstalledIds($pluginIds);
$this->getEvents(true);
return $ret;
} | php | public function install($id)
{
$plugin = $this->getById($id);
if (!$plugin) {
return ['code' => -1, 'message' => 'Plugin not found'];
}
if ($this->isInstalled($id)) {
return ['code' => -2, 'message' => 'Plugin has been installed'];
}
$ret = $plugin->install();
if ($ret['code'] !== 1) {
return $ret;
}
$pluginIds = $this->getInstalledIds();
$pluginIds[] = $id;
$this->setInstalledIds($pluginIds);
$this->getEvents(true);
return $ret;
} | [
"public",
"function",
"install",
"(",
"$",
"id",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"plugin",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"1",
",",
"'message'",
"=>",
"'Plugin not found'",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isInstalled",
"(",
"$",
"id",
")",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"2",
",",
"'message'",
"=>",
"'Plugin has been installed'",
"]",
";",
"}",
"$",
"ret",
"=",
"$",
"plugin",
"->",
"install",
"(",
")",
";",
"if",
"(",
"$",
"ret",
"[",
"'code'",
"]",
"!==",
"1",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"$",
"pluginIds",
"=",
"$",
"this",
"->",
"getInstalledIds",
"(",
")",
";",
"$",
"pluginIds",
"[",
"]",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"setInstalledIds",
"(",
"$",
"pluginIds",
")",
";",
"$",
"this",
"->",
"getEvents",
"(",
"true",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | Install a plugin by ID
@param string $id
@return array | [
"Install",
"a",
"plugin",
"by",
"ID"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L338-L361 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.uninstall | public function uninstall($id)
{
$plugin = $this->getById($id);
if (!$plugin) {
return ['code' => -3, 'message' => 'Plugin not found'];
}
if (!$this->isInstalled($id)) {
return ['code' => -4, 'message' => 'Plugin not installed'];
}
if ($this->isBuildIn($id)) {
return ['code' => -5, 'message' => 'Can not uninstall build-in plugin'];
}
$ret = $plugin->uninstall();
if ($ret['code'] !== 1) {
return $ret;
}
$pluginIds = $this->getInstalledIds();
$key = array_search($id, $pluginIds);
if (false === $key) {
return ['code' => -6, 'message' => 'Plugin not installed'];
}
unset($pluginIds[$key]);
$this->setInstalledIds($pluginIds);
$this->getEvents(true);
return $ret;
} | php | public function uninstall($id)
{
$plugin = $this->getById($id);
if (!$plugin) {
return ['code' => -3, 'message' => 'Plugin not found'];
}
if (!$this->isInstalled($id)) {
return ['code' => -4, 'message' => 'Plugin not installed'];
}
if ($this->isBuildIn($id)) {
return ['code' => -5, 'message' => 'Can not uninstall build-in plugin'];
}
$ret = $plugin->uninstall();
if ($ret['code'] !== 1) {
return $ret;
}
$pluginIds = $this->getInstalledIds();
$key = array_search($id, $pluginIds);
if (false === $key) {
return ['code' => -6, 'message' => 'Plugin not installed'];
}
unset($pluginIds[$key]);
$this->setInstalledIds($pluginIds);
$this->getEvents(true);
return $ret;
} | [
"public",
"function",
"uninstall",
"(",
"$",
"id",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"plugin",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"3",
",",
"'message'",
"=>",
"'Plugin not found'",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isInstalled",
"(",
"$",
"id",
")",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"4",
",",
"'message'",
"=>",
"'Plugin not installed'",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isBuildIn",
"(",
"$",
"id",
")",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"5",
",",
"'message'",
"=>",
"'Can not uninstall build-in plugin'",
"]",
";",
"}",
"$",
"ret",
"=",
"$",
"plugin",
"->",
"uninstall",
"(",
")",
";",
"if",
"(",
"$",
"ret",
"[",
"'code'",
"]",
"!==",
"1",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"$",
"pluginIds",
"=",
"$",
"this",
"->",
"getInstalledIds",
"(",
")",
";",
"$",
"key",
"=",
"array_search",
"(",
"$",
"id",
",",
"$",
"pluginIds",
")",
";",
"if",
"(",
"false",
"===",
"$",
"key",
")",
"{",
"return",
"[",
"'code'",
"=>",
"-",
"6",
",",
"'message'",
"=>",
"'Plugin not installed'",
"]",
";",
"}",
"unset",
"(",
"$",
"pluginIds",
"[",
"$",
"key",
"]",
")",
";",
"$",
"this",
"->",
"setInstalledIds",
"(",
"$",
"pluginIds",
")",
";",
"$",
"this",
"->",
"getEvents",
"(",
"true",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | Uninstall a plugin by ID
@param string $id
@return array | [
"Uninstall",
"a",
"plugin",
"by",
"ID"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L369-L400 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.getPluginClass | protected function getPluginClass($id)
{
return isset($this->pluginClasses[$id]) ? $this->pluginClasses[$id] : null;
} | php | protected function getPluginClass($id)
{
return isset($this->pluginClasses[$id]) ? $this->pluginClasses[$id] : null;
} | [
"protected",
"function",
"getPluginClass",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"pluginClasses",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"pluginClasses",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Returns the plugin class by plugin ID
@param string $id
@return string | [
"Returns",
"the",
"plugin",
"class",
"by",
"plugin",
"ID"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L441-L444 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.getEventsById | protected function getEventsById($id)
{
$events = [];
$methods = get_class_methods($this->getPluginClass($id));
foreach ($methods as $method) {
// The event naming is onName[Priority],eg onProductShowItem50
if (substr($method, 0, 2) != 'on') {
continue;
}
$event = lcfirst(substr($method, 2));
if (is_numeric(substr($event, -1))) {
preg_match('/(.+?)(\d+)$/', $event, $matches);
$events[] = ['name' => $matches[1], 'priority' => (int) $matches[2]];
} else {
$events[] = ['name' => $event, 'priority' => static::DEFAULT_PRIORITY];
}
}
return $events;
} | php | protected function getEventsById($id)
{
$events = [];
$methods = get_class_methods($this->getPluginClass($id));
foreach ($methods as $method) {
// The event naming is onName[Priority],eg onProductShowItem50
if (substr($method, 0, 2) != 'on') {
continue;
}
$event = lcfirst(substr($method, 2));
if (is_numeric(substr($event, -1))) {
preg_match('/(.+?)(\d+)$/', $event, $matches);
$events[] = ['name' => $matches[1], 'priority' => (int) $matches[2]];
} else {
$events[] = ['name' => $event, 'priority' => static::DEFAULT_PRIORITY];
}
}
return $events;
} | [
"protected",
"function",
"getEventsById",
"(",
"$",
"id",
")",
"{",
"$",
"events",
"=",
"[",
"]",
";",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"this",
"->",
"getPluginClass",
"(",
"$",
"id",
")",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"// The event naming is onName[Priority],eg onProductShowItem50",
"if",
"(",
"substr",
"(",
"$",
"method",
",",
"0",
",",
"2",
")",
"!=",
"'on'",
")",
"{",
"continue",
";",
"}",
"$",
"event",
"=",
"lcfirst",
"(",
"substr",
"(",
"$",
"method",
",",
"2",
")",
")",
";",
"if",
"(",
"is_numeric",
"(",
"substr",
"(",
"$",
"event",
",",
"-",
"1",
")",
")",
")",
"{",
"preg_match",
"(",
"'/(.+?)(\\d+)$/'",
",",
"$",
"event",
",",
"$",
"matches",
")",
";",
"$",
"events",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"matches",
"[",
"1",
"]",
",",
"'priority'",
"=>",
"(",
"int",
")",
"$",
"matches",
"[",
"2",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"events",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"event",
",",
"'priority'",
"=>",
"static",
"::",
"DEFAULT_PRIORITY",
"]",
";",
"}",
"}",
"return",
"$",
"events",
";",
"}"
] | Returns the event definitions by plugin ID
@param string $id
@return array | [
"Returns",
"the",
"event",
"definitions",
"by",
"plugin",
"ID"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L487-L506 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.loadEvent | public function loadEvent($name)
{
// 1. Load event data only once
if (isset($this->loadedEvents[$name])) {
return;
}
$this->loadedEvents[$name] = true;
// 2. Get event handlers
$events = $this->getEvents();
if (!isset($events[$name])) {
return;
}
// 3. Attach handlers to event
$baseMethod = 'on' . ucfirst($name);
foreach ($events[$name] as $priority => $pluginIds) {
if ($priority && $priority != static::DEFAULT_PRIORITY) {
$method = $baseMethod . $priority;
} else {
$method = $baseMethod;
}
foreach ($pluginIds as $pluginId) {
$plugin = $this->getById($pluginId);
if (method_exists($plugin, $method)) {
$this->event->on($name, [$plugin, $method], $priority);
}
}
}
} | php | public function loadEvent($name)
{
// 1. Load event data only once
if (isset($this->loadedEvents[$name])) {
return;
}
$this->loadedEvents[$name] = true;
// 2. Get event handlers
$events = $this->getEvents();
if (!isset($events[$name])) {
return;
}
// 3. Attach handlers to event
$baseMethod = 'on' . ucfirst($name);
foreach ($events[$name] as $priority => $pluginIds) {
if ($priority && $priority != static::DEFAULT_PRIORITY) {
$method = $baseMethod . $priority;
} else {
$method = $baseMethod;
}
foreach ($pluginIds as $pluginId) {
$plugin = $this->getById($pluginId);
if (method_exists($plugin, $method)) {
$this->event->on($name, [$plugin, $method], $priority);
}
}
}
} | [
"public",
"function",
"loadEvent",
"(",
"$",
"name",
")",
"{",
"// 1. Load event data only once",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"loadedEvents",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"loadedEvents",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"// 2. Get event handlers",
"$",
"events",
"=",
"$",
"this",
"->",
"getEvents",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"events",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
";",
"}",
"// 3. Attach handlers to event",
"$",
"baseMethod",
"=",
"'on'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"events",
"[",
"$",
"name",
"]",
"as",
"$",
"priority",
"=>",
"$",
"pluginIds",
")",
"{",
"if",
"(",
"$",
"priority",
"&&",
"$",
"priority",
"!=",
"static",
"::",
"DEFAULT_PRIORITY",
")",
"{",
"$",
"method",
"=",
"$",
"baseMethod",
".",
"$",
"priority",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"$",
"baseMethod",
";",
"}",
"foreach",
"(",
"$",
"pluginIds",
"as",
"$",
"pluginId",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"pluginId",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"plugin",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"event",
"->",
"on",
"(",
"$",
"name",
",",
"[",
"$",
"plugin",
",",
"$",
"method",
"]",
",",
"$",
"priority",
")",
";",
"}",
"}",
"}",
"}"
] | Load plugin event by name
@param string $name | [
"Load",
"plugin",
"event",
"by",
"name"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L513-L543 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.generateClassMap | public function generateClassMap(array $dirs, $pattern, $type, $ignoreProject = true)
{
$patterns = (array) $pattern;
$types = (array) $type;
$map = [];
foreach ($patterns as $i => $pattern) {
$files = $this->globByDirs($dirs, $pattern);
foreach ($files as $file) {
$class = $this->guessClassName($file, $ignoreProject);
if (!$class) {
continue;
}
$name = $this->getShortName($class, $types[$i]);
$this->addDuplicates($map, $name, $class);
$map[$name] = $class;
}
}
ksort($map);
// Display first type name
return $this->filterDuplicates($map, lcfirst(is_array($type) ? current($type) : $type));
} | php | public function generateClassMap(array $dirs, $pattern, $type, $ignoreProject = true)
{
$patterns = (array) $pattern;
$types = (array) $type;
$map = [];
foreach ($patterns as $i => $pattern) {
$files = $this->globByDirs($dirs, $pattern);
foreach ($files as $file) {
$class = $this->guessClassName($file, $ignoreProject);
if (!$class) {
continue;
}
$name = $this->getShortName($class, $types[$i]);
$this->addDuplicates($map, $name, $class);
$map[$name] = $class;
}
}
ksort($map);
// Display first type name
return $this->filterDuplicates($map, lcfirst(is_array($type) ? current($type) : $type));
} | [
"public",
"function",
"generateClassMap",
"(",
"array",
"$",
"dirs",
",",
"$",
"pattern",
",",
"$",
"type",
",",
"$",
"ignoreProject",
"=",
"true",
")",
"{",
"$",
"patterns",
"=",
"(",
"array",
")",
"$",
"pattern",
";",
"$",
"types",
"=",
"(",
"array",
")",
"$",
"type",
";",
"$",
"map",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"patterns",
"as",
"$",
"i",
"=>",
"$",
"pattern",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"globByDirs",
"(",
"$",
"dirs",
",",
"$",
"pattern",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"guessClassName",
"(",
"$",
"file",
",",
"$",
"ignoreProject",
")",
";",
"if",
"(",
"!",
"$",
"class",
")",
"{",
"continue",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"getShortName",
"(",
"$",
"class",
",",
"$",
"types",
"[",
"$",
"i",
"]",
")",
";",
"$",
"this",
"->",
"addDuplicates",
"(",
"$",
"map",
",",
"$",
"name",
",",
"$",
"class",
")",
";",
"$",
"map",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"}",
"}",
"ksort",
"(",
"$",
"map",
")",
";",
"// Display first type name",
"return",
"$",
"this",
"->",
"filterDuplicates",
"(",
"$",
"map",
",",
"lcfirst",
"(",
"is_array",
"(",
"$",
"type",
")",
"?",
"current",
"(",
"$",
"type",
")",
":",
"$",
"type",
")",
")",
";",
"}"
] | Generate class map
@param array $dirs
@param string|array $pattern
@param string|array $type
@param bool $ignoreProject
@return array
@throws Exception | [
"Generate",
"class",
"map"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L555-L580 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.guessClassName | protected function guessClassName($file, $ignoreProject = false)
{
// 假设为根目录
if ($file[0] === '.') {
$file = '\\' . ltrim($file, './');
}
list($dir, $className) = explode('src/', $file);
// TODO V2 处理V2的插件形式
if ($dir == '\\') {
$dir = '';
}
$composerJson = ($dir ? ($dir . '/') : '') . 'composer.json';
if (!is_file($composerJson)) {
throw new Exception(sprintf('Composer file "%s" not found', $composerJson));
}
$json = json_decode(file_get_contents($composerJson), true);
if ($ignoreProject && isset($json['type']) && $json['type'] == 'project') {
return false;
}
if (!isset($json['autoload']['psr-4']) || !$json['autoload']['psr-4']) {
throw new Exception('Missing psr-4 autoload config');
}
$namespace = key($json['autoload']['psr-4']);
$className = rtrim($namespace, '\\') . '\\' . $className;
// 移除结尾的.php扩展名,并替换目录为命名空间分隔符
return strtr(substr($className, 0, -4), ['/' => '\\']);
} | php | protected function guessClassName($file, $ignoreProject = false)
{
// 假设为根目录
if ($file[0] === '.') {
$file = '\\' . ltrim($file, './');
}
list($dir, $className) = explode('src/', $file);
// TODO V2 处理V2的插件形式
if ($dir == '\\') {
$dir = '';
}
$composerJson = ($dir ? ($dir . '/') : '') . 'composer.json';
if (!is_file($composerJson)) {
throw new Exception(sprintf('Composer file "%s" not found', $composerJson));
}
$json = json_decode(file_get_contents($composerJson), true);
if ($ignoreProject && isset($json['type']) && $json['type'] == 'project') {
return false;
}
if (!isset($json['autoload']['psr-4']) || !$json['autoload']['psr-4']) {
throw new Exception('Missing psr-4 autoload config');
}
$namespace = key($json['autoload']['psr-4']);
$className = rtrim($namespace, '\\') . '\\' . $className;
// 移除结尾的.php扩展名,并替换目录为命名空间分隔符
return strtr(substr($className, 0, -4), ['/' => '\\']);
} | [
"protected",
"function",
"guessClassName",
"(",
"$",
"file",
",",
"$",
"ignoreProject",
"=",
"false",
")",
"{",
"// 假设为根目录",
"if",
"(",
"$",
"file",
"[",
"0",
"]",
"===",
"'.'",
")",
"{",
"$",
"file",
"=",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"file",
",",
"'./'",
")",
";",
"}",
"list",
"(",
"$",
"dir",
",",
"$",
"className",
")",
"=",
"explode",
"(",
"'src/'",
",",
"$",
"file",
")",
";",
"// TODO V2 处理V2的插件形式",
"if",
"(",
"$",
"dir",
"==",
"'\\\\'",
")",
"{",
"$",
"dir",
"=",
"''",
";",
"}",
"$",
"composerJson",
"=",
"(",
"$",
"dir",
"?",
"(",
"$",
"dir",
".",
"'/'",
")",
":",
"''",
")",
".",
"'composer.json'",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"composerJson",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Composer file \"%s\" not found'",
",",
"$",
"composerJson",
")",
")",
";",
"}",
"$",
"json",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"composerJson",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"ignoreProject",
"&&",
"isset",
"(",
"$",
"json",
"[",
"'type'",
"]",
")",
"&&",
"$",
"json",
"[",
"'type'",
"]",
"==",
"'project'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"json",
"[",
"'autoload'",
"]",
"[",
"'psr-4'",
"]",
")",
"||",
"!",
"$",
"json",
"[",
"'autoload'",
"]",
"[",
"'psr-4'",
"]",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Missing psr-4 autoload config'",
")",
";",
"}",
"$",
"namespace",
"=",
"key",
"(",
"$",
"json",
"[",
"'autoload'",
"]",
"[",
"'psr-4'",
"]",
")",
";",
"$",
"className",
"=",
"rtrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
".",
"'\\\\'",
".",
"$",
"className",
";",
"// 移除结尾的.php扩展名,并替换目录为命名空间分隔符",
"return",
"strtr",
"(",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"-",
"4",
")",
",",
"[",
"'/'",
"=>",
"'\\\\'",
"]",
")",
";",
"}"
] | Guest class name by file name
@param string $file
@param bool $ignoreProject
@return string
@throws Exception | [
"Guest",
"class",
"name",
"by",
"file",
"name"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L599-L632 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.getShortName | protected function getShortName($class, $type)
{
// 获取类名中,类型之后的半段
// 如Miaoxing\User\Controller\Admins\User返回Admin\User
$name = explode('\\' . $type . '\\', $class, 2)[1];
// 将名称转换为小写
$pos = strrpos($name, '\\');
$pos = $pos === false ? 0 : $pos + 1;
$name[$pos] = lcfirst($name[$pos]);
$name = lcfirst($name);
return $name;
} | php | protected function getShortName($class, $type)
{
// 获取类名中,类型之后的半段
// 如Miaoxing\User\Controller\Admins\User返回Admin\User
$name = explode('\\' . $type . '\\', $class, 2)[1];
// 将名称转换为小写
$pos = strrpos($name, '\\');
$pos = $pos === false ? 0 : $pos + 1;
$name[$pos] = lcfirst($name[$pos]);
$name = lcfirst($name);
return $name;
} | [
"protected",
"function",
"getShortName",
"(",
"$",
"class",
",",
"$",
"type",
")",
"{",
"// 获取类名中,类型之后的半段",
"// 如Miaoxing\\User\\Controller\\Admins\\User返回Admin\\User",
"$",
"name",
"=",
"explode",
"(",
"'\\\\'",
".",
"$",
"type",
".",
"'\\\\'",
",",
"$",
"class",
",",
"2",
")",
"[",
"1",
"]",
";",
"// 将名称转换为小写",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'\\\\'",
")",
";",
"$",
"pos",
"=",
"$",
"pos",
"===",
"false",
"?",
"0",
":",
"$",
"pos",
"+",
"1",
";",
"$",
"name",
"[",
"$",
"pos",
"]",
"=",
"lcfirst",
"(",
"$",
"name",
"[",
"$",
"pos",
"]",
")",
";",
"$",
"name",
"=",
"lcfirst",
"(",
"$",
"name",
")",
";",
"return",
"$",
"name",
";",
"}"
] | Return short name of class by specified type
@param string $class
@param string $type
@return string | [
"Return",
"short",
"name",
"of",
"class",
"by",
"specified",
"type"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L641-L654 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.globByDirs | protected function globByDirs(array $dirs, $pattern)
{
$dirs = implode(',', $dirs);
$pattern = '{' . $dirs . '}' . $pattern;
return glob($pattern, GLOB_BRACE | GLOB_NOSORT);
} | php | protected function globByDirs(array $dirs, $pattern)
{
$dirs = implode(',', $dirs);
$pattern = '{' . $dirs . '}' . $pattern;
return glob($pattern, GLOB_BRACE | GLOB_NOSORT);
} | [
"protected",
"function",
"globByDirs",
"(",
"array",
"$",
"dirs",
",",
"$",
"pattern",
")",
"{",
"$",
"dirs",
"=",
"implode",
"(",
"','",
",",
"$",
"dirs",
")",
";",
"$",
"pattern",
"=",
"'{'",
".",
"$",
"dirs",
".",
"'}'",
".",
"$",
"pattern",
";",
"return",
"glob",
"(",
"$",
"pattern",
",",
"GLOB_BRACE",
"|",
"GLOB_NOSORT",
")",
";",
"}"
] | Find files matching a pattern in specified directories
@param array $dirs
@param string $pattern
@return array | [
"Find",
"files",
"matching",
"a",
"pattern",
"in",
"specified",
"directories"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L663-L669 | train |
miaoxing/plugin | src/Service/Plugin.php | Plugin.setInstalledIds | protected function setInstalledIds(array $pluginIds)
{
$app = $this->app->getRecord();
$app['pluginIds'] = array_filter($pluginIds);
$app->save();
return $this;
} | php | protected function setInstalledIds(array $pluginIds)
{
$app = $this->app->getRecord();
$app['pluginIds'] = array_filter($pluginIds);
$app->save();
return $this;
} | [
"protected",
"function",
"setInstalledIds",
"(",
"array",
"$",
"pluginIds",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
"->",
"getRecord",
"(",
")",
";",
"$",
"app",
"[",
"'pluginIds'",
"]",
"=",
"array_filter",
"(",
"$",
"pluginIds",
")",
";",
"$",
"app",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Stores installed plugin IDs
@param array $pluginIds
@return $this | [
"Stores",
"installed",
"plugin",
"IDs"
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/Plugin.php#L746-L753 | train |
shgysk8zer0/core_api | traits/files.php | Files.fclose | final protected function fclose()
{
$this->_fhandle = null;
$this->flocked = false;
$this->use_include_path = false;
} | php | final protected function fclose()
{
$this->_fhandle = null;
$this->flocked = false;
$this->use_include_path = false;
} | [
"final",
"protected",
"function",
"fclose",
"(",
")",
"{",
"$",
"this",
"->",
"_fhandle",
"=",
"null",
";",
"$",
"this",
"->",
"flocked",
"=",
"false",
";",
"$",
"this",
"->",
"use_include_path",
"=",
"false",
";",
"}"
] | "Closes" file. Only resets class variables
@return [type] [description] | [
"Closes",
"file",
".",
"Only",
"resets",
"class",
"variables"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L66-L71 | train |
shgysk8zer0/core_api | traits/files.php | Files.filesize | public function filesize()
{
if ($this->use_include_path) {
return filesize(stream_resolve_include_path($this->_fhandle));
} else {
return filesize($this->_fhandle);
}
} | php | public function filesize()
{
if ($this->use_include_path) {
return filesize(stream_resolve_include_path($this->_fhandle));
} else {
return filesize($this->_fhandle);
}
} | [
"public",
"function",
"filesize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"filesize",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"filesize",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file size
@param void
@return int The size of the file in bytes
@see https://php.net/manual/en/function.filesize.php | [
"Gets",
"file",
"size"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L252-L259 | train |
shgysk8zer0/core_api | traits/files.php | Files.fileinode | public function fileinode()
{
if ($this->use_include_path) {
return fileinode(stream_resolve_include_path($this->_fhandle));
} else {
return fileinode($this->_fhandle);
}
} | php | public function fileinode()
{
if ($this->use_include_path) {
return fileinode(stream_resolve_include_path($this->_fhandle));
} else {
return fileinode($this->_fhandle);
}
} | [
"public",
"function",
"fileinode",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"fileinode",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"fileinode",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file inode
@param void
@return int inode number of the file
@see https://php.net/manual/en/function.fileinode.php | [
"Gets",
"file",
"inode"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L268-L275 | train |
shgysk8zer0/core_api | traits/files.php | Files.fileatime | public function fileatime()
{
if ($this->use_include_path) {
return fileatime(stream_resolve_include_path($this->_fhandle));
} else {
return fileatime($this->_fhandle);
}
} | php | public function fileatime()
{
if ($this->use_include_path) {
return fileatime(stream_resolve_include_path($this->_fhandle));
} else {
return fileatime($this->_fhandle);
}
} | [
"public",
"function",
"fileatime",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"fileatime",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"fileatime",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets last access time of file
@param void
@return int The time the file was last accessed | [
"Gets",
"last",
"access",
"time",
"of",
"file"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L283-L290 | train |
shgysk8zer0/core_api | traits/files.php | Files.filectime | public function filectime()
{
if ($this->use_include_path) {
return filectime(stream_resolve_include_path($this->_fhandle));
} else {
return filectime($this->_fhandle);
}
} | php | public function filectime()
{
if ($this->use_include_path) {
return filectime(stream_resolve_include_path($this->_fhandle));
} else {
return filectime($this->_fhandle);
}
} | [
"public",
"function",
"filectime",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"filectime",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"filectime",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets inode change time of file
@param void
@return int The time the file was last changed | [
"Gets",
"inode",
"change",
"time",
"of",
"file"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L298-L305 | train |
shgysk8zer0/core_api | traits/files.php | Files.filemtime | public function filemtime()
{
if ($this->use_include_path) {
return filemtime(stream_resolve_include_path($this->_fhandle));
} else {
return filemtime($this->_fhandle);
}
} | php | public function filemtime()
{
if ($this->use_include_path) {
return filemtime(stream_resolve_include_path($this->_fhandle));
} else {
return filemtime($this->_fhandle);
}
} | [
"public",
"function",
"filemtime",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"filemtime",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"filemtime",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file modification time
@param void
@return int The time the file was last modified | [
"Gets",
"file",
"modification",
"time"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L313-L320 | train |
shgysk8zer0/core_api | traits/files.php | Files.fileowner | public function fileowner()
{
if ($this->use_include_path) {
return fileowner(stream_resolve_include_path($this->_fhandle));
} else {
return fileowner($this->_fhandle);
}
} | php | public function fileowner()
{
if ($this->use_include_path) {
return fileowner(stream_resolve_include_path($this->_fhandle));
} else {
return fileowner($this->_fhandle);
}
} | [
"public",
"function",
"fileowner",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"fileowner",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"fileowner",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file owner
@param void
@return int The user ID of the owner of the file | [
"Gets",
"file",
"owner"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L328-L335 | train |
shgysk8zer0/core_api | traits/files.php | Files.filegroup | public function filegroup()
{
if ($this->use_include_path) {
return filegroup(stream_resolve_include_path($this->_fhandle));
} else {
return filegroup($this->_fhandle);
}
} | php | public function filegroup()
{
if ($this->use_include_path) {
return filegroup(stream_resolve_include_path($this->_fhandle));
} else {
return filegroup($this->_fhandle);
}
} | [
"public",
"function",
"filegroup",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"filegroup",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"filegroup",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file group
@param void
@return int The group ID of the file | [
"Gets",
"file",
"group"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L343-L350 | train |
shgysk8zer0/core_api | traits/files.php | Files.fileperms | public function fileperms()
{
if ($this->use_include_path) {
return fileperms(stream_resolve_include_path($this->_fhandle));
} else {
return fileperms($this->_fhandle);
}
} | php | public function fileperms()
{
if ($this->use_include_path) {
return fileperms(stream_resolve_include_path($this->_fhandle));
} else {
return fileperms($this->_fhandle);
}
} | [
"public",
"function",
"fileperms",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"use_include_path",
")",
"{",
"return",
"fileperms",
"(",
"stream_resolve_include_path",
"(",
"$",
"this",
"->",
"_fhandle",
")",
")",
";",
"}",
"else",
"{",
"return",
"fileperms",
"(",
"$",
"this",
"->",
"_fhandle",
")",
";",
"}",
"}"
] | Gets file permissions
@param void
@return int The file's permissions as a numeric mode | [
"Gets",
"file",
"permissions"
] | 9e9b8baf761af874b95256ad2462e55fbb2b2e58 | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/files.php#L358-L365 | train |
anime-db/catalog-bundle | src/Entity/Storage.php | Storage.getTypeTitle | public function getTypeTitle()
{
return isset(self::$type_titles[$this->type]) ? self::$type_titles[$this->type] : '';
} | php | public function getTypeTitle()
{
return isset(self::$type_titles[$this->type]) ? self::$type_titles[$this->type] : '';
} | [
"public",
"function",
"getTypeTitle",
"(",
")",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"type_titles",
"[",
"$",
"this",
"->",
"type",
"]",
")",
"?",
"self",
"::",
"$",
"type_titles",
"[",
"$",
"this",
"->",
"type",
"]",
":",
"''",
";",
"}"
] | Get title for current type.
@return string | [
"Get",
"title",
"for",
"current",
"type",
"."
] | 631b6f92a654e91bee84f46218c52cf42bdb8606 | https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Entity/Storage.php#L315-L318 | train |
CalderaWP/caldera-interop | src/Traits/Rest/ProvidesRestParams.php | ProvidesRestParams.getParam | public function getParam(string $paramName)
{
return $this->hasParam($paramName) ? $this->params[ $paramName ] : null;
} | php | public function getParam(string $paramName)
{
return $this->hasParam($paramName) ? $this->params[ $paramName ] : null;
} | [
"public",
"function",
"getParam",
"(",
"string",
"$",
"paramName",
")",
"{",
"return",
"$",
"this",
"->",
"hasParam",
"(",
"$",
"paramName",
")",
"?",
"$",
"this",
"->",
"params",
"[",
"$",
"paramName",
"]",
":",
"null",
";",
"}"
] | Get parameter from request
@param string $paramName
@return mixed | [
"Get",
"parameter",
"from",
"request"
] | d25c4bc930200b314fbd42d084080b5d85261c94 | https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/Traits/Rest/ProvidesRestParams.php#L20-L23 | train |
CalderaWP/caldera-interop | src/Traits/Rest/ProvidesRestParams.php | ProvidesRestParams.setParam | public function setParam(string $paramName, $paramValue): HttpRequestContract
{
$this->params[ $paramName ] = $paramValue;
return $this;
} | php | public function setParam(string $paramName, $paramValue): HttpRequestContract
{
$this->params[ $paramName ] = $paramValue;
return $this;
} | [
"public",
"function",
"setParam",
"(",
"string",
"$",
"paramName",
",",
"$",
"paramValue",
")",
":",
"HttpRequestContract",
"{",
"$",
"this",
"->",
"params",
"[",
"$",
"paramName",
"]",
"=",
"$",
"paramValue",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameter in request
@param string $paramName
@param mixed $paramValue
@return $this | [
"Set",
"parameter",
"in",
"request"
] | d25c4bc930200b314fbd42d084080b5d85261c94 | https://github.com/CalderaWP/caldera-interop/blob/d25c4bc930200b314fbd42d084080b5d85261c94/src/Traits/Rest/ProvidesRestParams.php#L33-L37 | train |
CismonX/ProcConnection | src/ProcConnection.php | ProcConnection.setArray | function setArray(array $options) {
foreach ($options as $key => $value) {
$this->set($key, $value);
}
return $this;
} | php | function setArray(array $options) {
foreach ($options as $key => $value) {
$this->set($key, $value);
}
return $this;
} | [
"function",
"setArray",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Multiple set options.
@param array $options
@return self | [
"Multiple",
"set",
"options",
"."
] | 497cd6f7261ce2fa5054648664049aadc07e1df2 | https://github.com/CismonX/ProcConnection/blob/497cd6f7261ce2fa5054648664049aadc07e1df2/src/ProcConnection.php#L119-L124 | train |
CismonX/ProcConnection | src/ProcConnection.php | ProcConnection.run | function run(callable $callback = null) {
if (isset($this->res))
return null;
$this->res = proc_open($this->cmd, $this->descriptor_spec, $this->pipes, $this->cwd, $this->env);
if ($this->res) {
$this->stdout = new TcpConnection($this->pipes[1]);
if (is_callable($this->onMessage))
$this->stdout->onMessage = function ($conn, $data) {
($this->onMessage)($this, $data);
};
if (is_callable($this->onClose))
$this->stdout->onClose = function () {
($this->onClose)($this);
};
stream_set_blocking($this->pipes[0], false);
if (is_callable($callback))
$callback($this);
return true;
}
unset ($this->res);
return false;
} | php | function run(callable $callback = null) {
if (isset($this->res))
return null;
$this->res = proc_open($this->cmd, $this->descriptor_spec, $this->pipes, $this->cwd, $this->env);
if ($this->res) {
$this->stdout = new TcpConnection($this->pipes[1]);
if (is_callable($this->onMessage))
$this->stdout->onMessage = function ($conn, $data) {
($this->onMessage)($this, $data);
};
if (is_callable($this->onClose))
$this->stdout->onClose = function () {
($this->onClose)($this);
};
stream_set_blocking($this->pipes[0], false);
if (is_callable($callback))
$callback($this);
return true;
}
unset ($this->res);
return false;
} | [
"function",
"run",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"res",
")",
")",
"return",
"null",
";",
"$",
"this",
"->",
"res",
"=",
"proc_open",
"(",
"$",
"this",
"->",
"cmd",
",",
"$",
"this",
"->",
"descriptor_spec",
",",
"$",
"this",
"->",
"pipes",
",",
"$",
"this",
"->",
"cwd",
",",
"$",
"this",
"->",
"env",
")",
";",
"if",
"(",
"$",
"this",
"->",
"res",
")",
"{",
"$",
"this",
"->",
"stdout",
"=",
"new",
"TcpConnection",
"(",
"$",
"this",
"->",
"pipes",
"[",
"1",
"]",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"onMessage",
")",
")",
"$",
"this",
"->",
"stdout",
"->",
"onMessage",
"=",
"function",
"(",
"$",
"conn",
",",
"$",
"data",
")",
"{",
"(",
"$",
"this",
"->",
"onMessage",
")",
"(",
"$",
"this",
",",
"$",
"data",
")",
";",
"}",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"onClose",
")",
")",
"$",
"this",
"->",
"stdout",
"->",
"onClose",
"=",
"function",
"(",
")",
"{",
"(",
"$",
"this",
"->",
"onClose",
")",
"(",
"$",
"this",
")",
";",
"}",
";",
"stream_set_blocking",
"(",
"$",
"this",
"->",
"pipes",
"[",
"0",
"]",
",",
"false",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"return",
"true",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"res",
")",
";",
"return",
"false",
";",
"}"
] | Execute command in a child process.
@param callable $callback
@return bool. | [
"Execute",
"command",
"in",
"a",
"child",
"process",
"."
] | 497cd6f7261ce2fa5054648664049aadc07e1df2 | https://github.com/CismonX/ProcConnection/blob/497cd6f7261ce2fa5054648664049aadc07e1df2/src/ProcConnection.php#L139-L160 | train |
CismonX/ProcConnection | src/ProcConnection.php | ProcConnection.send | function send($data, $length = null) {
if (!isset($this->pipes[0]))
return 0;
if (!isset($length))
$length = strlen($data);
return intval(fwrite($this->pipes[0], $data, $length));
} | php | function send($data, $length = null) {
if (!isset($this->pipes[0]))
return 0;
if (!isset($length))
$length = strlen($data);
return intval(fwrite($this->pipes[0], $data, $length));
} | [
"function",
"send",
"(",
"$",
"data",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pipes",
"[",
"0",
"]",
")",
")",
"return",
"0",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"length",
")",
")",
"$",
"length",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"return",
"intval",
"(",
"fwrite",
"(",
"$",
"this",
"->",
"pipes",
"[",
"0",
"]",
",",
"$",
"data",
",",
"$",
"length",
")",
")",
";",
"}"
] | Write data to stdin pipe.
@param mixed $data
@param int|null $length
@return int : number of bytes written. | [
"Write",
"data",
"to",
"stdin",
"pipe",
"."
] | 497cd6f7261ce2fa5054648664049aadc07e1df2 | https://github.com/CismonX/ProcConnection/blob/497cd6f7261ce2fa5054648664049aadc07e1df2/src/ProcConnection.php#L168-L174 | train |
CismonX/ProcConnection | src/ProcConnection.php | ProcConnection.close | function close() {
if (isset($this->res)) {
$this->stdout->close();
fclose($this->pipes[0]);
$status = $this->status();
$exit = $status['running'] ? proc_close($this->res) : $status['exitcode'];
unset($this->res, $this->pipes, $this->stdout);
return $exit;
}
return null;
} | php | function close() {
if (isset($this->res)) {
$this->stdout->close();
fclose($this->pipes[0]);
$status = $this->status();
$exit = $status['running'] ? proc_close($this->res) : $status['exitcode'];
unset($this->res, $this->pipes, $this->stdout);
return $exit;
}
return null;
} | [
"function",
"close",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"res",
")",
")",
"{",
"$",
"this",
"->",
"stdout",
"->",
"close",
"(",
")",
";",
"fclose",
"(",
"$",
"this",
"->",
"pipes",
"[",
"0",
"]",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"status",
"(",
")",
";",
"$",
"exit",
"=",
"$",
"status",
"[",
"'running'",
"]",
"?",
"proc_close",
"(",
"$",
"this",
"->",
"res",
")",
":",
"$",
"status",
"[",
"'exitcode'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"res",
",",
"$",
"this",
"->",
"pipes",
",",
"$",
"this",
"->",
"stdout",
")",
";",
"return",
"$",
"exit",
";",
"}",
"return",
"null",
";",
"}"
] | Terminate process.
@return int - exit code | [
"Terminate",
"process",
"."
] | 497cd6f7261ce2fa5054648664049aadc07e1df2 | https://github.com/CismonX/ProcConnection/blob/497cd6f7261ce2fa5054648664049aadc07e1df2/src/ProcConnection.php#L180-L190 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.validateAsArray | public function validateAsArray($bool = null) {
if(false === is_bool($bool) && null !== $bool) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($bool)), E_USER_ERROR);
}
if(null === $bool) {
$bool = true;
}
foreach($this -> getFieldnames() as $field) {
$this -> validateAsArray[$field] = $bool;
}
return $this;
} | php | public function validateAsArray($bool = null) {
if(false === is_bool($bool) && null !== $bool) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type boolean, "%s" given', __METHOD__, gettype($bool)), E_USER_ERROR);
}
if(null === $bool) {
$bool = true;
}
foreach($this -> getFieldnames() as $field) {
$this -> validateAsArray[$field] = $bool;
}
return $this;
} | [
"public",
"function",
"validateAsArray",
"(",
"$",
"bool",
"=",
"null",
")",
"{",
"if",
"(",
"false",
"===",
"is_bool",
"(",
"$",
"bool",
")",
"&&",
"null",
"!==",
"$",
"bool",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type boolean, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"bool",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"bool",
")",
"{",
"$",
"bool",
"=",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getFieldnames",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"validateAsArray",
"[",
"$",
"field",
"]",
"=",
"$",
"bool",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set a rule that a field value must be an array and all array items will be validated individual
@param boolean|null $bool
@return sFire\Validator | [
"Set",
"a",
"rule",
"that",
"a",
"field",
"value",
"must",
"be",
"an",
"array",
"and",
"all",
"array",
"items",
"will",
"be",
"validated",
"individual"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L104-L119 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.combine | public function combine() {
$fieldnames = func_get_args();
$values = [];
foreach($fieldnames as $fieldname) {
if(false === is_string($fieldname)) {
return trigger_error(sprintf('All fieldnames used in "%s"() must be of the type string, "%s" given', __METHOD__, gettype($fieldname)), E_USER_ERROR);
}
$values[] = $this -> getValue($fieldname, $this -> getPrefix());
}
$combine = new Combine();
$combine -> setValues($values);
$combine -> setFieldnames($fieldnames);
$this -> combine[] = $combine;
return $combine;
} | php | public function combine() {
$fieldnames = func_get_args();
$values = [];
foreach($fieldnames as $fieldname) {
if(false === is_string($fieldname)) {
return trigger_error(sprintf('All fieldnames used in "%s"() must be of the type string, "%s" given', __METHOD__, gettype($fieldname)), E_USER_ERROR);
}
$values[] = $this -> getValue($fieldname, $this -> getPrefix());
}
$combine = new Combine();
$combine -> setValues($values);
$combine -> setFieldnames($fieldnames);
$this -> combine[] = $combine;
return $combine;
} | [
"public",
"function",
"combine",
"(",
")",
"{",
"$",
"fieldnames",
"=",
"func_get_args",
"(",
")",
";",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldnames",
"as",
"$",
"fieldname",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"fieldname",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'All fieldnames used in \"%s\"() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"fieldname",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"fieldname",
",",
"$",
"this",
"->",
"getPrefix",
"(",
")",
")",
";",
"}",
"$",
"combine",
"=",
"new",
"Combine",
"(",
")",
";",
"$",
"combine",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"$",
"combine",
"->",
"setFieldnames",
"(",
"$",
"fieldnames",
")",
";",
"$",
"this",
"->",
"combine",
"[",
"]",
"=",
"$",
"combine",
";",
"return",
"$",
"combine",
";",
"}"
] | Combines multiple fields to be as one for validation
@return sFire\Validator\Combine | [
"Combines",
"multiple",
"fields",
"to",
"be",
"as",
"one",
"for",
"validation"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L126-L147 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.token | public function token() {
$session = new Session();
$name = $this -> getValue('_token-name');
$value = $this -> getValue('_token-value');
if((null !== $name && null !== $value && $session -> pull(['_token', $name]) !== $value) || null === $name || null === $value) {
$instance = $this -> getMessageInstance();
$instance :: setFieldnames(['_token']);
$instance :: setError(null, '_token', 'Token mismatch');
$this -> setPasses(false);
}
} | php | public function token() {
$session = new Session();
$name = $this -> getValue('_token-name');
$value = $this -> getValue('_token-value');
if((null !== $name && null !== $value && $session -> pull(['_token', $name]) !== $value) || null === $name || null === $value) {
$instance = $this -> getMessageInstance();
$instance :: setFieldnames(['_token']);
$instance :: setError(null, '_token', 'Token mismatch');
$this -> setPasses(false);
}
} | [
"public",
"function",
"token",
"(",
")",
"{",
"$",
"session",
"=",
"new",
"Session",
"(",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"getValue",
"(",
"'_token-name'",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"'_token-value'",
")",
";",
"if",
"(",
"(",
"null",
"!==",
"$",
"name",
"&&",
"null",
"!==",
"$",
"value",
"&&",
"$",
"session",
"->",
"pull",
"(",
"[",
"'_token'",
",",
"$",
"name",
"]",
")",
"!==",
"$",
"value",
")",
"||",
"null",
"===",
"$",
"name",
"||",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getMessageInstance",
"(",
")",
";",
"$",
"instance",
"::",
"setFieldnames",
"(",
"[",
"'_token'",
"]",
")",
";",
"$",
"instance",
"::",
"setError",
"(",
"null",
",",
"'_token'",
",",
"'Token mismatch'",
")",
";",
"$",
"this",
"->",
"setPasses",
"(",
"false",
")",
";",
"}",
"}"
] | Validates token from input
@return array | [
"Validates",
"token",
"from",
"input"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L154-L168 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.getMessageInstance | private function getMessageInstance() {
if(null === $this -> messageInstance) {
$this -> messageInstance = Message :: Instance();
}
return $this -> messageInstance;
} | php | private function getMessageInstance() {
if(null === $this -> messageInstance) {
$this -> messageInstance = Message :: Instance();
}
return $this -> messageInstance;
} | [
"private",
"function",
"getMessageInstance",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"messageInstance",
")",
"{",
"$",
"this",
"->",
"messageInstance",
"=",
"Message",
"::",
"Instance",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"messageInstance",
";",
"}"
] | Returns the instance for custom messsages
@return \sFire\Validator\Message | [
"Returns",
"the",
"instance",
"for",
"custom",
"messsages"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L175-L182 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.isRequired | private function isRequired($field, $value) {
if(true === isset($this -> required[$field])) {
$empty = true;
if(true === is_array($value)) {
foreach($value as $val) {
if(strlen(trim($val)) > 0) {
$empty = false;
}
}
}
if(true === is_string($value) && strlen(trim($value)) > 0) {
$empty = false;
}
if(false === $this -> required[$field] && $empty) {
return true;
}
}
return false;
} | php | private function isRequired($field, $value) {
if(true === isset($this -> required[$field])) {
$empty = true;
if(true === is_array($value)) {
foreach($value as $val) {
if(strlen(trim($val)) > 0) {
$empty = false;
}
}
}
if(true === is_string($value) && strlen(trim($value)) > 0) {
$empty = false;
}
if(false === $this -> required[$field] && $empty) {
return true;
}
}
return false;
} | [
"private",
"function",
"isRequired",
"(",
"$",
"field",
",",
"$",
"value",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"this",
"->",
"required",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"empty",
"=",
"true",
";",
"if",
"(",
"true",
"===",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"val",
")",
")",
">",
"0",
")",
"{",
"$",
"empty",
"=",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"true",
"===",
"is_string",
"(",
"$",
"value",
")",
"&&",
"strlen",
"(",
"trim",
"(",
"$",
"value",
")",
")",
">",
"0",
")",
"{",
"$",
"empty",
"=",
"false",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"required",
"[",
"$",
"field",
"]",
"&&",
"$",
"empty",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Evaluates if field value is required or not
@param $field string
@param $value string
@return boolean | [
"Evaluates",
"if",
"field",
"value",
"is",
"required",
"or",
"not"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L266-L292 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.isValidateArray | private function isValidateArray($field) {
if(true === isset($this -> validateAsArray[$field])) {
return $this -> validateAsArray[$field];
}
return false;
} | php | private function isValidateArray($field) {
if(true === isset($this -> validateAsArray[$field])) {
return $this -> validateAsArray[$field];
}
return false;
} | [
"private",
"function",
"isValidateArray",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"this",
"->",
"validateAsArray",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validateAsArray",
"[",
"$",
"field",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | Evaluates if field value should be validated as an array
@param $field string
@return boolean | [
"Evaluates",
"if",
"field",
"value",
"should",
"be",
"validated",
"as",
"an",
"array"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L300-L307 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.getRuleClass | private function getRuleClass($rule) {
if(false === is_string($rule)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($rule)), E_USER_ERROR);
}
if(true === isset($this -> custom[$rule])) {
return $this -> custom[$rule];
}
return __NAMESPACE__ . self :: NAMESPACE_RULES . ucfirst(strtolower($rule));
} | php | private function getRuleClass($rule) {
if(false === is_string($rule)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($rule)), E_USER_ERROR);
}
if(true === isset($this -> custom[$rule])) {
return $this -> custom[$rule];
}
return __NAMESPACE__ . self :: NAMESPACE_RULES . ucfirst(strtolower($rule));
} | [
"private",
"function",
"getRuleClass",
"(",
"$",
"rule",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"rule",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"rule",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"this",
"->",
"custom",
"[",
"$",
"rule",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"custom",
"[",
"$",
"rule",
"]",
";",
"}",
"return",
"__NAMESPACE__",
".",
"self",
"::",
"NAMESPACE_RULES",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"rule",
")",
")",
";",
"}"
] | Returns the class of the rule
@param string $rule
@return string | [
"Returns",
"the",
"class",
"of",
"the",
"rule"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L315-L326 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.setErrorMessage | private function setErrorMessage($rule, $class) {
$instance = $this -> getMessageInstance();
$message = $instance :: getMessage($rule -> field, $rule -> rule);
$message = null !== $message ? $message : $class -> getMessage();
$message = Translation :: translate($message, $rule -> parameters);
$message = vsprintf($message, $rule -> parameters);
$instance :: setFieldnames([$rule -> field]);
$instance :: setError($rule -> prefix, $rule -> field, $message);
call_user_func_array([$instance, $rule -> rule], [$message]);
} | php | private function setErrorMessage($rule, $class) {
$instance = $this -> getMessageInstance();
$message = $instance :: getMessage($rule -> field, $rule -> rule);
$message = null !== $message ? $message : $class -> getMessage();
$message = Translation :: translate($message, $rule -> parameters);
$message = vsprintf($message, $rule -> parameters);
$instance :: setFieldnames([$rule -> field]);
$instance :: setError($rule -> prefix, $rule -> field, $message);
call_user_func_array([$instance, $rule -> rule], [$message]);
} | [
"private",
"function",
"setErrorMessage",
"(",
"$",
"rule",
",",
"$",
"class",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getMessageInstance",
"(",
")",
";",
"$",
"message",
"=",
"$",
"instance",
"::",
"getMessage",
"(",
"$",
"rule",
"->",
"field",
",",
"$",
"rule",
"->",
"rule",
")",
";",
"$",
"message",
"=",
"null",
"!==",
"$",
"message",
"?",
"$",
"message",
":",
"$",
"class",
"->",
"getMessage",
"(",
")",
";",
"$",
"message",
"=",
"Translation",
"::",
"translate",
"(",
"$",
"message",
",",
"$",
"rule",
"->",
"parameters",
")",
";",
"$",
"message",
"=",
"vsprintf",
"(",
"$",
"message",
",",
"$",
"rule",
"->",
"parameters",
")",
";",
"$",
"instance",
"::",
"setFieldnames",
"(",
"[",
"$",
"rule",
"->",
"field",
"]",
")",
";",
"$",
"instance",
"::",
"setError",
"(",
"$",
"rule",
"->",
"prefix",
",",
"$",
"rule",
"->",
"field",
",",
"$",
"message",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"instance",
",",
"$",
"rule",
"->",
"rule",
"]",
",",
"[",
"$",
"message",
"]",
")",
";",
"}"
] | Set the error message for particular rule
@param string $rule
@param object $class | [
"Set",
"the",
"error",
"message",
"for",
"particular",
"rule"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L334-L347 | train |
Kris-Kuiper/sFire-Framework | src/Validator/Form/Validator.php | Validator.getValue | private function getValue($field, $prefix = null) {
foreach($this -> combine as $combine) {
if($combine -> getName() === $field) {
return $combine -> combine();
}
}
//Prefix
if(null !== $prefix) {
$field = $prefix . '[' . $field . ']';
}
//Get the value
$helper = new StringToArray();
$data = $helper -> execute($field, null, $this -> getData());
return $data;
} | php | private function getValue($field, $prefix = null) {
foreach($this -> combine as $combine) {
if($combine -> getName() === $field) {
return $combine -> combine();
}
}
//Prefix
if(null !== $prefix) {
$field = $prefix . '[' . $field . ']';
}
//Get the value
$helper = new StringToArray();
$data = $helper -> execute($field, null, $this -> getData());
return $data;
} | [
"private",
"function",
"getValue",
"(",
"$",
"field",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"combine",
"as",
"$",
"combine",
")",
"{",
"if",
"(",
"$",
"combine",
"->",
"getName",
"(",
")",
"===",
"$",
"field",
")",
"{",
"return",
"$",
"combine",
"->",
"combine",
"(",
")",
";",
"}",
"}",
"//Prefix\r",
"if",
"(",
"null",
"!==",
"$",
"prefix",
")",
"{",
"$",
"field",
"=",
"$",
"prefix",
".",
"'['",
".",
"$",
"field",
".",
"']'",
";",
"}",
"//Get the value\r",
"$",
"helper",
"=",
"new",
"StringToArray",
"(",
")",
";",
"$",
"data",
"=",
"$",
"helper",
"->",
"execute",
"(",
"$",
"field",
",",
"null",
",",
"$",
"this",
"->",
"getData",
"(",
")",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Returns the value for a given field
@param string $field
@param string $prefix
@return mixed | [
"Returns",
"the",
"value",
"for",
"a",
"given",
"field"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Validator.php#L370-L389 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.resetParts | public function resetParts(array $partNames = array())
{
if (empty($partNames)) {
$partNames = array_keys($this->parts);
}
foreach ($partNames as $partName) {
$this->resetPart($partName);
}
return $this;
} | php | public function resetParts(array $partNames = array())
{
if (empty($partNames)) {
$partNames = array_keys($this->parts);
}
foreach ($partNames as $partName) {
$this->resetPart($partName);
}
return $this;
} | [
"public",
"function",
"resetParts",
"(",
"array",
"$",
"partNames",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"partNames",
")",
")",
"{",
"$",
"partNames",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"parts",
")",
";",
"}",
"foreach",
"(",
"$",
"partNames",
"as",
"$",
"partName",
")",
"{",
"$",
"this",
"->",
"resetPart",
"(",
"$",
"partName",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Resets query parts.
@param array $partNames The query part names to reset.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Resets",
"query",
"parts",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L169-L180 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.resetPart | public function resetPart($partName)
{
$this->parts[$partName] = is_array($this->parts[$partName]) ? array() : null;
return $this;
} | php | public function resetPart($partName)
{
$this->parts[$partName] = is_array($this->parts[$partName]) ? array() : null;
return $this;
} | [
"public",
"function",
"resetPart",
"(",
"$",
"partName",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"$",
"partName",
"]",
"=",
"is_array",
"(",
"$",
"this",
"->",
"parts",
"[",
"$",
"partName",
"]",
")",
"?",
"array",
"(",
")",
":",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Resets a query part.
@param string $partName The query part name to reset.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Resets",
"a",
"query",
"part",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L189-L194 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.select | public function select($selects = array())
{
$this->type = self::SELECT;
if (!empty($selects)) {
$this->parts['select'] = array_merge($this->parts['select'], (array) $selects);
}
return $this;
} | php | public function select($selects = array())
{
$this->type = self::SELECT;
if (!empty($selects)) {
$this->parts['select'] = array_merge($this->parts['select'], (array) $selects);
}
return $this;
} | [
"public",
"function",
"select",
"(",
"$",
"selects",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"SELECT",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"selects",
")",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"'select'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"parts",
"[",
"'select'",
"]",
",",
"(",
"array",
")",
"$",
"selects",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the select query mode.
@param string|array $selects The fields to select.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Sets",
"the",
"select",
"query",
"mode",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L203-L212 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.insert | public function insert($insert)
{
$this->type = self::INSERT;
$this->from($insert);
return $this;
} | php | public function insert($insert)
{
$this->type = self::INSERT;
$this->from($insert);
return $this;
} | [
"public",
"function",
"insert",
"(",
"$",
"insert",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"INSERT",
";",
"$",
"this",
"->",
"from",
"(",
"$",
"insert",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the insert query mode for a specific table.
@param string $insert The table name.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Sets",
"the",
"insert",
"query",
"mode",
"for",
"a",
"specific",
"table",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L221-L228 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.update | public function update($update, $alias = null)
{
$this->type = self::UPDATE;
$this->from($update, $alias);
return $this;
} | php | public function update($update, $alias = null)
{
$this->type = self::UPDATE;
$this->from($update, $alias);
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"update",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"UPDATE",
";",
"$",
"this",
"->",
"from",
"(",
"$",
"update",
",",
"$",
"alias",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the update query mode for a specific table.
@param string $update The table name.
@param string $alias The table alias.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Sets",
"the",
"update",
"query",
"mode",
"for",
"a",
"specific",
"table",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L238-L245 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.delete | public function delete($delete, $alias = null)
{
$this->type = self::DELETE;
$this->from($delete, $alias);
return $this;
} | php | public function delete($delete, $alias = null)
{
$this->type = self::DELETE;
$this->from($delete, $alias);
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"delete",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"DELETE",
";",
"$",
"this",
"->",
"from",
"(",
"$",
"delete",
",",
"$",
"alias",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the delete query mode for a specific table.
@param string $delete The table name.
@param string $alias The table alias.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Sets",
"the",
"delete",
"query",
"mode",
"for",
"a",
"specific",
"table",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L255-L262 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.innerJoin | public function innerJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->join($fromAlias, 'inner', $join, $alias, $condition);
} | php | public function innerJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->join($fromAlias, 'inner', $join, $alias, $condition);
} | [
"public",
"function",
"innerJoin",
"(",
"$",
"fromAlias",
",",
"$",
"join",
",",
"$",
"alias",
",",
"$",
"condition",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"fromAlias",
",",
"'inner'",
",",
"$",
"join",
",",
"$",
"alias",
",",
"$",
"condition",
")",
";",
"}"
] | Adds an "INNER JOIN" clause to the query.
@param string $fromAlias The from table alias.
@param string $join The join table name.
@param string $alias The join table alias.
@param string $condition The join condition.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Adds",
"an",
"INNER",
"JOIN",
"clause",
"to",
"the",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L292-L295 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.rightJoin | public function rightJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->join($fromAlias, 'right', $join, $alias, $condition);
} | php | public function rightJoin($fromAlias, $join, $alias, $condition = null)
{
return $this->join($fromAlias, 'right', $join, $alias, $condition);
} | [
"public",
"function",
"rightJoin",
"(",
"$",
"fromAlias",
",",
"$",
"join",
",",
"$",
"alias",
",",
"$",
"condition",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"fromAlias",
",",
"'right'",
",",
"$",
"join",
",",
"$",
"alias",
",",
"$",
"condition",
")",
";",
"}"
] | Adds a "RIGHT JOIN" clause to the query.
@param string $fromAlias The from table alias.
@param string $join The join table name.
@param string $alias The join table alias.
@param string $condition The join condition.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Adds",
"a",
"RIGHT",
"JOIN",
"clause",
"to",
"the",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L322-L325 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.where | public function where($expression, $type = Expression\Expression::TYPE_AND)
{
return $this->addExpression('where', $type, $expression);
} | php | public function where($expression, $type = Expression\Expression::TYPE_AND)
{
return $this->addExpression('where', $type, $expression);
} | [
"public",
"function",
"where",
"(",
"$",
"expression",
",",
"$",
"type",
"=",
"Expression",
"\\",
"Expression",
"::",
"TYPE_AND",
")",
"{",
"return",
"$",
"this",
"->",
"addExpression",
"(",
"'where'",
",",
"$",
"type",
",",
"$",
"expression",
")",
";",
"}"
] | Adds a "WHERE" clause to the query.
@param string|array|\Fridge\DBAL\Query\Expression\Expression $expression The expression.
@param string $type The expression type (AND, OR).
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Adds",
"a",
"WHERE",
"clause",
"to",
"the",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L377-L380 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.having | public function having($expression, $type = Expression\Expression::TYPE_AND)
{
return $this->addExpression('having', $type, $expression);
} | php | public function having($expression, $type = Expression\Expression::TYPE_AND)
{
return $this->addExpression('having', $type, $expression);
} | [
"public",
"function",
"having",
"(",
"$",
"expression",
",",
"$",
"type",
"=",
"Expression",
"\\",
"Expression",
"::",
"TYPE_AND",
")",
"{",
"return",
"$",
"this",
"->",
"addExpression",
"(",
"'having'",
",",
"$",
"type",
",",
"$",
"expression",
")",
";",
"}"
] | Adds an "HAVING" clause to the query.
@param string|array|\Fridge\DBAL\Query\Expression\Expression $expression The expression.
@param string $type The expression type (AND, OR).
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Adds",
"an",
"HAVING",
"clause",
"to",
"the",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L428-L431 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.setParameters | public function setParameters(array $parameters, array $types = array())
{
foreach ($parameters as $parameter => $value) {
if (isset($types[$parameter])) {
$this->setParameter($parameter, $value, $types[$parameter]);
} else {
$this->setParameter($parameter, $value);
}
}
return $this;
} | php | public function setParameters(array $parameters, array $types = array())
{
foreach ($parameters as $parameter => $value) {
if (isset($types[$parameter])) {
$this->setParameter($parameter, $value, $types[$parameter]);
} else {
$this->setParameter($parameter, $value);
}
}
return $this;
} | [
"public",
"function",
"setParameters",
"(",
"array",
"$",
"parameters",
",",
"array",
"$",
"types",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"types",
"[",
"$",
"parameter",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"parameter",
",",
"$",
"value",
",",
"$",
"types",
"[",
"$",
"parameter",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"parameter",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets query parameters.
@param array $parameters The query parameters.
@param array $types The query parameter types.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Sets",
"query",
"parameters",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L507-L518 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.createParameter | public function createParameter($value, $type = null)
{
if ($this->mode === self::MODE_POSITIONAL) {
return $this->createPositionalParameter($value, $type);
}
return $this->createNamedParameter($value, $type);
} | php | public function createParameter($value, $type = null)
{
if ($this->mode === self::MODE_POSITIONAL) {
return $this->createPositionalParameter($value, $type);
}
return $this->createNamedParameter($value, $type);
} | [
"public",
"function",
"createParameter",
"(",
"$",
"value",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"self",
"::",
"MODE_POSITIONAL",
")",
"{",
"return",
"$",
"this",
"->",
"createPositionalParameter",
"(",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createNamedParameter",
"(",
"$",
"value",
",",
"$",
"type",
")",
";",
"}"
] | Creates and sets a parameter.
@param mixed $value The value.
@param mixed $type The type.
@return string The parameter placeholder. | [
"Creates",
"and",
"sets",
"a",
"parameter",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L555-L562 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.createPositionalParameter | public function createPositionalParameter($value, $type = null)
{
$this->setParameter($this->parameterCounters['positional'], $value, $type);
return '?';
} | php | public function createPositionalParameter($value, $type = null)
{
$this->setParameter($this->parameterCounters['positional'], $value, $type);
return '?';
} | [
"public",
"function",
"createPositionalParameter",
"(",
"$",
"value",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"this",
"->",
"parameterCounters",
"[",
"'positional'",
"]",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"return",
"'?'",
";",
"}"
] | Creates and sets a positional parameter.
@param mixed $value The value.
@param mixed $type The type.
@return string The positional parameter placeholder. | [
"Creates",
"and",
"sets",
"a",
"positional",
"parameter",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L572-L577 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.createNamedParameter | public function createNamedParameter($value, $type = null, $placeholder = null)
{
if ($placeholder === null) {
$placeholder = ':fridge';
}
$parameter = substr($placeholder, 1);
if (!isset($this->parameterCounters['named'][$parameter])) {
$this->parameterCounters['named'][$parameter] = 0;
}
$placeholder = $placeholder.$this->parameterCounters['named'][$parameter];
$this->setParameter($parameter.$this->parameterCounters['named'][$parameter], $value, $type);
$this->parameterCounters['named'][$parameter]++;
return $placeholder;
} | php | public function createNamedParameter($value, $type = null, $placeholder = null)
{
if ($placeholder === null) {
$placeholder = ':fridge';
}
$parameter = substr($placeholder, 1);
if (!isset($this->parameterCounters['named'][$parameter])) {
$this->parameterCounters['named'][$parameter] = 0;
}
$placeholder = $placeholder.$this->parameterCounters['named'][$parameter];
$this->setParameter($parameter.$this->parameterCounters['named'][$parameter], $value, $type);
$this->parameterCounters['named'][$parameter]++;
return $placeholder;
} | [
"public",
"function",
"createNamedParameter",
"(",
"$",
"value",
",",
"$",
"type",
"=",
"null",
",",
"$",
"placeholder",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"placeholder",
"===",
"null",
")",
"{",
"$",
"placeholder",
"=",
"':fridge'",
";",
"}",
"$",
"parameter",
"=",
"substr",
"(",
"$",
"placeholder",
",",
"1",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameterCounters",
"[",
"'named'",
"]",
"[",
"$",
"parameter",
"]",
")",
")",
"{",
"$",
"this",
"->",
"parameterCounters",
"[",
"'named'",
"]",
"[",
"$",
"parameter",
"]",
"=",
"0",
";",
"}",
"$",
"placeholder",
"=",
"$",
"placeholder",
".",
"$",
"this",
"->",
"parameterCounters",
"[",
"'named'",
"]",
"[",
"$",
"parameter",
"]",
";",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"parameter",
".",
"$",
"this",
"->",
"parameterCounters",
"[",
"'named'",
"]",
"[",
"$",
"parameter",
"]",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"parameterCounters",
"[",
"'named'",
"]",
"[",
"$",
"parameter",
"]",
"++",
";",
"return",
"$",
"placeholder",
";",
"}"
] | Creates and sets a named parameter.
@param mixed $value The value.
@param mixed $type The type
@param string $placeholder The placeholder.
@return string The named parameter placeholder. | [
"Creates",
"and",
"sets",
"a",
"named",
"parameter",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L588-L606 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getParameterType | public function getParameterType($identifier)
{
return isset($this->parameterTypes[$identifier]) ? $this->parameterTypes[$identifier] : null;
} | php | public function getParameterType($identifier)
{
return isset($this->parameterTypes[$identifier]) ? $this->parameterTypes[$identifier] : null;
} | [
"public",
"function",
"getParameterType",
"(",
"$",
"identifier",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"parameterTypes",
"[",
"$",
"identifier",
"]",
")",
"?",
"$",
"this",
"->",
"parameterTypes",
"[",
"$",
"identifier",
"]",
":",
"null",
";",
"}"
] | Gets a query parameter type.
@param string $identifier The identifier.
@return mixed The query parameter type. | [
"Gets",
"a",
"query",
"parameter",
"type",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L647-L650 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getQuery | public function getQuery()
{
$query = null;
switch ($this->type) {
case self::SELECT:
$query = $this->getSelectQuery();
break;
case self::INSERT:
$query = $this->getInsertQuery();
break;
case self::UPDATE:
$query = $this->getUpdateQuery();
break;
case self::DELETE:
$query = $this->getDeleteQuery();
break;
}
return $query;
} | php | public function getQuery()
{
$query = null;
switch ($this->type) {
case self::SELECT:
$query = $this->getSelectQuery();
break;
case self::INSERT:
$query = $this->getInsertQuery();
break;
case self::UPDATE:
$query = $this->getUpdateQuery();
break;
case self::DELETE:
$query = $this->getDeleteQuery();
break;
}
return $query;
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"query",
"=",
"null",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"SELECT",
":",
"$",
"query",
"=",
"$",
"this",
"->",
"getSelectQuery",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"INSERT",
":",
"$",
"query",
"=",
"$",
"this",
"->",
"getInsertQuery",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"UPDATE",
":",
"$",
"query",
"=",
"$",
"this",
"->",
"getUpdateQuery",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"DELETE",
":",
"$",
"query",
"=",
"$",
"this",
"->",
"getDeleteQuery",
"(",
")",
";",
"break",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Gets the generated query.
@return string The generated query. | [
"Gets",
"the",
"generated",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L657-L677 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.addExpression | private function addExpression($part, $type, $expression)
{
if (!($expression instanceof Expression\Expression)) {
$expression = new Expression\Expression($type, (array) $expression);
}
if ($this->parts[$part] === null) {
$this->parts[$part] = $expression;
return $this;
}
if ($this->parts[$part]->getType() !== $type) {
$this->parts[$part] = new Expression\Expression($type, array($this->parts[$part]));
}
foreach ($expression->getParts() as $expressionPart) {
$this->parts[$part]->addPart($expressionPart);
}
return $this;
} | php | private function addExpression($part, $type, $expression)
{
if (!($expression instanceof Expression\Expression)) {
$expression = new Expression\Expression($type, (array) $expression);
}
if ($this->parts[$part] === null) {
$this->parts[$part] = $expression;
return $this;
}
if ($this->parts[$part]->getType() !== $type) {
$this->parts[$part] = new Expression\Expression($type, array($this->parts[$part]));
}
foreach ($expression->getParts() as $expressionPart) {
$this->parts[$part]->addPart($expressionPart);
}
return $this;
} | [
"private",
"function",
"addExpression",
"(",
"$",
"part",
",",
"$",
"type",
",",
"$",
"expression",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"expression",
"instanceof",
"Expression",
"\\",
"Expression",
")",
")",
"{",
"$",
"expression",
"=",
"new",
"Expression",
"\\",
"Expression",
"(",
"$",
"type",
",",
"(",
"array",
")",
"$",
"expression",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
"=",
"$",
"expression",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
"->",
"getType",
"(",
")",
"!==",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
"=",
"new",
"Expression",
"\\",
"Expression",
"(",
"$",
"type",
",",
"array",
"(",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"expression",
"->",
"getParts",
"(",
")",
"as",
"$",
"expressionPart",
")",
"{",
"$",
"this",
"->",
"parts",
"[",
"$",
"part",
"]",
"->",
"addPart",
"(",
"$",
"expressionPart",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds an expression to the "WHERE" or "HAVING" clause.
@param string $part The query part.
@param string $type The expression type (AND, OR)
@param string|array|\Fridge\DBAL\Query\Expression\Expression $expression The expression.
@return \Fridge\DBAL\Query\QueryBuilder The query builder. | [
"Adds",
"an",
"expression",
"to",
"the",
"WHERE",
"or",
"HAVING",
"clause",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L702-L723 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getSelectQuery | private function getSelectQuery()
{
return 'SELECT '.(empty($this->parts['select']) ? '*' : implode(', ', $this->parts['select'])).
' FROM '.$this->getFromClause().
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null).
(!empty($this->parts['group_by']) ? ' GROUP BY '.implode(', ', $this->parts['group_by']) : null).
(($this->parts['having'] !== null) ? ' HAVING '.$this->parts['having'] : null).
(!empty($this->parts['order_by']) ? ' ORDER BY '.implode(', ', $this->parts['order_by']) : null).
(($this->parts['limit'] !== null) ? ' LIMIT '.$this->parts['limit'] : null).
(($this->parts['offset'] !== null) ? ' OFFSET '.$this->parts['offset'] : null);
} | php | private function getSelectQuery()
{
return 'SELECT '.(empty($this->parts['select']) ? '*' : implode(', ', $this->parts['select'])).
' FROM '.$this->getFromClause().
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null).
(!empty($this->parts['group_by']) ? ' GROUP BY '.implode(', ', $this->parts['group_by']) : null).
(($this->parts['having'] !== null) ? ' HAVING '.$this->parts['having'] : null).
(!empty($this->parts['order_by']) ? ' ORDER BY '.implode(', ', $this->parts['order_by']) : null).
(($this->parts['limit'] !== null) ? ' LIMIT '.$this->parts['limit'] : null).
(($this->parts['offset'] !== null) ? ' OFFSET '.$this->parts['offset'] : null);
} | [
"private",
"function",
"getSelectQuery",
"(",
")",
"{",
"return",
"'SELECT '",
".",
"(",
"empty",
"(",
"$",
"this",
"->",
"parts",
"[",
"'select'",
"]",
")",
"?",
"'*'",
":",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"parts",
"[",
"'select'",
"]",
")",
")",
".",
"' FROM '",
".",
"$",
"this",
"->",
"getFromClause",
"(",
")",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
"!==",
"null",
")",
"?",
"' WHERE '",
".",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
":",
"null",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parts",
"[",
"'group_by'",
"]",
")",
"?",
"' GROUP BY '",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"parts",
"[",
"'group_by'",
"]",
")",
":",
"null",
")",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'having'",
"]",
"!==",
"null",
")",
"?",
"' HAVING '",
".",
"$",
"this",
"->",
"parts",
"[",
"'having'",
"]",
":",
"null",
")",
".",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parts",
"[",
"'order_by'",
"]",
")",
"?",
"' ORDER BY '",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"parts",
"[",
"'order_by'",
"]",
")",
":",
"null",
")",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'limit'",
"]",
"!==",
"null",
")",
"?",
"' LIMIT '",
".",
"$",
"this",
"->",
"parts",
"[",
"'limit'",
"]",
":",
"null",
")",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'offset'",
"]",
"!==",
"null",
")",
"?",
"' OFFSET '",
".",
"$",
"this",
"->",
"parts",
"[",
"'offset'",
"]",
":",
"null",
")",
";",
"}"
] | Generates a "SELECT" query
@return string The "SELECT" query. | [
"Generates",
"a",
"SELECT",
"query"
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L730-L740 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getInsertQuery | private function getInsertQuery()
{
return 'INSERT INTO '.$this->parts['from'][0]['table'].
' ('.implode(', ', array_keys($this->parts['set'])).')'.
' VALUES'.
' ('.implode(', ', $this->parts['set']).')';
} | php | private function getInsertQuery()
{
return 'INSERT INTO '.$this->parts['from'][0]['table'].
' ('.implode(', ', array_keys($this->parts['set'])).')'.
' VALUES'.
' ('.implode(', ', $this->parts['set']).')';
} | [
"private",
"function",
"getInsertQuery",
"(",
")",
"{",
"return",
"'INSERT INTO '",
".",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'table'",
"]",
".",
"' ('",
".",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"this",
"->",
"parts",
"[",
"'set'",
"]",
")",
")",
".",
"')'",
".",
"' VALUES'",
".",
"' ('",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"parts",
"[",
"'set'",
"]",
")",
".",
"')'",
";",
"}"
] | Generates an "INSERT" query.
@return string The "INSERT" query. | [
"Generates",
"an",
"INSERT",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L747-L753 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getUpdateQuery | private function getUpdateQuery()
{
if (isset($this->parts['from'][0]['alias'])) {
$fromClause = $this->parts['from'][0]['alias'].' FROM '.$this->getFromClause();
} else {
$fromClause = $this->parts['from'][0]['table'];
}
$setClause = array();
foreach ($this->parts['set'] as $idenfier => $value) {
$setClause[] = $this->getExpressionBuilder()->equal($idenfier, $value);
}
return 'UPDATE '.$fromClause.
' SET '.implode(', ', $setClause).
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
} | php | private function getUpdateQuery()
{
if (isset($this->parts['from'][0]['alias'])) {
$fromClause = $this->parts['from'][0]['alias'].' FROM '.$this->getFromClause();
} else {
$fromClause = $this->parts['from'][0]['table'];
}
$setClause = array();
foreach ($this->parts['set'] as $idenfier => $value) {
$setClause[] = $this->getExpressionBuilder()->equal($idenfier, $value);
}
return 'UPDATE '.$fromClause.
' SET '.implode(', ', $setClause).
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
} | [
"private",
"function",
"getUpdateQuery",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'alias'",
"]",
")",
")",
"{",
"$",
"fromClause",
"=",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'alias'",
"]",
".",
"' FROM '",
".",
"$",
"this",
"->",
"getFromClause",
"(",
")",
";",
"}",
"else",
"{",
"$",
"fromClause",
"=",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'table'",
"]",
";",
"}",
"$",
"setClause",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"[",
"'set'",
"]",
"as",
"$",
"idenfier",
"=>",
"$",
"value",
")",
"{",
"$",
"setClause",
"[",
"]",
"=",
"$",
"this",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"equal",
"(",
"$",
"idenfier",
",",
"$",
"value",
")",
";",
"}",
"return",
"'UPDATE '",
".",
"$",
"fromClause",
".",
"' SET '",
".",
"implode",
"(",
"', '",
",",
"$",
"setClause",
")",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
"!==",
"null",
")",
"?",
"' WHERE '",
".",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
":",
"null",
")",
";",
"}"
] | Generates an "UPDATE" query.
@return string The "UPDATE" query. | [
"Generates",
"an",
"UPDATE",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L760-L777 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getDeleteQuery | private function getDeleteQuery()
{
$fromClause = null;
if (isset($this->parts['from'][0]['alias'])) {
$fromClause = $this->parts['from'][0]['alias'].' ';
}
$fromClause .= 'FROM '.$this->getFromClause();
return 'DELETE '.$fromClause.
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
} | php | private function getDeleteQuery()
{
$fromClause = null;
if (isset($this->parts['from'][0]['alias'])) {
$fromClause = $this->parts['from'][0]['alias'].' ';
}
$fromClause .= 'FROM '.$this->getFromClause();
return 'DELETE '.$fromClause.
(($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
} | [
"private",
"function",
"getDeleteQuery",
"(",
")",
"{",
"$",
"fromClause",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'alias'",
"]",
")",
")",
"{",
"$",
"fromClause",
"=",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"[",
"0",
"]",
"[",
"'alias'",
"]",
".",
"' '",
";",
"}",
"$",
"fromClause",
".=",
"'FROM '",
".",
"$",
"this",
"->",
"getFromClause",
"(",
")",
";",
"return",
"'DELETE '",
".",
"$",
"fromClause",
".",
"(",
"(",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
"!==",
"null",
")",
"?",
"' WHERE '",
".",
"$",
"this",
"->",
"parts",
"[",
"'where'",
"]",
":",
"null",
")",
";",
"}"
] | Generates a "DELETE" query.
@return string The "DELETE" query. | [
"Generates",
"a",
"DELETE",
"query",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L784-L796 | train |
fridge-project/dbal | src/Fridge/DBAL/Query/QueryBuilder.php | QueryBuilder.getFromClause | private function getFromClause()
{
$fromClauses = array();
foreach ($this->parts['from'] as $from) {
$fromClause = $from['table'];
if ($from['alias'] !== null) {
$fromClause .= ' '.$from['alias'];
}
if (isset($this->parts['join'][$from['alias']])) {
foreach ($this->parts['join'][$from['alias']] as $join) {
$fromClause .= ' '.strtoupper($join['type']).
' JOIN '.$join['table'].' '.$join['alias'].
' ON '.$join['expression'];
}
}
$fromClauses[] = $fromClause;
}
return implode(', ', $fromClauses);
} | php | private function getFromClause()
{
$fromClauses = array();
foreach ($this->parts['from'] as $from) {
$fromClause = $from['table'];
if ($from['alias'] !== null) {
$fromClause .= ' '.$from['alias'];
}
if (isset($this->parts['join'][$from['alias']])) {
foreach ($this->parts['join'][$from['alias']] as $join) {
$fromClause .= ' '.strtoupper($join['type']).
' JOIN '.$join['table'].' '.$join['alias'].
' ON '.$join['expression'];
}
}
$fromClauses[] = $fromClause;
}
return implode(', ', $fromClauses);
} | [
"private",
"function",
"getFromClause",
"(",
")",
"{",
"$",
"fromClauses",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"[",
"'from'",
"]",
"as",
"$",
"from",
")",
"{",
"$",
"fromClause",
"=",
"$",
"from",
"[",
"'table'",
"]",
";",
"if",
"(",
"$",
"from",
"[",
"'alias'",
"]",
"!==",
"null",
")",
"{",
"$",
"fromClause",
".=",
"' '",
".",
"$",
"from",
"[",
"'alias'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parts",
"[",
"'join'",
"]",
"[",
"$",
"from",
"[",
"'alias'",
"]",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"[",
"'join'",
"]",
"[",
"$",
"from",
"[",
"'alias'",
"]",
"]",
"as",
"$",
"join",
")",
"{",
"$",
"fromClause",
".=",
"' '",
".",
"strtoupper",
"(",
"$",
"join",
"[",
"'type'",
"]",
")",
".",
"' JOIN '",
".",
"$",
"join",
"[",
"'table'",
"]",
".",
"' '",
".",
"$",
"join",
"[",
"'alias'",
"]",
".",
"' ON '",
".",
"$",
"join",
"[",
"'expression'",
"]",
";",
"}",
"}",
"$",
"fromClauses",
"[",
"]",
"=",
"$",
"fromClause",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"fromClauses",
")",
";",
"}"
] | Generates the "FROM" clause.
@return string The "FROM" clause. | [
"Generates",
"the",
"FROM",
"clause",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Query/QueryBuilder.php#L803-L826 | train |
phpffcms/ffcms-core | src/Helper/Type/Str.php | Str.cleanExtension | public static function cleanExtension(?string $string): ?string
{
// no extension in string is founded
if (!self::contains('.', $string)) {
return $string;
}
$splited = explode('.', $string);
array_pop($splited);
return implode('.', $splited);
} | php | public static function cleanExtension(?string $string): ?string
{
// no extension in string is founded
if (!self::contains('.', $string)) {
return $string;
}
$splited = explode('.', $string);
array_pop($splited);
return implode('.', $splited);
} | [
"public",
"static",
"function",
"cleanExtension",
"(",
"?",
"string",
"$",
"string",
")",
":",
"?",
"string",
"{",
"// no extension in string is founded",
"if",
"(",
"!",
"self",
"::",
"contains",
"(",
"'.'",
",",
"$",
"string",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"$",
"splited",
"=",
"explode",
"(",
"'.'",
",",
"$",
"string",
")",
";",
"array_pop",
"(",
"$",
"splited",
")",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"splited",
")",
";",
"}"
] | Remove extension from string
@param string $string
@return string|null | [
"Remove",
"extension",
"from",
"string"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Type/Str.php#L103-L113 | train |
phpffcms/ffcms-core | src/Helper/Type/Str.php | Str.upperCase | public static function upperCase(?string $string = null): ?string
{
if ($string === null) {
return null;
}
return mb_strtoupper($string, 'UTF-8');
} | php | public static function upperCase(?string $string = null): ?string
{
if ($string === null) {
return null;
}
return mb_strtoupper($string, 'UTF-8');
} | [
"public",
"static",
"function",
"upperCase",
"(",
"?",
"string",
"$",
"string",
"=",
"null",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"string",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"mb_strtoupper",
"(",
"$",
"string",
",",
"'UTF-8'",
")",
";",
"}"
] | Change content to upper case. Analog of strtoupper with UTF-8
@param string|null $string
@return string|null | [
"Change",
"content",
"to",
"upper",
"case",
".",
"Analog",
"of",
"strtoupper",
"with",
"UTF",
"-",
"8"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Type/Str.php#L145-L152 | train |
phpffcms/ffcms-core | src/Helper/Type/Str.php | Str.splitCamelCase | public static function splitCamelCase(string $string, string $glue = ' '): string
{
$expression = '/(?#! splitCamelCase Rev:20140412)
# Split camelCase "words". Two global alternatives. Either g1of2:
(?<=[a-z]) # Position is after a lowercase,
(?=[A-Z]) # and before an uppercase letter.
| (?<=[A-Z]) # Or g2of2; Position is after uppercase,
(?=[A-Z][a-z]) # and before upper-then-lower case.
/x';
$split = preg_split($expression, $string);
$output = [];
$count = count($split);
for ($i = 0; $i < $count; ++$i) { // @todo: rework me with foreach() cycle
$word = strtolower($split[$i]);
if ($i === 0) {
$word = ucfirst($word);
}
$output[] = $word;
}
return implode($glue, $output);
} | php | public static function splitCamelCase(string $string, string $glue = ' '): string
{
$expression = '/(?#! splitCamelCase Rev:20140412)
# Split camelCase "words". Two global alternatives. Either g1of2:
(?<=[a-z]) # Position is after a lowercase,
(?=[A-Z]) # and before an uppercase letter.
| (?<=[A-Z]) # Or g2of2; Position is after uppercase,
(?=[A-Z][a-z]) # and before upper-then-lower case.
/x';
$split = preg_split($expression, $string);
$output = [];
$count = count($split);
for ($i = 0; $i < $count; ++$i) { // @todo: rework me with foreach() cycle
$word = strtolower($split[$i]);
if ($i === 0) {
$word = ucfirst($word);
}
$output[] = $word;
}
return implode($glue, $output);
} | [
"public",
"static",
"function",
"splitCamelCase",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"glue",
"=",
"' '",
")",
":",
"string",
"{",
"$",
"expression",
"=",
"'/(?#! splitCamelCase Rev:20140412)\n # Split camelCase \"words\". Two global alternatives. Either g1of2:\n (?<=[a-z]) # Position is after a lowercase,\n (?=[A-Z]) # and before an uppercase letter.\n | (?<=[A-Z]) # Or g2of2; Position is after uppercase,\n (?=[A-Z][a-z]) # and before upper-then-lower case.\n /x'",
";",
"$",
"split",
"=",
"preg_split",
"(",
"$",
"expression",
",",
"$",
"string",
")",
";",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"split",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"++",
"$",
"i",
")",
"{",
"// @todo: rework me with foreach() cycle",
"$",
"word",
"=",
"strtolower",
"(",
"$",
"split",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"i",
"===",
"0",
")",
"{",
"$",
"word",
"=",
"ucfirst",
"(",
"$",
"word",
")",
";",
"}",
"$",
"output",
"[",
"]",
"=",
"$",
"word",
";",
"}",
"return",
"implode",
"(",
"$",
"glue",
",",
"$",
"output",
")",
";",
"}"
] | Split camel case words with glue. camelCaseWords => Camel case words
@param string $string
@param string $glue
@return string | [
"Split",
"camel",
"case",
"words",
"with",
"glue",
".",
"camelCaseWords",
"=",
">",
"Camel",
"case",
"words"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Type/Str.php#L171-L192 | train |
phpffcms/ffcms-core | src/Helper/Type/Str.php | Str.concat | public static function concat()
{
$args = func_get_args();
$separator = array_shift($args);
$output = null;
foreach ($args as $string) {
$output .= $string . $separator;
}
$output = rtrim($output, $separator);
return $output;
} | php | public static function concat()
{
$args = func_get_args();
$separator = array_shift($args);
$output = null;
foreach ($args as $string) {
$output .= $string . $separator;
}
$output = rtrim($output, $separator);
return $output;
} | [
"public",
"static",
"function",
"concat",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"separator",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"output",
"=",
"null",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"string",
")",
"{",
"$",
"output",
".=",
"$",
"string",
".",
"$",
"separator",
";",
"}",
"$",
"output",
"=",
"rtrim",
"(",
"$",
"output",
",",
"$",
"separator",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Concat string with add string by separator
@param string $separator
@param string $string1
@param string $string2
@return string | [
"Concat",
"string",
"with",
"add",
"string",
"by",
"separator"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Helper/Type/Str.php#L336-L348 | train |
freialib/ran.tools | src/Trait/Form.php | FormTrait.btn | function btn($label, $tagbody) {
return $this->button($label, null, $tagbody)
->set('type', null);
} | php | function btn($label, $tagbody) {
return $this->button($label, null, $tagbody)
->set('type', null);
} | [
"function",
"btn",
"(",
"$",
"label",
",",
"$",
"tagbody",
")",
"{",
"return",
"$",
"this",
"->",
"button",
"(",
"$",
"label",
",",
"null",
",",
"$",
"tagbody",
")",
"->",
"set",
"(",
"'type'",
",",
"null",
")",
";",
"}"
] | Same as button only it doenst submit data.
@return \ran\Field | [
"Same",
"as",
"button",
"only",
"it",
"doenst",
"submit",
"data",
"."
] | f4cbb926ef54da357b102cbfa4b6ce273be6ce63 | https://github.com/freialib/ran.tools/blob/f4cbb926ef54da357b102cbfa4b6ce273be6ce63/src/Trait/Form.php#L92-L95 | train |
freialib/ran.tools | src/Trait/Form.php | FormTrait.errors | function errors($fieldname) {
if ($fieldname == null) {
return null;
}
else { # field errors
if ($this->errors !== null) {
if (isset($this->errors[$fieldname])) {
return $this->errors[$fieldname];
}
else { # not set
return null;
}
}
}
} | php | function errors($fieldname) {
if ($fieldname == null) {
return null;
}
else { # field errors
if ($this->errors !== null) {
if (isset($this->errors[$fieldname])) {
return $this->errors[$fieldname];
}
else { # not set
return null;
}
}
}
} | [
"function",
"errors",
"(",
"$",
"fieldname",
")",
"{",
"if",
"(",
"$",
"fieldname",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"# field errors",
"if",
"(",
"$",
"this",
"->",
"errors",
"!==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"fieldname",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"errors",
"[",
"$",
"fieldname",
"]",
";",
"}",
"else",
"{",
"# not set",
"return",
"null",
";",
"}",
"}",
"}",
"}"
] | Retrieves errors for a given field or all errors if no field
is specified.
@return array or null | [
"Retrieves",
"errors",
"for",
"a",
"given",
"field",
"or",
"all",
"errors",
"if",
"no",
"field",
"is",
"specified",
"."
] | f4cbb926ef54da357b102cbfa4b6ce273be6ce63 | https://github.com/freialib/ran.tools/blob/f4cbb926ef54da357b102cbfa4b6ce273be6ce63/src/Trait/Form.php#L289-L303 | train |
freialib/ran.tools | src/Trait/Form.php | FormTrait.addfieldconfigurer | function addfieldconfigurer(callable $configurer, $fieldtypes = null) {
$fieldtypes != null or $fieldtypes = 'field';
is_array($fieldtypes) or $fieldtypes = [$fieldtypes];
foreach ($fieldtypes as $fieldtype) {
$this->fieldconfigurers[$fieldtype] = $configurer;
}
return $this;
} | php | function addfieldconfigurer(callable $configurer, $fieldtypes = null) {
$fieldtypes != null or $fieldtypes = 'field';
is_array($fieldtypes) or $fieldtypes = [$fieldtypes];
foreach ($fieldtypes as $fieldtype) {
$this->fieldconfigurers[$fieldtype] = $configurer;
}
return $this;
} | [
"function",
"addfieldconfigurer",
"(",
"callable",
"$",
"configurer",
",",
"$",
"fieldtypes",
"=",
"null",
")",
"{",
"$",
"fieldtypes",
"!=",
"null",
"or",
"$",
"fieldtypes",
"=",
"'field'",
";",
"is_array",
"(",
"$",
"fieldtypes",
")",
"or",
"$",
"fieldtypes",
"=",
"[",
"$",
"fieldtypes",
"]",
";",
"foreach",
"(",
"$",
"fieldtypes",
"as",
"$",
"fieldtype",
")",
"{",
"$",
"this",
"->",
"fieldconfigurers",
"[",
"$",
"fieldtype",
"]",
"=",
"$",
"configurer",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a configurer to the field. The configurer is called by the fields
during rendering. The configurer is primarily used for formatting.
If fieldtype is null the configurer will apply to all fields in the
absence of a specialized configurer.
@return static $this | [
"Adds",
"a",
"configurer",
"to",
"the",
"field",
".",
"The",
"configurer",
"is",
"called",
"by",
"the",
"fields",
"during",
"rendering",
".",
"The",
"configurer",
"is",
"primarily",
"used",
"for",
"formatting",
"."
] | f4cbb926ef54da357b102cbfa4b6ce273be6ce63 | https://github.com/freialib/ran.tools/blob/f4cbb926ef54da357b102cbfa4b6ce273be6ce63/src/Trait/Form.php#L346-L355 | train |
praxigento/mobi_mod_downline | Plugin/Magento/Customer/Model/GroupManagement.php | GroupManagement.aroundGetNotLoggedInGroup | public function aroundGetNotLoggedInGroup(
\Magento\Customer\Model\GroupManagement $subject,
\Closure $proceed
)
{
/* call parent to process other around-plugins */
$result = $proceed();
/* check referral code in registry */
$code = $this->hlpReferral->getReferralCode();
if ($code) {
/* and return referral group if code exists */
$groupId = $this->hlpConfig->getReferralsGroupReferrals();
$result = $this->daoCustGroup->getById($groupId);
}
return $result;
} | php | public function aroundGetNotLoggedInGroup(
\Magento\Customer\Model\GroupManagement $subject,
\Closure $proceed
)
{
/* call parent to process other around-plugins */
$result = $proceed();
/* check referral code in registry */
$code = $this->hlpReferral->getReferralCode();
if ($code) {
/* and return referral group if code exists */
$groupId = $this->hlpConfig->getReferralsGroupReferrals();
$result = $this->daoCustGroup->getById($groupId);
}
return $result;
} | [
"public",
"function",
"aroundGetNotLoggedInGroup",
"(",
"\\",
"Magento",
"\\",
"Customer",
"\\",
"Model",
"\\",
"GroupManagement",
"$",
"subject",
",",
"\\",
"Closure",
"$",
"proceed",
")",
"{",
"/* call parent to process other around-plugins */",
"$",
"result",
"=",
"$",
"proceed",
"(",
")",
";",
"/* check referral code in registry */",
"$",
"code",
"=",
"$",
"this",
"->",
"hlpReferral",
"->",
"getReferralCode",
"(",
")",
";",
"if",
"(",
"$",
"code",
")",
"{",
"/* and return referral group if code exists */",
"$",
"groupId",
"=",
"$",
"this",
"->",
"hlpConfig",
"->",
"getReferralsGroupReferrals",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"daoCustGroup",
"->",
"getById",
"(",
"$",
"groupId",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get referral group data instead of anonymous group.
@param \Magento\Customer\Model\GroupManagement $subject
@param \Closure $proceed
@return \Magento\Customer\Api\Data\GroupInterface
@throws \Magento\Framework\Exception\LocalizedException | [
"Get",
"referral",
"group",
"data",
"instead",
"of",
"anonymous",
"group",
"."
] | 0f3c276dfff1aa029f9fd205ccfc56f207a2e75b | https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Plugin/Magento/Customer/Model/GroupManagement.php#L37-L52 | train |
Kris-Kuiper/sFire-Framework | src/Container/Container.php | Container.add | public static function add($key, $value) {
if(null === $value && is_array($key)) {
foreach($key as $index => $value) {
static :: $data[$index] = $value;
}
return;
}
if(true === isset(static :: $data[$key]) && true === is_array(static :: $data[$key])) {
if(true === is_array($value)) {
$value = array_merge(static :: $data[$key], $value);
}
else {
static :: $data[$key][] = $value;
}
}
static :: $data[$key] = $value;
} | php | public static function add($key, $value) {
if(null === $value && is_array($key)) {
foreach($key as $index => $value) {
static :: $data[$index] = $value;
}
return;
}
if(true === isset(static :: $data[$key]) && true === is_array(static :: $data[$key])) {
if(true === is_array($value)) {
$value = array_merge(static :: $data[$key], $value);
}
else {
static :: $data[$key][] = $value;
}
}
static :: $data[$key] = $value;
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
"&&",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"foreach",
"(",
"$",
"key",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"static",
"::",
"$",
"data",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"return",
";",
"}",
"if",
"(",
"true",
"===",
"isset",
"(",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"&&",
"true",
"===",
"is_array",
"(",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"true",
"===",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_merge",
"(",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Stores a new piece of data and tries to merge the data if already exists
@param string|array $key
@param mixed $value | [
"Stores",
"a",
"new",
"piece",
"of",
"data",
"and",
"tries",
"to",
"merge",
"the",
"data",
"if",
"already",
"exists"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Container/Container.php#L23-L45 | train |
Kris-Kuiper/sFire-Framework | src/Container/Container.php | Container.set | public static function set($key, $value) {
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
static :: $data[$key] = $value;
} | php | public static function set($key, $value) {
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
static :: $data[$key] = $value;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"key",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] | Stores a new piece of data and overwrites the data if already exists
@param string $key
@param mixed $value | [
"Stores",
"a",
"new",
"piece",
"of",
"data",
"and",
"overwrites",
"the",
"data",
"if",
"already",
"exists"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Container/Container.php#L53-L60 | train |
Kris-Kuiper/sFire-Framework | src/Container/Container.php | Container.remove | public static function remove($key) {
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
if($key && isset(static :: $data[$key])) {
unset(static :: $data[$key]);
}
} | php | public static function remove($key) {
if(false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
if($key && isset(static :: $data[$key])) {
unset(static :: $data[$key]);
}
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"false",
"===",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type string, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"key",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"$",
"key",
"&&",
"isset",
"(",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"static",
"::",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Remove data based on key
@param string $key | [
"Remove",
"data",
"based",
"on",
"key"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Container/Container.php#L90-L99 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.set | public function set($number)
{
$this->setCurrentValue($number);
$this->currentOperation = 'add';
$this->addToHistory('set', $number);
return $this;
} | php | public function set($number)
{
$this->setCurrentValue($number);
$this->currentOperation = 'add';
$this->addToHistory('set', $number);
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"number",
")",
"{",
"$",
"this",
"->",
"setCurrentValue",
"(",
"$",
"number",
")",
";",
"$",
"this",
"->",
"currentOperation",
"=",
"'add'",
";",
"$",
"this",
"->",
"addToHistory",
"(",
"'set'",
",",
"$",
"number",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the current value.
@param $number
@return $this | [
"Sets",
"the",
"current",
"value",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L180-L186 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.performOperationOnExpressionEngine | protected function performOperationOnExpressionEngine($operation, $number)
{
$this->currentOperation = $operation;
if (is_array($number)) {
foreach ($number as $actualNumber) {
$this->{$operation}($actualNumber);
}
} else {
$this->addToHistory($operation, $number);
$this->setCurrentValue($this->expressionEngine->{$operation}($this->getCurrentValue(), $number));
}
} | php | protected function performOperationOnExpressionEngine($operation, $number)
{
$this->currentOperation = $operation;
if (is_array($number)) {
foreach ($number as $actualNumber) {
$this->{$operation}($actualNumber);
}
} else {
$this->addToHistory($operation, $number);
$this->setCurrentValue($this->expressionEngine->{$operation}($this->getCurrentValue(), $number));
}
} | [
"protected",
"function",
"performOperationOnExpressionEngine",
"(",
"$",
"operation",
",",
"$",
"number",
")",
"{",
"$",
"this",
"->",
"currentOperation",
"=",
"$",
"operation",
";",
"if",
"(",
"is_array",
"(",
"$",
"number",
")",
")",
"{",
"foreach",
"(",
"$",
"number",
"as",
"$",
"actualNumber",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"operation",
"}",
"(",
"$",
"actualNumber",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addToHistory",
"(",
"$",
"operation",
",",
"$",
"number",
")",
";",
"$",
"this",
"->",
"setCurrentValue",
"(",
"$",
"this",
"->",
"expressionEngine",
"->",
"{",
"$",
"operation",
"}",
"(",
"$",
"this",
"->",
"getCurrentValue",
"(",
")",
",",
"$",
"number",
")",
")",
";",
"}",
"}"
] | Helper function to recursively call a method on the FluentCalculator
and the underlying expression engine.
@param $operation
@param $number | [
"Helper",
"function",
"to",
"recursively",
"call",
"a",
"method",
"on",
"the",
"FluentCalculator",
"and",
"the",
"underlying",
"expression",
"engine",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L195-L206 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.add | public function add($number = null)
{
if ($number == null) {
$this->internalSetOperationModeWithHistory('add');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('add');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('add', $number);
}
return $this;
} | php | public function add($number = null)
{
if ($number == null) {
$this->internalSetOperationModeWithHistory('add');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('add');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('add', $number);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"number",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"number",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'add'",
")",
";",
"}",
"elseif",
"(",
"$",
"number",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'add'",
")",
";",
"return",
"$",
"this",
"->",
"group",
"(",
"$",
"number",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"performOperationOnExpressionEngine",
"(",
"'add'",
",",
"$",
"number",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a given number to the current value.
@param $number
@return $this | [
"Adds",
"a",
"given",
"number",
"to",
"the",
"current",
"value",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L242-L253 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.subtract | public function subtract($number = null)
{
if ($number == null) {
$this->internalSetOperationModeWithHistory('subtract');
} elseif($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('subtract');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('subtract', $number);
}
return $this;
} | php | public function subtract($number = null)
{
if ($number == null) {
$this->internalSetOperationModeWithHistory('subtract');
} elseif($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('subtract');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('subtract', $number);
}
return $this;
} | [
"public",
"function",
"subtract",
"(",
"$",
"number",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"number",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'subtract'",
")",
";",
"}",
"elseif",
"(",
"$",
"number",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'subtract'",
")",
";",
"return",
"$",
"this",
"->",
"group",
"(",
"$",
"number",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"performOperationOnExpressionEngine",
"(",
"'subtract'",
",",
"$",
"number",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Subtracts a given number from the current value.
@param $number
@return $this | [
"Subtracts",
"a",
"given",
"number",
"from",
"the",
"current",
"value",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L262-L274 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.multiply | public function multiply($number = null)
{
if ($number === null) {
$this->internalSetOperationModeWithHistory('multiply');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('multiply');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('multiply', $number);
}
return $this;
} | php | public function multiply($number = null)
{
if ($number === null) {
$this->internalSetOperationModeWithHistory('multiply');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('multiply');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('multiply', $number);
}
return $this;
} | [
"public",
"function",
"multiply",
"(",
"$",
"number",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"number",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'multiply'",
")",
";",
"}",
"elseif",
"(",
"$",
"number",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'multiply'",
")",
";",
"return",
"$",
"this",
"->",
"group",
"(",
"$",
"number",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"performOperationOnExpressionEngine",
"(",
"'multiply'",
",",
"$",
"number",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Multiplies the current value by a given number.
@param $number
@return $this | [
"Multiplies",
"the",
"current",
"value",
"by",
"a",
"given",
"number",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L283-L295 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.divide | public function divide($number = null)
{
if ($number === null) {
$this->internalSetOperationModeWithHistory('divide');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('divide');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('divide', $number);
}
return $this;
} | php | public function divide($number = null)
{
if ($number === null) {
$this->internalSetOperationModeWithHistory('divide');
} elseif ($number instanceof Closure) {
$this->internalSetOperationModeWithHistory('divide');
return $this->group($number);
} else {
$this->performOperationOnExpressionEngine('divide', $number);
}
return $this;
} | [
"public",
"function",
"divide",
"(",
"$",
"number",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"number",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'divide'",
")",
";",
"}",
"elseif",
"(",
"$",
"number",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"internalSetOperationModeWithHistory",
"(",
"'divide'",
")",
";",
"return",
"$",
"this",
"->",
"group",
"(",
"$",
"number",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"performOperationOnExpressionEngine",
"(",
"'divide'",
",",
"$",
"number",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Divides the current value by a given number.
@param $number
@throws \Stillat\Common\Exceptions\Arithmetic\DivideByZeroException;
@return $this | [
"Divides",
"the",
"current",
"value",
"by",
"a",
"given",
"number",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L305-L317 | train |
Stillat/Common | src/Stillat/Common/Math/FluentCalculator.php | FluentCalculator.round | public function round($number, $precision = 0, $mode = PHP_ROUND_HALF_UP)
{
return $this->runExpressionFunction3Param('round', $number, $precision, $mode);
} | php | public function round($number, $precision = 0, $mode = PHP_ROUND_HALF_UP)
{
return $this->runExpressionFunction3Param('round', $number, $precision, $mode);
} | [
"public",
"function",
"round",
"(",
"$",
"number",
",",
"$",
"precision",
"=",
"0",
",",
"$",
"mode",
"=",
"PHP_ROUND_HALF_UP",
")",
"{",
"return",
"$",
"this",
"->",
"runExpressionFunction3Param",
"(",
"'round'",
",",
"$",
"number",
",",
"$",
"precision",
",",
"$",
"mode",
")",
";",
"}"
] | Rounds a number to the nearest value.
@param float|Closure $number
@param int|Closure $precision optional The number of digits to round to.
@param int|Closure $mode optional The rounding mode.
@return $this | [
"Rounds",
"a",
"number",
"to",
"the",
"nearest",
"value",
"."
] | 9f69105292740c307aece588cf58a85892bad350 | https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Math/FluentCalculator.php#L619-L622 | train |
mrimann/CacheBreaker | Classes/FusionObjects/ResourceUriImplementation.php | ResourceUriImplementation.evaluate | public function evaluate()
{
$path = $this->getPath();
if ($path === null) {
throw new FusionException('"path" was not specified', 1386458763);
}
$package = $this->getPackage();
if ($package === null) {
$controllerContext = $this->runtime->getControllerContext();
/** @var $actionRequest ActionRequest */
$actionRequest = $controllerContext->getRequest();
$package = $actionRequest->getControllerPackageKey();
}
return $this->resourceService->getResourceUri($path, $package);
} | php | public function evaluate()
{
$path = $this->getPath();
if ($path === null) {
throw new FusionException('"path" was not specified', 1386458763);
}
$package = $this->getPackage();
if ($package === null) {
$controllerContext = $this->runtime->getControllerContext();
/** @var $actionRequest ActionRequest */
$actionRequest = $controllerContext->getRequest();
$package = $actionRequest->getControllerPackageKey();
}
return $this->resourceService->getResourceUri($path, $package);
} | [
"public",
"function",
"evaluate",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"throw",
"new",
"FusionException",
"(",
"'\"path\" was not specified'",
",",
"1386458763",
")",
";",
"}",
"$",
"package",
"=",
"$",
"this",
"->",
"getPackage",
"(",
")",
";",
"if",
"(",
"$",
"package",
"===",
"null",
")",
"{",
"$",
"controllerContext",
"=",
"$",
"this",
"->",
"runtime",
"->",
"getControllerContext",
"(",
")",
";",
"/** @var $actionRequest ActionRequest */",
"$",
"actionRequest",
"=",
"$",
"controllerContext",
"->",
"getRequest",
"(",
")",
";",
"$",
"package",
"=",
"$",
"actionRequest",
"->",
"getControllerPackageKey",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resourceService",
"->",
"getResourceUri",
"(",
"$",
"path",
",",
"$",
"package",
")",
";",
"}"
] | Returns the absolute URL of a resource with cache bursting string
@return string
@throws FusionException
@throws \Exception | [
"Returns",
"the",
"absolute",
"URL",
"of",
"a",
"resource",
"with",
"cache",
"bursting",
"string"
] | 2b195f06bc2f92d1d9dc069fdc67cc28a3bee576 | https://github.com/mrimann/CacheBreaker/blob/2b195f06bc2f92d1d9dc069fdc67cc28a3bee576/Classes/FusionObjects/ResourceUriImplementation.php#L61-L77 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/messages/MessageCodeResolver.php | MessageCodeResolver.getPropertyFilepaths | protected function getPropertyFilepaths()
{
$file = $this->basename.'.properties';
if($this->MessageService->fileExists($file))
return $this->MessageService->resolveFile($file)->getLocalPath();
return null;
} | php | protected function getPropertyFilepaths()
{
$file = $this->basename.'.properties';
if($this->MessageService->fileExists($file))
return $this->MessageService->resolveFile($file)->getLocalPath();
return null;
} | [
"protected",
"function",
"getPropertyFilepaths",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"basename",
".",
"'.properties'",
";",
"if",
"(",
"$",
"this",
"->",
"MessageService",
"->",
"fileExists",
"(",
"$",
"file",
")",
")",
"return",
"$",
"this",
"->",
"MessageService",
"->",
"resolveFile",
"(",
"$",
"file",
")",
"->",
"getLocalPath",
"(",
")",
";",
"return",
"null",
";",
"}"
] | Get a list of reverse-specific absolute property file paths
@return array | [
"Get",
"a",
"list",
"of",
"reverse",
"-",
"specific",
"absolute",
"property",
"file",
"paths"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/messages/MessageCodeResolver.php#L205-L213 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.