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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
OxfordInfoLabs/kinikit-core | src/Util/ObjectUtils.php | ObjectUtils.getDifferingMembers | public static function getDifferingMembers($object1, $object2, $membersToConsider = array(), $recursive = false) {
if (!($object1 instanceof SerialisableObject) || !($object2 instanceof SerialisableObject)) {
throw new Exception("You cannot compare for differing members of none serialisable objects");
}
$members1 = $object1->__getSerialisablePropertyMap();
$members2 = $object2->__getSerialisablePropertyMap();
// Turn members to consider into a values array for ease of processing
if (is_array($membersToConsider)) {
$membersToConsider = array_values($membersToConsider);
}
// Go through first object, look for differences that way.
$differingMembers = array();
foreach ($members1 as $member => $value) {
if (!is_object($value) && !is_array($value)) {
if (isset($members2[$member]) && $members2[$member] != $value) {
if (!$membersToConsider || is_numeric(array_search($member, $membersToConsider))) {
$differingMembers[$member] = array("first" => $value, "second" => $members2[$member]);
}
}
}
if (is_object($value) && is_object($members2[$member]) && $recursive) {
$differingSubMembers = ObjectUtils::getDifferingMembers($value, $members2[$member], null, true);
foreach ($differingSubMembers as $key => $subMember) {
if (!$membersToConsider || is_numeric(array_search($member . "." . $key, $membersToConsider))) {
$differingMembers[$member . "." . $key] = $subMember;
}
}
}
if (is_array($value) && is_array($members2[$member]) && $recursive) {
foreach ($value as $key => $memberEntry) {
if (is_object($memberEntry) && isset($members2[$member][$key]) && is_object($members2[$member][$key])) {
$differingSubMembers = ObjectUtils::getDifferingMembers($memberEntry, $members2[$member][$key], null, true);
foreach ($differingSubMembers as $subKey => $subMember) {
$differingMembers[$member . "[" . $key . "]" . "." . $subKey] = $subMember;
}
}
}
}
}
return $differingMembers;
} | php | public static function getDifferingMembers($object1, $object2, $membersToConsider = array(), $recursive = false) {
if (!($object1 instanceof SerialisableObject) || !($object2 instanceof SerialisableObject)) {
throw new Exception("You cannot compare for differing members of none serialisable objects");
}
$members1 = $object1->__getSerialisablePropertyMap();
$members2 = $object2->__getSerialisablePropertyMap();
// Turn members to consider into a values array for ease of processing
if (is_array($membersToConsider)) {
$membersToConsider = array_values($membersToConsider);
}
// Go through first object, look for differences that way.
$differingMembers = array();
foreach ($members1 as $member => $value) {
if (!is_object($value) && !is_array($value)) {
if (isset($members2[$member]) && $members2[$member] != $value) {
if (!$membersToConsider || is_numeric(array_search($member, $membersToConsider))) {
$differingMembers[$member] = array("first" => $value, "second" => $members2[$member]);
}
}
}
if (is_object($value) && is_object($members2[$member]) && $recursive) {
$differingSubMembers = ObjectUtils::getDifferingMembers($value, $members2[$member], null, true);
foreach ($differingSubMembers as $key => $subMember) {
if (!$membersToConsider || is_numeric(array_search($member . "." . $key, $membersToConsider))) {
$differingMembers[$member . "." . $key] = $subMember;
}
}
}
if (is_array($value) && is_array($members2[$member]) && $recursive) {
foreach ($value as $key => $memberEntry) {
if (is_object($memberEntry) && isset($members2[$member][$key]) && is_object($members2[$member][$key])) {
$differingSubMembers = ObjectUtils::getDifferingMembers($memberEntry, $members2[$member][$key], null, true);
foreach ($differingSubMembers as $subKey => $subMember) {
$differingMembers[$member . "[" . $key . "]" . "." . $subKey] = $subMember;
}
}
}
}
}
return $differingMembers;
} | [
"public",
"static",
"function",
"getDifferingMembers",
"(",
"$",
"object1",
",",
"$",
"object2",
",",
"$",
"membersToConsider",
"=",
"array",
"(",
")",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object1",
"instanceof",
"SerialisableObject",
")",
"||",
"!",
"(",
"$",
"object2",
"instanceof",
"SerialisableObject",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"You cannot compare for differing members of none serialisable objects\"",
")",
";",
"}",
"$",
"members1",
"=",
"$",
"object1",
"->",
"__getSerialisablePropertyMap",
"(",
")",
";",
"$",
"members2",
"=",
"$",
"object2",
"->",
"__getSerialisablePropertyMap",
"(",
")",
";",
"// Turn members to consider into a values array for ease of processing",
"if",
"(",
"is_array",
"(",
"$",
"membersToConsider",
")",
")",
"{",
"$",
"membersToConsider",
"=",
"array_values",
"(",
"$",
"membersToConsider",
")",
";",
"}",
"// Go through first object, look for differences that way.",
"$",
"differingMembers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"members1",
"as",
"$",
"member",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"value",
")",
"&&",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"members2",
"[",
"$",
"member",
"]",
")",
"&&",
"$",
"members2",
"[",
"$",
"member",
"]",
"!=",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"membersToConsider",
"||",
"is_numeric",
"(",
"array_search",
"(",
"$",
"member",
",",
"$",
"membersToConsider",
")",
")",
")",
"{",
"$",
"differingMembers",
"[",
"$",
"member",
"]",
"=",
"array",
"(",
"\"first\"",
"=>",
"$",
"value",
",",
"\"second\"",
"=>",
"$",
"members2",
"[",
"$",
"member",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"is_object",
"(",
"$",
"members2",
"[",
"$",
"member",
"]",
")",
"&&",
"$",
"recursive",
")",
"{",
"$",
"differingSubMembers",
"=",
"ObjectUtils",
"::",
"getDifferingMembers",
"(",
"$",
"value",
",",
"$",
"members2",
"[",
"$",
"member",
"]",
",",
"null",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"differingSubMembers",
"as",
"$",
"key",
"=>",
"$",
"subMember",
")",
"{",
"if",
"(",
"!",
"$",
"membersToConsider",
"||",
"is_numeric",
"(",
"array_search",
"(",
"$",
"member",
".",
"\".\"",
".",
"$",
"key",
",",
"$",
"membersToConsider",
")",
")",
")",
"{",
"$",
"differingMembers",
"[",
"$",
"member",
".",
"\".\"",
".",
"$",
"key",
"]",
"=",
"$",
"subMember",
";",
"}",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"is_array",
"(",
"$",
"members2",
"[",
"$",
"member",
"]",
")",
"&&",
"$",
"recursive",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"memberEntry",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"memberEntry",
")",
"&&",
"isset",
"(",
"$",
"members2",
"[",
"$",
"member",
"]",
"[",
"$",
"key",
"]",
")",
"&&",
"is_object",
"(",
"$",
"members2",
"[",
"$",
"member",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"differingSubMembers",
"=",
"ObjectUtils",
"::",
"getDifferingMembers",
"(",
"$",
"memberEntry",
",",
"$",
"members2",
"[",
"$",
"member",
"]",
"[",
"$",
"key",
"]",
",",
"null",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"differingSubMembers",
"as",
"$",
"subKey",
"=>",
"$",
"subMember",
")",
"{",
"$",
"differingMembers",
"[",
"$",
"member",
".",
"\"[\"",
".",
"$",
"key",
".",
"\"]\"",
".",
"\".\"",
".",
"$",
"subKey",
"]",
"=",
"$",
"subMember",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"differingMembers",
";",
"}"
] | Get differing members between two serialisable source objects - this will return a structured array detailing the differences.
If the membersToConsider array is passed only members contained within the array will be considered otherwise all members will be considered by default.
@param $object
@param $object2 | [
"Get",
"differing",
"members",
"between",
"two",
"serialisable",
"source",
"objects",
"-",
"this",
"will",
"return",
"a",
"structured",
"array",
"detailing",
"the",
"differences",
".",
"If",
"the",
"membersToConsider",
"array",
"is",
"passed",
"only",
"members",
"contained",
"within",
"the",
"array",
"will",
"be",
"considered",
"otherwise",
"all",
"members",
"will",
"be",
"considered",
"by",
"default",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/ObjectUtils.php#L138-L191 | train |
OxfordInfoLabs/kinikit-core | src/Util/ObjectUtils.php | ObjectUtils.getDifferingMembersFormattedString | public static function getDifferingMembersFormattedString($object1, $object2, $formatString, $separator, $displayMemberKeys = array(), $recursive = false) {
// Get the differing members
$differingMembers = ObjectUtils::getDifferingMembers($object1, $object2, array_keys($displayMemberKeys), $recursive);
// Loop through each differing member
$elements = array();
foreach ($differingMembers as $member => $data) {
$elements[] = str_replace(array("{member}", "{first}", "{second}"), array(
isset($displayMemberKeys[$member]) ? $displayMemberKeys[$member] : $member,
$data["first"], $data["second"]), $formatString);
}
return join($separator, $elements);
} | php | public static function getDifferingMembersFormattedString($object1, $object2, $formatString, $separator, $displayMemberKeys = array(), $recursive = false) {
// Get the differing members
$differingMembers = ObjectUtils::getDifferingMembers($object1, $object2, array_keys($displayMemberKeys), $recursive);
// Loop through each differing member
$elements = array();
foreach ($differingMembers as $member => $data) {
$elements[] = str_replace(array("{member}", "{first}", "{second}"), array(
isset($displayMemberKeys[$member]) ? $displayMemberKeys[$member] : $member,
$data["first"], $data["second"]), $formatString);
}
return join($separator, $elements);
} | [
"public",
"static",
"function",
"getDifferingMembersFormattedString",
"(",
"$",
"object1",
",",
"$",
"object2",
",",
"$",
"formatString",
",",
"$",
"separator",
",",
"$",
"displayMemberKeys",
"=",
"array",
"(",
")",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"// Get the differing members",
"$",
"differingMembers",
"=",
"ObjectUtils",
"::",
"getDifferingMembers",
"(",
"$",
"object1",
",",
"$",
"object2",
",",
"array_keys",
"(",
"$",
"displayMemberKeys",
")",
",",
"$",
"recursive",
")",
";",
"// Loop through each differing member",
"$",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"differingMembers",
"as",
"$",
"member",
"=>",
"$",
"data",
")",
"{",
"$",
"elements",
"[",
"]",
"=",
"str_replace",
"(",
"array",
"(",
"\"{member}\"",
",",
"\"{first}\"",
",",
"\"{second}\"",
")",
",",
"array",
"(",
"isset",
"(",
"$",
"displayMemberKeys",
"[",
"$",
"member",
"]",
")",
"?",
"$",
"displayMemberKeys",
"[",
"$",
"member",
"]",
":",
"$",
"member",
",",
"$",
"data",
"[",
"\"first\"",
"]",
",",
"$",
"data",
"[",
"\"second\"",
"]",
")",
",",
"$",
"formatString",
")",
";",
"}",
"return",
"join",
"(",
"$",
"separator",
",",
"$",
"elements",
")",
";",
"}"
] | Get a formatted string encoding the differing members.
@param $object
@param $object2
@param $formatString
@param $separator | [
"Get",
"a",
"formatted",
"string",
"encoding",
"the",
"differing",
"members",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/ObjectUtils.php#L201-L216 | train |
Blipfoto/php-sdk | src/Blipfoto/Traits/Helper.php | Helper.getset | public function getset($property, $args) {
if (count($args)) {
$this->$property = $args[0];
}
return $this->$property;
} | php | public function getset($property, $args) {
if (count($args)) {
$this->$property = $args[0];
}
return $this->$property;
} | [
"public",
"function",
"getset",
"(",
"$",
"property",
",",
"$",
"args",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"property",
";",
"}"
] | Get and optionally set the value for a property.
@param string $property
@param array $args | [
"Get",
"and",
"optionally",
"set",
"the",
"value",
"for",
"a",
"property",
"."
] | 04f770ac7427e79d15f97b993c787651079cdeb4 | https://github.com/Blipfoto/php-sdk/blob/04f770ac7427e79d15f97b993c787651079cdeb4/src/Blipfoto/Traits/Helper.php#L13-L18 | train |
codeblanche/Entity | src/Entity/Abstraction/AbstractEntity.php | AbstractEntity.resolveDefitions | protected function resolveDefitions(PropertyDefinitionCollectionInterface $propertyDefinitionCollection = null)
{
if ($propertyDefinitionCollection instanceof PropertyDefinitionCollectionInterface) {
return $propertyDefinitionCollection->import($this->propertiesAndTypes());
}
$className = $this->calledClassName();
if ($this->runtimeCache->has($className, __METHOD__)) {
return $this->runtimeCache->get($className, __METHOD__);
}
$propertyDefinitionCollection = $this->createPropertyDefinitionCollection();
$propertyDefinitionCollection->import($this->propertiesAndTypes());
$this->runtimeCache->set($className, $propertyDefinitionCollection, __METHOD__);
return $propertyDefinitionCollection;
} | php | protected function resolveDefitions(PropertyDefinitionCollectionInterface $propertyDefinitionCollection = null)
{
if ($propertyDefinitionCollection instanceof PropertyDefinitionCollectionInterface) {
return $propertyDefinitionCollection->import($this->propertiesAndTypes());
}
$className = $this->calledClassName();
if ($this->runtimeCache->has($className, __METHOD__)) {
return $this->runtimeCache->get($className, __METHOD__);
}
$propertyDefinitionCollection = $this->createPropertyDefinitionCollection();
$propertyDefinitionCollection->import($this->propertiesAndTypes());
$this->runtimeCache->set($className, $propertyDefinitionCollection, __METHOD__);
return $propertyDefinitionCollection;
} | [
"protected",
"function",
"resolveDefitions",
"(",
"PropertyDefinitionCollectionInterface",
"$",
"propertyDefinitionCollection",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"propertyDefinitionCollection",
"instanceof",
"PropertyDefinitionCollectionInterface",
")",
"{",
"return",
"$",
"propertyDefinitionCollection",
"->",
"import",
"(",
"$",
"this",
"->",
"propertiesAndTypes",
"(",
")",
")",
";",
"}",
"$",
"className",
"=",
"$",
"this",
"->",
"calledClassName",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"runtimeCache",
"->",
"has",
"(",
"$",
"className",
",",
"__METHOD__",
")",
")",
"{",
"return",
"$",
"this",
"->",
"runtimeCache",
"->",
"get",
"(",
"$",
"className",
",",
"__METHOD__",
")",
";",
"}",
"$",
"propertyDefinitionCollection",
"=",
"$",
"this",
"->",
"createPropertyDefinitionCollection",
"(",
")",
";",
"$",
"propertyDefinitionCollection",
"->",
"import",
"(",
"$",
"this",
"->",
"propertiesAndTypes",
"(",
")",
")",
";",
"$",
"this",
"->",
"runtimeCache",
"->",
"set",
"(",
"$",
"className",
",",
"$",
"propertyDefinitionCollection",
",",
"__METHOD__",
")",
";",
"return",
"$",
"propertyDefinitionCollection",
";",
"}"
] | Resolve and if necessary initialize the property definition collection.
@param PropertyDefinitionCollectionInterface $propertyDefinitionCollection
@return PropertyDefinitionCollectionInterface | [
"Resolve",
"and",
"if",
"necessary",
"initialize",
"the",
"property",
"definition",
"collection",
"."
] | 1d3839c09d7639ae8bbfc9d2721223202f3a5cdd | https://github.com/codeblanche/Entity/blob/1d3839c09d7639ae8bbfc9d2721223202f3a5cdd/src/Entity/Abstraction/AbstractEntity.php#L165-L184 | train |
OxfordInfoLabs/kinikit-core | src/Util/FileUtils.php | FileUtils.appendDataToFile | public static function appendDataToFile($filePath, $data, $newLine = false) {
if ($newLine) {
file_put_contents($filePath, $data . PHP_EOL, FILE_APPEND);
} else {
file_put_contents($filePath, $data, FILE_APPEND);
}
} | php | public static function appendDataToFile($filePath, $data, $newLine = false) {
if ($newLine) {
file_put_contents($filePath, $data . PHP_EOL, FILE_APPEND);
} else {
file_put_contents($filePath, $data, FILE_APPEND);
}
} | [
"public",
"static",
"function",
"appendDataToFile",
"(",
"$",
"filePath",
",",
"$",
"data",
",",
"$",
"newLine",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"newLine",
")",
"{",
"file_put_contents",
"(",
"$",
"filePath",
",",
"$",
"data",
".",
"PHP_EOL",
",",
"FILE_APPEND",
")",
";",
"}",
"else",
"{",
"file_put_contents",
"(",
"$",
"filePath",
",",
"$",
"data",
",",
"FILE_APPEND",
")",
";",
"}",
"}"
] | Add data to the end of a file.
@param $filePath string
@param $data string
@param $newLine boolean | [
"Add",
"data",
"to",
"the",
"end",
"of",
"a",
"file",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/FileUtils.php#L15-L21 | train |
OxfordInfoLabs/kinikit-core | src/Util/FileUtils.php | FileUtils.removeLineFromFile | public static function removeLineFromFile($filePath, $match) {
$allLines = file($filePath);
$matches = preg_grep('/' . $match . '/i', $allLines, PREG_GREP_INVERT);
// This removes any lines with returns, so we avoid additional blank lines when we glue
// back together again.
$cleanMatches = array_map(function ($str) {
return str_replace(PHP_EOL, '', $str);
}, $matches);
// Write each match back onto its own line.
file_put_contents($filePath, implode(PHP_EOL, array_filter($cleanMatches)));
} | php | public static function removeLineFromFile($filePath, $match) {
$allLines = file($filePath);
$matches = preg_grep('/' . $match . '/i', $allLines, PREG_GREP_INVERT);
// This removes any lines with returns, so we avoid additional blank lines when we glue
// back together again.
$cleanMatches = array_map(function ($str) {
return str_replace(PHP_EOL, '', $str);
}, $matches);
// Write each match back onto its own line.
file_put_contents($filePath, implode(PHP_EOL, array_filter($cleanMatches)));
} | [
"public",
"static",
"function",
"removeLineFromFile",
"(",
"$",
"filePath",
",",
"$",
"match",
")",
"{",
"$",
"allLines",
"=",
"file",
"(",
"$",
"filePath",
")",
";",
"$",
"matches",
"=",
"preg_grep",
"(",
"'/'",
".",
"$",
"match",
".",
"'/i'",
",",
"$",
"allLines",
",",
"PREG_GREP_INVERT",
")",
";",
"// This removes any lines with returns, so we avoid additional blank lines when we glue",
"// back together again.",
"$",
"cleanMatches",
"=",
"array_map",
"(",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"str_replace",
"(",
"PHP_EOL",
",",
"''",
",",
"$",
"str",
")",
";",
"}",
",",
"$",
"matches",
")",
";",
"// Write each match back onto its own line.",
"file_put_contents",
"(",
"$",
"filePath",
",",
"implode",
"(",
"PHP_EOL",
",",
"array_filter",
"(",
"$",
"cleanMatches",
")",
")",
")",
";",
"}"
] | Find matching line of text from file and remove it.
@param $filePath string
@param $match string | [
"Find",
"matching",
"line",
"of",
"text",
"from",
"file",
"and",
"remove",
"it",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/FileUtils.php#L33-L45 | train |
OxfordInfoLabs/kinikit-core | src/Util/FileUtils.php | FileUtils.returnMatchingLinesFromFile | public static function returnMatchingLinesFromFile($filePath, $textMatch) {
$allLines = file($filePath);
$matches = preg_grep("/" . $textMatch . "/i", $allLines);
$cleanMatches = array_map(function ($str) {
return str_replace(PHP_EOL, '', $str);
}, $matches);
return $cleanMatches;
} | php | public static function returnMatchingLinesFromFile($filePath, $textMatch) {
$allLines = file($filePath);
$matches = preg_grep("/" . $textMatch . "/i", $allLines);
$cleanMatches = array_map(function ($str) {
return str_replace(PHP_EOL, '', $str);
}, $matches);
return $cleanMatches;
} | [
"public",
"static",
"function",
"returnMatchingLinesFromFile",
"(",
"$",
"filePath",
",",
"$",
"textMatch",
")",
"{",
"$",
"allLines",
"=",
"file",
"(",
"$",
"filePath",
")",
";",
"$",
"matches",
"=",
"preg_grep",
"(",
"\"/\"",
".",
"$",
"textMatch",
".",
"\"/i\"",
",",
"$",
"allLines",
")",
";",
"$",
"cleanMatches",
"=",
"array_map",
"(",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"str_replace",
"(",
"PHP_EOL",
",",
"''",
",",
"$",
"str",
")",
";",
"}",
",",
"$",
"matches",
")",
";",
"return",
"$",
"cleanMatches",
";",
"}"
] | Return lines matching the text supplied.
@param $filePath
@param $textMatch
@return array | [
"Return",
"lines",
"matching",
"the",
"text",
"supplied",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/FileUtils.php#L54-L63 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.createMenu | public function createMenu(string $id, string $class): string
{
$output = $this->addOpeningNav($id);
if ($this->options['brand']['name'] !== '') $output .= $this->addBranding();
if ($this->options['mobile']) $output .= $this->addMobileButton();
$output .= '<div class="collapse navbar-collapse" id="bootstrapMenu">';
$output .= $this->createLeftMenu();
$output .= $this->createRightMenu();
$output .= '</div>';
$output .= '</nav>';
return $output;
} | php | public function createMenu(string $id, string $class): string
{
$output = $this->addOpeningNav($id);
if ($this->options['brand']['name'] !== '') $output .= $this->addBranding();
if ($this->options['mobile']) $output .= $this->addMobileButton();
$output .= '<div class="collapse navbar-collapse" id="bootstrapMenu">';
$output .= $this->createLeftMenu();
$output .= $this->createRightMenu();
$output .= '</div>';
$output .= '</nav>';
return $output;
} | [
"public",
"function",
"createMenu",
"(",
"string",
"$",
"id",
",",
"string",
"$",
"class",
")",
":",
"string",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"addOpeningNav",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'name'",
"]",
"!==",
"''",
")",
"$",
"output",
".=",
"$",
"this",
"->",
"addBranding",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'mobile'",
"]",
")",
"$",
"output",
".=",
"$",
"this",
"->",
"addMobileButton",
"(",
")",
";",
"$",
"output",
".=",
"'<div class=\"collapse navbar-collapse\" id=\"bootstrapMenu\">'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createLeftMenu",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createRightMenu",
"(",
")",
";",
"$",
"output",
".=",
"'</div>'",
";",
"$",
"output",
".=",
"'</nav>'",
";",
"return",
"$",
"output",
";",
"}"
] | 1.0 Start of creating the bootstrap menu
@param string $id
@param string $class
@return string | [
"1",
".",
"0",
"Start",
"of",
"creating",
"the",
"bootstrap",
"menu"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L65-L76 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.addOpeningNav | private function addOpeningNav(string $id): string
{
$output = '<nav ';
if ($id !== '') $output .= 'id="' . $id . '" ';
$output .= 'class="navbar navbar-' . $this->options['theme']['fore'];
if (!empty($this->options['theme']['back'])) $output .= " bg-" . $this->options['theme']['back'];
if ($this->options['mobile']) {
$output .= ' navbar-expand-' . $this->options['mobileSize'];
} else {
$output .= ' navbar-expand';
}
if (!empty($this->options['theme']['color'])) $output .= '" style="background-color: #' . $this->options['theme']['color'];
$output .= '">';
return $output;
} | php | private function addOpeningNav(string $id): string
{
$output = '<nav ';
if ($id !== '') $output .= 'id="' . $id . '" ';
$output .= 'class="navbar navbar-' . $this->options['theme']['fore'];
if (!empty($this->options['theme']['back'])) $output .= " bg-" . $this->options['theme']['back'];
if ($this->options['mobile']) {
$output .= ' navbar-expand-' . $this->options['mobileSize'];
} else {
$output .= ' navbar-expand';
}
if (!empty($this->options['theme']['color'])) $output .= '" style="background-color: #' . $this->options['theme']['color'];
$output .= '">';
return $output;
} | [
"private",
"function",
"addOpeningNav",
"(",
"string",
"$",
"id",
")",
":",
"string",
"{",
"$",
"output",
"=",
"'<nav '",
";",
"if",
"(",
"$",
"id",
"!==",
"''",
")",
"$",
"output",
".=",
"'id=\"'",
".",
"$",
"id",
".",
"'\" '",
";",
"$",
"output",
".=",
"'class=\"navbar navbar-'",
".",
"$",
"this",
"->",
"options",
"[",
"'theme'",
"]",
"[",
"'fore'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'theme'",
"]",
"[",
"'back'",
"]",
")",
")",
"$",
"output",
".=",
"\" bg-\"",
".",
"$",
"this",
"->",
"options",
"[",
"'theme'",
"]",
"[",
"'back'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'mobile'",
"]",
")",
"{",
"$",
"output",
".=",
"' navbar-expand-'",
".",
"$",
"this",
"->",
"options",
"[",
"'mobileSize'",
"]",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"' navbar-expand'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'theme'",
"]",
"[",
"'color'",
"]",
")",
")",
"$",
"output",
".=",
"'\" style=\"background-color: #'",
".",
"$",
"this",
"->",
"options",
"[",
"'theme'",
"]",
"[",
"'color'",
"]",
";",
"$",
"output",
".=",
"'\">'",
";",
"return",
"$",
"output",
";",
"}"
] | 1.1 Creating opening tag navigation
@param string $id
@return string | [
"1",
".",
"1",
"Creating",
"opening",
"tag",
"navigation"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L84-L98 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.addBranding | private function addBranding(): string
{
$output = '<a class="navbar-brand" href="' . BASE_URL . '/">';
if ($this->options['brand']['image']['link'] !== 'none') $output .= '<img src="' . BASE_URL . $this->options['brand']['image']['link'] . '" height="' . $this->options['brand']['image']['size'] . '" alt="Logo Website">';
$style = '';
if (!empty($this->options['brand']['style'])) {
foreach ($this->options['brand']['style'] as $key => $value) {
$key = strtolower($key);
if (is_string($value)) $value = strtolower($value);
$style .= $key . ':' . $value . ';';
}
}
$output .= '<span style="' . $style . '">' . $this->options['brand']['name'] . '</span></a>';
return $output;
} | php | private function addBranding(): string
{
$output = '<a class="navbar-brand" href="' . BASE_URL . '/">';
if ($this->options['brand']['image']['link'] !== 'none') $output .= '<img src="' . BASE_URL . $this->options['brand']['image']['link'] . '" height="' . $this->options['brand']['image']['size'] . '" alt="Logo Website">';
$style = '';
if (!empty($this->options['brand']['style'])) {
foreach ($this->options['brand']['style'] as $key => $value) {
$key = strtolower($key);
if (is_string($value)) $value = strtolower($value);
$style .= $key . ':' . $value . ';';
}
}
$output .= '<span style="' . $style . '">' . $this->options['brand']['name'] . '</span></a>';
return $output;
} | [
"private",
"function",
"addBranding",
"(",
")",
":",
"string",
"{",
"$",
"output",
"=",
"'<a class=\"navbar-brand\" href=\"'",
".",
"BASE_URL",
".",
"'/\">'",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'image'",
"]",
"[",
"'link'",
"]",
"!==",
"'none'",
")",
"$",
"output",
".=",
"'<img src=\"'",
".",
"BASE_URL",
".",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'image'",
"]",
"[",
"'link'",
"]",
".",
"'\" height=\"'",
".",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'image'",
"]",
"[",
"'size'",
"]",
".",
"'\" alt=\"Logo Website\">'",
";",
"$",
"style",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'style'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'style'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"$",
"style",
".=",
"$",
"key",
".",
"':'",
".",
"$",
"value",
".",
"';'",
";",
"}",
"}",
"$",
"output",
".=",
"'<span style=\"'",
".",
"$",
"style",
".",
"'\">'",
".",
"$",
"this",
"->",
"options",
"[",
"'brand'",
"]",
"[",
"'name'",
"]",
".",
"'</span></a>'",
";",
"return",
"$",
"output",
";",
"}"
] | 1.2 Adding the brand of the website to the menu
@return string | [
"1",
".",
"2",
"Adding",
"the",
"brand",
"of",
"the",
"website",
"to",
"the",
"menu"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L105-L119 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.createLeftMenu | private function createLeftMenu(): string
{
$argsCount = 0;
$arrayKey = $this->getArrayKey($this->menuData);
$output = '<ul class="navbar navbar-nav mr-auto">';
foreach ($arrayKey as $menuItem) {
list($url, $text, $place, $id, $class) = $this->getLinkInformation([$menuItem]);
if ($place == 'left') {
$arguments[$argsCount] = $menuItem;
$arraySubKey = $this->getArrayKey($this->menuData[$menuItem]);
if (count($arraySubKey) === 0) {
$output .= '<li class="nav-item">';
$output .= $this->createNavLinkUrl($arguments);
$output .= '</li>';
} else {
$output .= '<li class="nav-item dropdown">';
$output .= $this->createSubmenu($arguments, $this->menuData[$menuItem]);
$output .= '</li>';
}
}
}
$output .= '</ul>';
return $output;
} | php | private function createLeftMenu(): string
{
$argsCount = 0;
$arrayKey = $this->getArrayKey($this->menuData);
$output = '<ul class="navbar navbar-nav mr-auto">';
foreach ($arrayKey as $menuItem) {
list($url, $text, $place, $id, $class) = $this->getLinkInformation([$menuItem]);
if ($place == 'left') {
$arguments[$argsCount] = $menuItem;
$arraySubKey = $this->getArrayKey($this->menuData[$menuItem]);
if (count($arraySubKey) === 0) {
$output .= '<li class="nav-item">';
$output .= $this->createNavLinkUrl($arguments);
$output .= '</li>';
} else {
$output .= '<li class="nav-item dropdown">';
$output .= $this->createSubmenu($arguments, $this->menuData[$menuItem]);
$output .= '</li>';
}
}
}
$output .= '</ul>';
return $output;
} | [
"private",
"function",
"createLeftMenu",
"(",
")",
":",
"string",
"{",
"$",
"argsCount",
"=",
"0",
";",
"$",
"arrayKey",
"=",
"$",
"this",
"->",
"getArrayKey",
"(",
"$",
"this",
"->",
"menuData",
")",
";",
"$",
"output",
"=",
"'<ul class=\"navbar navbar-nav mr-auto\">'",
";",
"foreach",
"(",
"$",
"arrayKey",
"as",
"$",
"menuItem",
")",
"{",
"list",
"(",
"$",
"url",
",",
"$",
"text",
",",
"$",
"place",
",",
"$",
"id",
",",
"$",
"class",
")",
"=",
"$",
"this",
"->",
"getLinkInformation",
"(",
"[",
"$",
"menuItem",
"]",
")",
";",
"if",
"(",
"$",
"place",
"==",
"'left'",
")",
"{",
"$",
"arguments",
"[",
"$",
"argsCount",
"]",
"=",
"$",
"menuItem",
";",
"$",
"arraySubKey",
"=",
"$",
"this",
"->",
"getArrayKey",
"(",
"$",
"this",
"->",
"menuData",
"[",
"$",
"menuItem",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arraySubKey",
")",
"===",
"0",
")",
"{",
"$",
"output",
".=",
"'<li class=\"nav-item\">'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createNavLinkUrl",
"(",
"$",
"arguments",
")",
";",
"$",
"output",
".=",
"'</li>'",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"'<li class=\"nav-item dropdown\">'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createSubmenu",
"(",
"$",
"arguments",
",",
"$",
"this",
"->",
"menuData",
"[",
"$",
"menuItem",
"]",
")",
";",
"$",
"output",
".=",
"'</li>'",
";",
"}",
"}",
"}",
"$",
"output",
".=",
"'</ul>'",
";",
"return",
"$",
"output",
";",
"}"
] | 2.0 Creating Bootstrap's Left Menu
@return string | [
"2",
".",
"0",
"Creating",
"Bootstrap",
"s",
"Left",
"Menu"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L140-L163 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.createSubmenu | private function createSubmenu(array $arguments, array $subMenu): string
{
$argsCount = count($arguments);
$arrayKey = $this->getArrayKey($subMenu);
list($url, $text, $place, $id, $class) = $this->getLinkInformation($arguments);
$output = '<a class="nav-link dropdown-toggle';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="#" id="dropdown' . ++$this->numberSubmenu . '" role="button"';
$output .= ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
$output .= $text . '</a>';
$output .= '<ul class="dropdown-menu" aria-labelledby="dropdown' . $this->numberSubmenu . '">';
if ($this->options['overview']) $output .= $this->overviewUrl($url, $id, $class);
foreach ($arrayKey as $menuItem) {
$arguments[$argsCount] = $menuItem;
$arraySubKey = $this->getArrayKey($subMenu[$menuItem]);
if (count($arraySubKey) === 0) {
$output .= '<li>';
$output .= $this->createDropDownItemUrl($arguments);
$output .= '</li>';
} else {
$output .= '<li>';
$output .= $this->createDropDownItemSubUrl($arguments);
$output .= $this->createSubSubmenu($arguments, $subMenu[$menuItem]);
$output .= '</li>';
}
}
$output .= '</ul>';
return $output;
} | php | private function createSubmenu(array $arguments, array $subMenu): string
{
$argsCount = count($arguments);
$arrayKey = $this->getArrayKey($subMenu);
list($url, $text, $place, $id, $class) = $this->getLinkInformation($arguments);
$output = '<a class="nav-link dropdown-toggle';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="#" id="dropdown' . ++$this->numberSubmenu . '" role="button"';
$output .= ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
$output .= $text . '</a>';
$output .= '<ul class="dropdown-menu" aria-labelledby="dropdown' . $this->numberSubmenu . '">';
if ($this->options['overview']) $output .= $this->overviewUrl($url, $id, $class);
foreach ($arrayKey as $menuItem) {
$arguments[$argsCount] = $menuItem;
$arraySubKey = $this->getArrayKey($subMenu[$menuItem]);
if (count($arraySubKey) === 0) {
$output .= '<li>';
$output .= $this->createDropDownItemUrl($arguments);
$output .= '</li>';
} else {
$output .= '<li>';
$output .= $this->createDropDownItemSubUrl($arguments);
$output .= $this->createSubSubmenu($arguments, $subMenu[$menuItem]);
$output .= '</li>';
}
}
$output .= '</ul>';
return $output;
} | [
"private",
"function",
"createSubmenu",
"(",
"array",
"$",
"arguments",
",",
"array",
"$",
"subMenu",
")",
":",
"string",
"{",
"$",
"argsCount",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"$",
"arrayKey",
"=",
"$",
"this",
"->",
"getArrayKey",
"(",
"$",
"subMenu",
")",
";",
"list",
"(",
"$",
"url",
",",
"$",
"text",
",",
"$",
"place",
",",
"$",
"id",
",",
"$",
"class",
")",
"=",
"$",
"this",
"->",
"getLinkInformation",
"(",
"$",
"arguments",
")",
";",
"$",
"output",
"=",
"'<a class=\"nav-link dropdown-toggle'",
";",
"$",
"output",
"=",
"!",
"empty",
"(",
"$",
"class",
")",
"?",
"$",
"output",
".",
"' '",
".",
"$",
"class",
".",
"'\"'",
":",
"$",
"output",
".",
"'\"'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"$",
"output",
".=",
"' id=\"'",
".",
"$",
"id",
".",
"'\"'",
";",
"$",
"output",
".=",
"' href=\"#\" id=\"dropdown'",
".",
"++",
"$",
"this",
"->",
"numberSubmenu",
".",
"'\" role=\"button\"'",
";",
"$",
"output",
".=",
"' data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">'",
";",
"$",
"output",
".=",
"$",
"text",
".",
"'</a>'",
";",
"$",
"output",
".=",
"'<ul class=\"dropdown-menu\" aria-labelledby=\"dropdown'",
".",
"$",
"this",
"->",
"numberSubmenu",
".",
"'\">'",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'overview'",
"]",
")",
"$",
"output",
".=",
"$",
"this",
"->",
"overviewUrl",
"(",
"$",
"url",
",",
"$",
"id",
",",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"arrayKey",
"as",
"$",
"menuItem",
")",
"{",
"$",
"arguments",
"[",
"$",
"argsCount",
"]",
"=",
"$",
"menuItem",
";",
"$",
"arraySubKey",
"=",
"$",
"this",
"->",
"getArrayKey",
"(",
"$",
"subMenu",
"[",
"$",
"menuItem",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arraySubKey",
")",
"===",
"0",
")",
"{",
"$",
"output",
".=",
"'<li>'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createDropDownItemUrl",
"(",
"$",
"arguments",
")",
";",
"$",
"output",
".=",
"'</li>'",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"'<li>'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createDropDownItemSubUrl",
"(",
"$",
"arguments",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"createSubSubmenu",
"(",
"$",
"arguments",
",",
"$",
"subMenu",
"[",
"$",
"menuItem",
"]",
")",
";",
"$",
"output",
".=",
"'</li>'",
";",
"}",
"}",
"$",
"output",
".=",
"'</ul>'",
";",
"return",
"$",
"output",
";",
"}"
] | 4.0 Create the drop down submenu
@param array $arguments
@param array $subMenu
@return string | [
"4",
".",
"0",
"Create",
"the",
"drop",
"down",
"submenu"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L202-L231 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.createDropDownItemSubUrl | private function createDropDownItemSubUrl(array $args): string
{
list($url, $text, $place, $id, $class) = $this->getLinkInformation($args);
$output = '<a class="dropdown-item dropdown-toggle';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="' . BASE_URL . $url . '">' . $text . '</a>';
return $output;
} | php | private function createDropDownItemSubUrl(array $args): string
{
list($url, $text, $place, $id, $class) = $this->getLinkInformation($args);
$output = '<a class="dropdown-item dropdown-toggle';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="' . BASE_URL . $url . '">' . $text . '</a>';
return $output;
} | [
"private",
"function",
"createDropDownItemSubUrl",
"(",
"array",
"$",
"args",
")",
":",
"string",
"{",
"list",
"(",
"$",
"url",
",",
"$",
"text",
",",
"$",
"place",
",",
"$",
"id",
",",
"$",
"class",
")",
"=",
"$",
"this",
"->",
"getLinkInformation",
"(",
"$",
"args",
")",
";",
"$",
"output",
"=",
"'<a class=\"dropdown-item dropdown-toggle'",
";",
"$",
"output",
"=",
"!",
"empty",
"(",
"$",
"class",
")",
"?",
"$",
"output",
".",
"' '",
".",
"$",
"class",
".",
"'\"'",
":",
"$",
"output",
".",
"'\"'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"$",
"output",
".=",
"' id=\"'",
".",
"$",
"id",
".",
"'\"'",
";",
"$",
"output",
".=",
"' href=\"'",
".",
"BASE_URL",
".",
"$",
"url",
".",
"'\">'",
".",
"$",
"text",
".",
"'</a>'",
";",
"return",
"$",
"output",
";",
"}"
] | G.2 Create the URL for the dropdown-item
@param array $args
@return string | [
"G",
".",
"2",
"Create",
"the",
"URL",
"for",
"the",
"dropdown",
"-",
"item"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L303-L311 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.getLinkInformation | private function getLinkInformation(array $args): array
{
$arg = Menu::getIndexes($args);
$url = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['url'];
$text = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['text'];
$place = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['place'];
$id = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['id'];
$class = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['class'];
return [$url, $text, $place, $id, $class];
} | php | private function getLinkInformation(array $args): array
{
$arg = Menu::getIndexes($args);
$url = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['url'];
$text = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['text'];
$place = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['place'];
$id = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['id'];
$class = $this->menuData[$arg[0]][$arg[1]][$arg[2]][$arg[3]][$arg[4]][$arg[5]][$arg[6]][$arg[7]][$arg[8]][$arg[9]]['class'];
return [$url, $text, $place, $id, $class];
} | [
"private",
"function",
"getLinkInformation",
"(",
"array",
"$",
"args",
")",
":",
"array",
"{",
"$",
"arg",
"=",
"Menu",
"::",
"getIndexes",
"(",
"$",
"args",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"menuData",
"[",
"$",
"arg",
"[",
"0",
"]",
"]",
"[",
"$",
"arg",
"[",
"1",
"]",
"]",
"[",
"$",
"arg",
"[",
"2",
"]",
"]",
"[",
"$",
"arg",
"[",
"3",
"]",
"]",
"[",
"$",
"arg",
"[",
"4",
"]",
"]",
"[",
"$",
"arg",
"[",
"5",
"]",
"]",
"[",
"$",
"arg",
"[",
"6",
"]",
"]",
"[",
"$",
"arg",
"[",
"7",
"]",
"]",
"[",
"$",
"arg",
"[",
"8",
"]",
"]",
"[",
"$",
"arg",
"[",
"9",
"]",
"]",
"[",
"'url'",
"]",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"menuData",
"[",
"$",
"arg",
"[",
"0",
"]",
"]",
"[",
"$",
"arg",
"[",
"1",
"]",
"]",
"[",
"$",
"arg",
"[",
"2",
"]",
"]",
"[",
"$",
"arg",
"[",
"3",
"]",
"]",
"[",
"$",
"arg",
"[",
"4",
"]",
"]",
"[",
"$",
"arg",
"[",
"5",
"]",
"]",
"[",
"$",
"arg",
"[",
"6",
"]",
"]",
"[",
"$",
"arg",
"[",
"7",
"]",
"]",
"[",
"$",
"arg",
"[",
"8",
"]",
"]",
"[",
"$",
"arg",
"[",
"9",
"]",
"]",
"[",
"'text'",
"]",
";",
"$",
"place",
"=",
"$",
"this",
"->",
"menuData",
"[",
"$",
"arg",
"[",
"0",
"]",
"]",
"[",
"$",
"arg",
"[",
"1",
"]",
"]",
"[",
"$",
"arg",
"[",
"2",
"]",
"]",
"[",
"$",
"arg",
"[",
"3",
"]",
"]",
"[",
"$",
"arg",
"[",
"4",
"]",
"]",
"[",
"$",
"arg",
"[",
"5",
"]",
"]",
"[",
"$",
"arg",
"[",
"6",
"]",
"]",
"[",
"$",
"arg",
"[",
"7",
"]",
"]",
"[",
"$",
"arg",
"[",
"8",
"]",
"]",
"[",
"$",
"arg",
"[",
"9",
"]",
"]",
"[",
"'place'",
"]",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"menuData",
"[",
"$",
"arg",
"[",
"0",
"]",
"]",
"[",
"$",
"arg",
"[",
"1",
"]",
"]",
"[",
"$",
"arg",
"[",
"2",
"]",
"]",
"[",
"$",
"arg",
"[",
"3",
"]",
"]",
"[",
"$",
"arg",
"[",
"4",
"]",
"]",
"[",
"$",
"arg",
"[",
"5",
"]",
"]",
"[",
"$",
"arg",
"[",
"6",
"]",
"]",
"[",
"$",
"arg",
"[",
"7",
"]",
"]",
"[",
"$",
"arg",
"[",
"8",
"]",
"]",
"[",
"$",
"arg",
"[",
"9",
"]",
"]",
"[",
"'id'",
"]",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"menuData",
"[",
"$",
"arg",
"[",
"0",
"]",
"]",
"[",
"$",
"arg",
"[",
"1",
"]",
"]",
"[",
"$",
"arg",
"[",
"2",
"]",
"]",
"[",
"$",
"arg",
"[",
"3",
"]",
"]",
"[",
"$",
"arg",
"[",
"4",
"]",
"]",
"[",
"$",
"arg",
"[",
"5",
"]",
"]",
"[",
"$",
"arg",
"[",
"6",
"]",
"]",
"[",
"$",
"arg",
"[",
"7",
"]",
"]",
"[",
"$",
"arg",
"[",
"8",
"]",
"]",
"[",
"$",
"arg",
"[",
"9",
"]",
"]",
"[",
"'class'",
"]",
";",
"return",
"[",
"$",
"url",
",",
"$",
"text",
",",
"$",
"place",
",",
"$",
"id",
",",
"$",
"class",
"]",
";",
"}"
] | G.3 Get the menu information
@param array $args
@return array | [
"G",
".",
"3",
"Get",
"the",
"menu",
"information"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L319-L328 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.getArrayKey | private function getArrayKey(array $menuData): array
{
$arrayKey = array_keys($menuData);
$arrayKey = array_diff($arrayKey, $this->remove);
$arrayKey = array_values($arrayKey);
return $arrayKey;
} | php | private function getArrayKey(array $menuData): array
{
$arrayKey = array_keys($menuData);
$arrayKey = array_diff($arrayKey, $this->remove);
$arrayKey = array_values($arrayKey);
return $arrayKey;
} | [
"private",
"function",
"getArrayKey",
"(",
"array",
"$",
"menuData",
")",
":",
"array",
"{",
"$",
"arrayKey",
"=",
"array_keys",
"(",
"$",
"menuData",
")",
";",
"$",
"arrayKey",
"=",
"array_diff",
"(",
"$",
"arrayKey",
",",
"$",
"this",
"->",
"remove",
")",
";",
"$",
"arrayKey",
"=",
"array_values",
"(",
"$",
"arrayKey",
")",
";",
"return",
"$",
"arrayKey",
";",
"}"
] | G.4 Get the keys of the current level in the menu
@param array $menuData
@return array | [
"G",
".",
"4",
"Get",
"the",
"keys",
"of",
"the",
"current",
"level",
"in",
"the",
"menu"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L336-L342 | train |
RudyMas/Emvc_Menu | src/BootstrapMenu.php | BootstrapMenu.overviewUrl | private function overviewUrl(string $url, string $id, string $class): string
{
$output = '<li>';
$output .= '<a class="dropdown-item';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="' . $url . '">Overview</a>';
$output .= '</li>';
return $output;
} | php | private function overviewUrl(string $url, string $id, string $class): string
{
$output = '<li>';
$output .= '<a class="dropdown-item';
$output = !empty($class) ? $output . ' ' . $class . '"' : $output . '"';
if (!empty($id)) $output .= ' id="' . $id . '"';
$output .= ' href="' . $url . '">Overview</a>';
$output .= '</li>';
return $output;
} | [
"private",
"function",
"overviewUrl",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"id",
",",
"string",
"$",
"class",
")",
":",
"string",
"{",
"$",
"output",
"=",
"'<li>'",
";",
"$",
"output",
".=",
"'<a class=\"dropdown-item'",
";",
"$",
"output",
"=",
"!",
"empty",
"(",
"$",
"class",
")",
"?",
"$",
"output",
".",
"' '",
".",
"$",
"class",
".",
"'\"'",
":",
"$",
"output",
".",
"'\"'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"$",
"output",
".=",
"' id=\"'",
".",
"$",
"id",
".",
"'\"'",
";",
"$",
"output",
".=",
"' href=\"'",
".",
"$",
"url",
".",
"'\">Overview</a>'",
";",
"$",
"output",
".=",
"'</li>'",
";",
"return",
"$",
"output",
";",
"}"
] | G.5 Add Overview Menu option
@param string $url
@param string $id
@param string $class
@return string | [
"G",
".",
"5",
"Add",
"Overview",
"Menu",
"option"
] | 5765ec7e7193866de19e7a039a347ac4ed3bf952 | https://github.com/RudyMas/Emvc_Menu/blob/5765ec7e7193866de19e7a039a347ac4ed3bf952/src/BootstrapMenu.php#L352-L361 | train |
freialib/hlin.archetype | src/Trait/Logger.php | LoggerTrait.var_dump | function var_dump($message, $data) {
try {
$export = trim(str_replace("\n", "\n\t", var_export($data, true)), "\n\t ");
$this->log("$message\n\n\t$export\n");
}
catch (Exception $e) {
$this->failedLogging($e, $message);
}
} | php | function var_dump($message, $data) {
try {
$export = trim(str_replace("\n", "\n\t", var_export($data, true)), "\n\t ");
$this->log("$message\n\n\t$export\n");
}
catch (Exception $e) {
$this->failedLogging($e, $message);
}
} | [
"function",
"var_dump",
"(",
"$",
"message",
",",
"$",
"data",
")",
"{",
"try",
"{",
"$",
"export",
"=",
"trim",
"(",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\\t\"",
",",
"var_export",
"(",
"$",
"data",
",",
"true",
")",
")",
",",
"\"\\n\\t \"",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"$message\\n\\n\\t$export\\n\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"failedLogging",
"(",
"$",
"e",
",",
"$",
"message",
")",
";",
"}",
"}"
] | Save the data passed in as data. | [
"Save",
"the",
"data",
"passed",
"in",
"as",
"data",
"."
] | d8750a9bf4b7efb8063899969e3f39c1915c423a | https://github.com/freialib/hlin.archetype/blob/d8750a9bf4b7efb8063899969e3f39c1915c423a/src/Trait/Logger.php#L29-L37 | train |
freialib/hlin.archetype | src/Trait/Logger.php | LoggerTrait.becloud | protected function becloud($clear) {
if ($this->beclouding === null) {
return $clear;
}
else { // path replacements
$to_hide = [];
foreach ($this->beclouding as $key => $str) {
$to_hide[$str] = $key;
}
return strtr($clear, $to_hide);
}
} | php | protected function becloud($clear) {
if ($this->beclouding === null) {
return $clear;
}
else { // path replacements
$to_hide = [];
foreach ($this->beclouding as $key => $str) {
$to_hide[$str] = $key;
}
return strtr($clear, $to_hide);
}
} | [
"protected",
"function",
"becloud",
"(",
"$",
"clear",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"beclouding",
"===",
"null",
")",
"{",
"return",
"$",
"clear",
";",
"}",
"else",
"{",
"// path replacements",
"$",
"to_hide",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"beclouding",
"as",
"$",
"key",
"=>",
"$",
"str",
")",
"{",
"$",
"to_hide",
"[",
"$",
"str",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"strtr",
"(",
"$",
"clear",
",",
"$",
"to_hide",
")",
";",
"}",
"}"
] | This method is hook for implementation that can handle hiding, or
need hiding.
@return string beclouded version | [
"This",
"method",
"is",
"hook",
"for",
"implementation",
"that",
"can",
"handle",
"hiding",
"or",
"need",
"hiding",
"."
] | d8750a9bf4b7efb8063899969e3f39c1915c423a | https://github.com/freialib/hlin.archetype/blob/d8750a9bf4b7efb8063899969e3f39c1915c423a/src/Trait/Logger.php#L61-L72 | train |
PhoxPHP/Console | src/Environment.php | Environment.getText | public function getText(String $text=null, String $colour='green', String $backgroundColor='black')
{
$colours = [
'green' => Attributes::COLOR_GREEN,
'red' => Attributes::COLOR_RED,
'yellow' => Attributes::COLOR_YELLOW,
'blue' => Attributes::COLOR_BLUE,
'cyan' => Attributes::COLOR_CYAN,
'magenta' => Attributes::COLOR_MAGENTA,
'white' => Attributes::COLOR_WHITE,
];
$backgroundColors = [
'green' => Attributes::BG_GREEN,
'red' => Attributes::BG_RED,
'yellow' => Attributes::BG_YELLOW,
'blue' => Attributes::BG_BLUE,
'cyan' => Attributes::BG_CYAN,
'magenta' => Attributes::BG_MAGENTA,
'black' => Attributes::BG_BLACK,
];
if (isset($colours[$colour])) {
$text = $colours[$colour] . $text;
}
$text = $backgroundColors[$backgroundColor] . $text;
return $text . "\n";
} | php | public function getText(String $text=null, String $colour='green', String $backgroundColor='black')
{
$colours = [
'green' => Attributes::COLOR_GREEN,
'red' => Attributes::COLOR_RED,
'yellow' => Attributes::COLOR_YELLOW,
'blue' => Attributes::COLOR_BLUE,
'cyan' => Attributes::COLOR_CYAN,
'magenta' => Attributes::COLOR_MAGENTA,
'white' => Attributes::COLOR_WHITE,
];
$backgroundColors = [
'green' => Attributes::BG_GREEN,
'red' => Attributes::BG_RED,
'yellow' => Attributes::BG_YELLOW,
'blue' => Attributes::BG_BLUE,
'cyan' => Attributes::BG_CYAN,
'magenta' => Attributes::BG_MAGENTA,
'black' => Attributes::BG_BLACK,
];
if (isset($colours[$colour])) {
$text = $colours[$colour] . $text;
}
$text = $backgroundColors[$backgroundColor] . $text;
return $text . "\n";
} | [
"public",
"function",
"getText",
"(",
"String",
"$",
"text",
"=",
"null",
",",
"String",
"$",
"colour",
"=",
"'green'",
",",
"String",
"$",
"backgroundColor",
"=",
"'black'",
")",
"{",
"$",
"colours",
"=",
"[",
"'green'",
"=>",
"Attributes",
"::",
"COLOR_GREEN",
",",
"'red'",
"=>",
"Attributes",
"::",
"COLOR_RED",
",",
"'yellow'",
"=>",
"Attributes",
"::",
"COLOR_YELLOW",
",",
"'blue'",
"=>",
"Attributes",
"::",
"COLOR_BLUE",
",",
"'cyan'",
"=>",
"Attributes",
"::",
"COLOR_CYAN",
",",
"'magenta'",
"=>",
"Attributes",
"::",
"COLOR_MAGENTA",
",",
"'white'",
"=>",
"Attributes",
"::",
"COLOR_WHITE",
",",
"]",
";",
"$",
"backgroundColors",
"=",
"[",
"'green'",
"=>",
"Attributes",
"::",
"BG_GREEN",
",",
"'red'",
"=>",
"Attributes",
"::",
"BG_RED",
",",
"'yellow'",
"=>",
"Attributes",
"::",
"BG_YELLOW",
",",
"'blue'",
"=>",
"Attributes",
"::",
"BG_BLUE",
",",
"'cyan'",
"=>",
"Attributes",
"::",
"BG_CYAN",
",",
"'magenta'",
"=>",
"Attributes",
"::",
"BG_MAGENTA",
",",
"'black'",
"=>",
"Attributes",
"::",
"BG_BLACK",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"colours",
"[",
"$",
"colour",
"]",
")",
")",
"{",
"$",
"text",
"=",
"$",
"colours",
"[",
"$",
"colour",
"]",
".",
"$",
"text",
";",
"}",
"$",
"text",
"=",
"$",
"backgroundColors",
"[",
"$",
"backgroundColor",
"]",
".",
"$",
"text",
";",
"return",
"$",
"text",
".",
"\"\\n\"",
";",
"}"
] | Returns text with option to set the text colour.
@param $text <String>
@param $colour <String>
@param $backgroundColor <String>
@access public
@return <Mixed> | [
"Returns",
"text",
"with",
"option",
"to",
"set",
"the",
"text",
"colour",
"."
] | fee1238cfdb3592964bb5d5a2336e70b8ffd20e9 | https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Environment.php#L61-L90 | train |
PhoxPHP/Console | src/Environment.php | Environment.sendOutput | public function sendOutput(String $output, String $colour='white', String $backgroundColor='black')
{
fwrite(STDOUT, $this->getText($output, $colour, $backgroundColor));
} | php | public function sendOutput(String $output, String $colour='white', String $backgroundColor='black')
{
fwrite(STDOUT, $this->getText($output, $colour, $backgroundColor));
} | [
"public",
"function",
"sendOutput",
"(",
"String",
"$",
"output",
",",
"String",
"$",
"colour",
"=",
"'white'",
",",
"String",
"$",
"backgroundColor",
"=",
"'black'",
")",
"{",
"fwrite",
"(",
"STDOUT",
",",
"$",
"this",
"->",
"getText",
"(",
"$",
"output",
",",
"$",
"colour",
",",
"$",
"backgroundColor",
")",
")",
";",
"}"
] | Sends output to the environment.
@param $output <String>
@param $colour <String>
@param $backgroundColor <String>
@access public
@return <void> | [
"Sends",
"output",
"to",
"the",
"environment",
"."
] | fee1238cfdb3592964bb5d5a2336e70b8ffd20e9 | https://github.com/PhoxPHP/Console/blob/fee1238cfdb3592964bb5d5a2336e70b8ffd20e9/src/Environment.php#L134-L137 | train |
lasallecms/lasallecms-l5-lasallecmsemail-pkg | src/Repositories/Email_attachmentRepository.php | Email_attachmentRepository.getAlternatesortstring1ByUserId | public function getAlternatesortstring1ByUserId($userID) {
return DB::table('email_messages')
->join('email_attachments', 'email_messages.id', '=', 'email_attachments.email_messages_id')
->select('email_attachments.alternate_sort_string1')
->where('email_messages.user_id', '=', $userID)
->distinct()
->orderBy('email_attachments.alternate_sort_string1', 'desc')
->get()
;
} | php | public function getAlternatesortstring1ByUserId($userID) {
return DB::table('email_messages')
->join('email_attachments', 'email_messages.id', '=', 'email_attachments.email_messages_id')
->select('email_attachments.alternate_sort_string1')
->where('email_messages.user_id', '=', $userID)
->distinct()
->orderBy('email_attachments.alternate_sort_string1', 'desc')
->get()
;
} | [
"public",
"function",
"getAlternatesortstring1ByUserId",
"(",
"$",
"userID",
")",
"{",
"return",
"DB",
"::",
"table",
"(",
"'email_messages'",
")",
"->",
"join",
"(",
"'email_attachments'",
",",
"'email_messages.id'",
",",
"'='",
",",
"'email_attachments.email_messages_id'",
")",
"->",
"select",
"(",
"'email_attachments.alternate_sort_string1'",
")",
"->",
"where",
"(",
"'email_messages.user_id'",
",",
"'='",
",",
"$",
"userID",
")",
"->",
"distinct",
"(",
")",
"->",
"orderBy",
"(",
"'email_attachments.alternate_sort_string1'",
",",
"'desc'",
")",
"->",
"get",
"(",
")",
";",
"}"
] | Get a list of "alternatesortstring1" field values by user ID
@param int $userID
@return collection | [
"Get",
"a",
"list",
"of",
"alternatesortstring1",
"field",
"values",
"by",
"user",
"ID"
] | 95db5a59ab322105b9d3681cf9ab1f829c9fdb9f | https://github.com/lasallecms/lasallecms-l5-lasallecmsemail-pkg/blob/95db5a59ab322105b9d3681cf9ab1f829c9fdb9f/src/Repositories/Email_attachmentRepository.php#L102-L111 | train |
comodojo/foundation | src/Comodojo/Foundation/Utils/ErrorLevelConverter.php | ErrorLevelConverter.convert | public static function convert(int $error_code) {
return isset(self::$levels[$error_code]) ? self::$levels[$error_code] : "GENERIC_ERROR";
} | php | public static function convert(int $error_code) {
return isset(self::$levels[$error_code]) ? self::$levels[$error_code] : "GENERIC_ERROR";
} | [
"public",
"static",
"function",
"convert",
"(",
"int",
"$",
"error_code",
")",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"levels",
"[",
"$",
"error_code",
"]",
")",
"?",
"self",
"::",
"$",
"levels",
"[",
"$",
"error_code",
"]",
":",
"\"GENERIC_ERROR\"",
";",
"}"
] | Convert a PHP error level to its name
@param int $error_code
@return string | [
"Convert",
"a",
"PHP",
"error",
"level",
"to",
"its",
"name"
] | 21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a | https://github.com/comodojo/foundation/blob/21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a/src/Comodojo/Foundation/Utils/ErrorLevelConverter.php#L46-L50 | train |
AnonymPHP/Anonym-Database | Base.php | Base.errorInfo | public function errorInfo(){
if ($this->getConnection() instanceof PDO) {
$message = isset($this->connection->errorInfo()['message']) ? $this->getConnection()->errorInfo()['message'] : 'Something Went Wrong!';
} elseif ($this->getConnection() instanceof mysqli) {
$message = $this->getConnection()->error;
}
return $message;
} | php | public function errorInfo(){
if ($this->getConnection() instanceof PDO) {
$message = isset($this->connection->errorInfo()['message']) ? $this->getConnection()->errorInfo()['message'] : 'Something Went Wrong!';
} elseif ($this->getConnection() instanceof mysqli) {
$message = $this->getConnection()->error;
}
return $message;
} | [
"public",
"function",
"errorInfo",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
"instanceof",
"PDO",
")",
"{",
"$",
"message",
"=",
"isset",
"(",
"$",
"this",
"->",
"connection",
"->",
"errorInfo",
"(",
")",
"[",
"'message'",
"]",
")",
"?",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"errorInfo",
"(",
")",
"[",
"'message'",
"]",
":",
"'Something Went Wrong!'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
"instanceof",
"mysqli",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"error",
";",
"}",
"return",
"$",
"message",
";",
"}"
] | return the last query error
@return string | [
"return",
"the",
"last",
"query",
"error"
] | 4d034219e0e3eb2833fa53204e9f52a74a9a7e4b | https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Base.php#L174-L182 | train |
jacksleight/coast | library/App.php | App.dir | public function dir($path = null, $create = false)
{
if (!isset($this->_baseDir)) {
throw new App\Exception('Base directory not set');
}
return isset($path)
? $this->_baseDir->dir($path, $create)
: $this->_baseDir;
} | php | public function dir($path = null, $create = false)
{
if (!isset($this->_baseDir)) {
throw new App\Exception('Base directory not set');
}
return isset($path)
? $this->_baseDir->dir($path, $create)
: $this->_baseDir;
} | [
"public",
"function",
"dir",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"create",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_baseDir",
")",
")",
"{",
"throw",
"new",
"App",
"\\",
"Exception",
"(",
"'Base directory not set'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"path",
")",
"?",
"$",
"this",
"->",
"_baseDir",
"->",
"dir",
"(",
"$",
"path",
",",
"$",
"create",
")",
":",
"$",
"this",
"->",
"_baseDir",
";",
"}"
] | Get child directory.
@return Coast\Dir | [
"Get",
"child",
"directory",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L118-L126 | train |
jacksleight/coast | library/App.php | App.file | public function file($path)
{
if (!isset($this->_baseDir)) {
throw new App\Exception('Base directory not set');
}
return $this->_baseDir->file($path);
} | php | public function file($path)
{
if (!isset($this->_baseDir)) {
throw new App\Exception('Base directory not set');
}
return $this->_baseDir->file($path);
} | [
"public",
"function",
"file",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_baseDir",
")",
")",
"{",
"throw",
"new",
"App",
"\\",
"Exception",
"(",
"'Base directory not set'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_baseDir",
"->",
"file",
"(",
"$",
"path",
")",
";",
"}"
] | Get child file.
@return Coast\File | [
"Get",
"child",
"file",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L132-L138 | train |
jacksleight/coast | library/App.php | App.load | public function load($file, array $vars = array())
{
$file = !$file instanceof File
? new File("{$file}")
: $file;
$file = $file->isRelative()
? $this->file($file)
: $file;
return \Coast\load($file, array_merge(['app' => $this], $vars));
} | php | public function load($file, array $vars = array())
{
$file = !$file instanceof File
? new File("{$file}")
: $file;
$file = $file->isRelative()
? $this->file($file)
: $file;
return \Coast\load($file, array_merge(['app' => $this], $vars));
} | [
"public",
"function",
"load",
"(",
"$",
"file",
",",
"array",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"file",
"=",
"!",
"$",
"file",
"instanceof",
"File",
"?",
"new",
"File",
"(",
"\"{$file}\"",
")",
":",
"$",
"file",
";",
"$",
"file",
"=",
"$",
"file",
"->",
"isRelative",
"(",
")",
"?",
"$",
"this",
"->",
"file",
"(",
"$",
"file",
")",
":",
"$",
"file",
";",
"return",
"\\",
"Coast",
"\\",
"load",
"(",
"$",
"file",
",",
"array_merge",
"(",
"[",
"'app'",
"=>",
"$",
"this",
"]",
",",
"$",
"vars",
")",
")",
";",
"}"
] | Load a file without leaking variables, include app object in vars.
@param mixed $file
@param array $vars
@return mixed | [
"Load",
"a",
"file",
"without",
"leaking",
"variables",
"include",
"app",
"object",
"in",
"vars",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L146-L155 | train |
jacksleight/coast | library/App.php | App.lazy | public function lazy($source, array $vars = array())
{
if (is_string($source)) {
$source = new File("{$source}");
$source = $source->isRelative()
? $this->file($source)
: $source;
}
return new Lazy($source, array_merge(['app' => $this], $vars));
} | php | public function lazy($source, array $vars = array())
{
if (is_string($source)) {
$source = new File("{$source}");
$source = $source->isRelative()
? $this->file($source)
: $source;
}
return new Lazy($source, array_merge(['app' => $this], $vars));
} | [
"public",
"function",
"lazy",
"(",
"$",
"source",
",",
"array",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"$",
"source",
"=",
"new",
"File",
"(",
"\"{$source}\"",
")",
";",
"$",
"source",
"=",
"$",
"source",
"->",
"isRelative",
"(",
")",
"?",
"$",
"this",
"->",
"file",
"(",
"$",
"source",
")",
":",
"$",
"source",
";",
"}",
"return",
"new",
"Lazy",
"(",
"$",
"source",
",",
"array_merge",
"(",
"[",
"'app'",
"=>",
"$",
"this",
"]",
",",
"$",
"vars",
")",
")",
";",
"}"
] | Lazy load a file without leaking variables, include app object in vars.
@param mixed $file
@param array $vars
@return mixed | [
"Lazy",
"load",
"a",
"file",
"without",
"leaking",
"variables",
"include",
"app",
"object",
"in",
"vars",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L163-L172 | train |
jacksleight/coast | library/App.php | App.executable | public function executable($executable, $subpath = null)
{
if (!$executable instanceof Closure && !$executable instanceof Executable) {
throw new App\Exception("Object is not a closure or instance of Coast\App\Executable");
}
if (isset($subpath)) {
$executable = new App\Subpath($executable, $subpath);
} else if ($executable instanceof App || $executable instanceof Lazy) {
$executable->isSubapp(true);
}
array_push($this->_executables, $executable instanceof Closure
? $executable->bindTo($this)
: $executable);
return $this;
} | php | public function executable($executable, $subpath = null)
{
if (!$executable instanceof Closure && !$executable instanceof Executable) {
throw new App\Exception("Object is not a closure or instance of Coast\App\Executable");
}
if (isset($subpath)) {
$executable = new App\Subpath($executable, $subpath);
} else if ($executable instanceof App || $executable instanceof Lazy) {
$executable->isSubapp(true);
}
array_push($this->_executables, $executable instanceof Closure
? $executable->bindTo($this)
: $executable);
return $this;
} | [
"public",
"function",
"executable",
"(",
"$",
"executable",
",",
"$",
"subpath",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"executable",
"instanceof",
"Closure",
"&&",
"!",
"$",
"executable",
"instanceof",
"Executable",
")",
"{",
"throw",
"new",
"App",
"\\",
"Exception",
"(",
"\"Object is not a closure or instance of Coast\\App\\Executable\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"subpath",
")",
")",
"{",
"$",
"executable",
"=",
"new",
"App",
"\\",
"Subpath",
"(",
"$",
"executable",
",",
"$",
"subpath",
")",
";",
"}",
"else",
"if",
"(",
"$",
"executable",
"instanceof",
"App",
"||",
"$",
"executable",
"instanceof",
"Lazy",
")",
"{",
"$",
"executable",
"->",
"isSubapp",
"(",
"true",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"_executables",
",",
"$",
"executable",
"instanceof",
"Closure",
"?",
"$",
"executable",
"->",
"bindTo",
"(",
"$",
"this",
")",
":",
"$",
"executable",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add executable to the stack.
@param string $name
@param Closure|Coast\App\Executable $value
@return self | [
"Add",
"executable",
"to",
"the",
"stack",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L255-L269 | train |
jacksleight/coast | library/App.php | App.execute | public function execute(Request $req = null, Response $res = null)
{
$auto = false;
if (!isset($req)) {
$auto = true;
$req = (new Request())->fromGlobals();
$res = (new Response($req));
} else if (!isset($res)) {
throw new App\Exception('You must pass a Response object when passing a Request object');
}
$this->param('req', $req)
->param('res', $res);
try {
$this->preExecute($req, $res);
foreach ($this->_executables as $executable) {
if ($executable instanceof Executable && !$executable instanceof App) {
$executable->preExecute($req, $res);
}
}
$result = null;
foreach ($this->_executables as $executable) {
$result = call_user_func($executable instanceof Executable
? [$executable, 'execute']
: $executable, $req, $res);
if (isset($result)) {
break;
}
}
if (!$result && !$this->_isSubapp) {
if (isset($this->_failureHandler)) {
$result = call_user_func($this->_failureHandler, $req, $res);
} else {
throw new App\Exception('Nothing successfully handled the request');
}
}
foreach ($this->_executables as $executable) {
if ($executable instanceof Executable && !$executable instanceof App) {
$executable->postExecute($req, $res);
}
}
$this->postExecute($req, $res);
} catch (\Exception $e) {
if (isset($this->_errorHandler)) {
$result = call_user_func($this->_errorHandler, $req, $res, $e);
} else {
throw $e;
}
}
$this->param('req', null)
->param('res', null);
if ($auto) {
$res->toGlobals();
} else {
return $result;
}
} | php | public function execute(Request $req = null, Response $res = null)
{
$auto = false;
if (!isset($req)) {
$auto = true;
$req = (new Request())->fromGlobals();
$res = (new Response($req));
} else if (!isset($res)) {
throw new App\Exception('You must pass a Response object when passing a Request object');
}
$this->param('req', $req)
->param('res', $res);
try {
$this->preExecute($req, $res);
foreach ($this->_executables as $executable) {
if ($executable instanceof Executable && !$executable instanceof App) {
$executable->preExecute($req, $res);
}
}
$result = null;
foreach ($this->_executables as $executable) {
$result = call_user_func($executable instanceof Executable
? [$executable, 'execute']
: $executable, $req, $res);
if (isset($result)) {
break;
}
}
if (!$result && !$this->_isSubapp) {
if (isset($this->_failureHandler)) {
$result = call_user_func($this->_failureHandler, $req, $res);
} else {
throw new App\Exception('Nothing successfully handled the request');
}
}
foreach ($this->_executables as $executable) {
if ($executable instanceof Executable && !$executable instanceof App) {
$executable->postExecute($req, $res);
}
}
$this->postExecute($req, $res);
} catch (\Exception $e) {
if (isset($this->_errorHandler)) {
$result = call_user_func($this->_errorHandler, $req, $res, $e);
} else {
throw $e;
}
}
$this->param('req', null)
->param('res', null);
if ($auto) {
$res->toGlobals();
} else {
return $result;
}
} | [
"public",
"function",
"execute",
"(",
"Request",
"$",
"req",
"=",
"null",
",",
"Response",
"$",
"res",
"=",
"null",
")",
"{",
"$",
"auto",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"req",
")",
")",
"{",
"$",
"auto",
"=",
"true",
";",
"$",
"req",
"=",
"(",
"new",
"Request",
"(",
")",
")",
"->",
"fromGlobals",
"(",
")",
";",
"$",
"res",
"=",
"(",
"new",
"Response",
"(",
"$",
"req",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"isset",
"(",
"$",
"res",
")",
")",
"{",
"throw",
"new",
"App",
"\\",
"Exception",
"(",
"'You must pass a Response object when passing a Request object'",
")",
";",
"}",
"$",
"this",
"->",
"param",
"(",
"'req'",
",",
"$",
"req",
")",
"->",
"param",
"(",
"'res'",
",",
"$",
"res",
")",
";",
"try",
"{",
"$",
"this",
"->",
"preExecute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_executables",
"as",
"$",
"executable",
")",
"{",
"if",
"(",
"$",
"executable",
"instanceof",
"Executable",
"&&",
"!",
"$",
"executable",
"instanceof",
"App",
")",
"{",
"$",
"executable",
"->",
"preExecute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"}",
"$",
"result",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_executables",
"as",
"$",
"executable",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"executable",
"instanceof",
"Executable",
"?",
"[",
"$",
"executable",
",",
"'execute'",
"]",
":",
"$",
"executable",
",",
"$",
"req",
",",
"$",
"res",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
")",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"result",
"&&",
"!",
"$",
"this",
"->",
"_isSubapp",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_failureHandler",
")",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"_failureHandler",
",",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"App",
"\\",
"Exception",
"(",
"'Nothing successfully handled the request'",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_executables",
"as",
"$",
"executable",
")",
"{",
"if",
"(",
"$",
"executable",
"instanceof",
"Executable",
"&&",
"!",
"$",
"executable",
"instanceof",
"App",
")",
"{",
"$",
"executable",
"->",
"postExecute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"}",
"$",
"this",
"->",
"postExecute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_errorHandler",
")",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"_errorHandler",
",",
"$",
"req",
",",
"$",
"res",
",",
"$",
"e",
")",
";",
"}",
"else",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"$",
"this",
"->",
"param",
"(",
"'req'",
",",
"null",
")",
"->",
"param",
"(",
"'res'",
",",
"null",
")",
";",
"if",
"(",
"$",
"auto",
")",
"{",
"$",
"res",
"->",
"toGlobals",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"result",
";",
"}",
"}"
] | Execute the application, running middleware in order.
@param Coast\Request $req Request object.
@param Coast\Response $res Response object. | [
"Execute",
"the",
"application",
"running",
"middleware",
"in",
"order",
"."
] | cd6cd41e8304adce41f59f799d4183adcaf666f9 | https://github.com/jacksleight/coast/blob/cd6cd41e8304adce41f59f799d4183adcaf666f9/library/App.php#L276-L333 | train |
wasinger/adaptimage | src/ImageResizeDefinition.php | ImageResizeDefinition.addPostFilter | public function addPostFilter(FilterInterface $filter, $priority = 0)
{
$this->post_transformation->add($filter, $priority);
return $this;
} | php | public function addPostFilter(FilterInterface $filter, $priority = 0)
{
$this->post_transformation->add($filter, $priority);
return $this;
} | [
"public",
"function",
"addPostFilter",
"(",
"FilterInterface",
"$",
"filter",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"post_transformation",
"->",
"add",
"(",
"$",
"filter",
",",
"$",
"priority",
")",
";",
"return",
"$",
"this",
";",
"}"
] | add a post-processing filter to be always executed
This filter will ALWAYS be executed no matter whether the image has
actually been resized or not. Usefull e.g. for Strip or Monochrome filter.
@param FilterInterface $filter
@param int $priority
@return $this | [
"add",
"a",
"post",
"-",
"processing",
"filter",
"to",
"be",
"always",
"executed"
] | 7b529b25081b399451c8bbd56d0cef7daaa83ec4 | https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/ImageResizeDefinition.php#L148-L152 | train |
wasinger/adaptimage | src/ImageResizeDefinition.php | ImageResizeDefinition.create | static function create($width, $height = 0, $mode = ImageResizeDefinition::MODE_MAX, $upscale = false)
{
return new static($width, $height, $mode, $upscale);
} | php | static function create($width, $height = 0, $mode = ImageResizeDefinition::MODE_MAX, $upscale = false)
{
return new static($width, $height, $mode, $upscale);
} | [
"static",
"function",
"create",
"(",
"$",
"width",
",",
"$",
"height",
"=",
"0",
",",
"$",
"mode",
"=",
"ImageResizeDefinition",
"::",
"MODE_MAX",
",",
"$",
"upscale",
"=",
"false",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"mode",
",",
"$",
"upscale",
")",
";",
"}"
] | Create an ImageResizeDefinition instance
@param int $width The width of the new size
@param int $height The height of the new size.
If set to 0 (default), it will be set to the same value as width.
If set to ImageResizeDefinition::HEIGHT_UNRESTRICTED, height will not be restricted.
@param string $mode one of the ImageResizeDefinition::MODE_* constants, i.e. 'max', 'min', or 'crop'
@param bool $upscale Should the image be upscaled if it is smaller than the new size?
@return ImageResizeDefinition | [
"Create",
"an",
"ImageResizeDefinition",
"instance"
] | 7b529b25081b399451c8bbd56d0cef7daaa83ec4 | https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/ImageResizeDefinition.php#L231-L234 | train |
prolic/HumusSupervisorModule | src/HumusSupervisorModule/Module.php | Module.onBootstrap | public function onBootstrap(EventInterface $e)
{
/* @var $e \Zend\Mvc\MvcEvent */
$serviceManager = $e->getApplication()->getServiceManager();
/* @var $serviceManager \Zend\ServiceManager\ServiceManager */
$this->initPluginManagerFactory(
$serviceManager,
__NAMESPACE__ . '\SupervisorManager',
'supervisor_plugin_manager'
);
$this->initPluginManagerFactory(
$serviceManager,
__NAMESPACE__ . '\ListenerManager',
'listener_plugin_manager'
);
} | php | public function onBootstrap(EventInterface $e)
{
/* @var $e \Zend\Mvc\MvcEvent */
$serviceManager = $e->getApplication()->getServiceManager();
/* @var $serviceManager \Zend\ServiceManager\ServiceManager */
$this->initPluginManagerFactory(
$serviceManager,
__NAMESPACE__ . '\SupervisorManager',
'supervisor_plugin_manager'
);
$this->initPluginManagerFactory(
$serviceManager,
__NAMESPACE__ . '\ListenerManager',
'listener_plugin_manager'
);
} | [
"public",
"function",
"onBootstrap",
"(",
"EventInterface",
"$",
"e",
")",
"{",
"/* @var $e \\Zend\\Mvc\\MvcEvent */",
"$",
"serviceManager",
"=",
"$",
"e",
"->",
"getApplication",
"(",
")",
"->",
"getServiceManager",
"(",
")",
";",
"/* @var $serviceManager \\Zend\\ServiceManager\\ServiceManager */",
"$",
"this",
"->",
"initPluginManagerFactory",
"(",
"$",
"serviceManager",
",",
"__NAMESPACE__",
".",
"'\\SupervisorManager'",
",",
"'supervisor_plugin_manager'",
")",
";",
"$",
"this",
"->",
"initPluginManagerFactory",
"(",
"$",
"serviceManager",
",",
"__NAMESPACE__",
".",
"'\\ListenerManager'",
",",
"'listener_plugin_manager'",
")",
";",
"}"
] | Bootstrap the module
Register the supervisor plugin manager
@param EventInterface $e
@return array | [
"Bootstrap",
"the",
"module"
] | b71a7508d9737dbda1ad3b0a1374ed70b77070bd | https://github.com/prolic/HumusSupervisorModule/blob/b71a7508d9737dbda1ad3b0a1374ed70b77070bd/src/HumusSupervisorModule/Module.php#L57-L74 | train |
itcreator/custom-cmf | Module/Language/src/Cmf/Language/Container.php | Container.get | protected function get($name)
{
$this->load();
return isset($this->lng[$name]) ? $this->lng[$name] : $name;
} | php | protected function get($name)
{
$this->load();
return isset($this->lng[$name]) ? $this->lng[$name] : $name;
} | [
"protected",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"lng",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"lng",
"[",
"$",
"name",
"]",
":",
"$",
"name",
";",
"}"
] | get language Value
@param string $name
@return mixed | [
"get",
"language",
"Value"
] | 42fc0535dfa0f641856f06673f6ab596b2020c40 | https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Language/src/Cmf/Language/Container.php#L65-L70 | train |
frodosghost/AtomLoggerBundle | Log/AtomLogger.php | AtomLogger.message | public function message($message, $level, $level_name, $channel, $datetime)
{
$datetime->setTimezone(new \DateTimeZone('UTC'));
$this->request->setData(array(
'message' => $message,
'status_code' => $level,
'status_name' => $level_name,
'channel' => $channel,
'created_utc' => $datetime->format('Y-m-d H:i:s')
));
try {
$this->client->send($this->request);
} catch (FormattingException $e) {
}
} | php | public function message($message, $level, $level_name, $channel, $datetime)
{
$datetime->setTimezone(new \DateTimeZone('UTC'));
$this->request->setData(array(
'message' => $message,
'status_code' => $level,
'status_name' => $level_name,
'channel' => $channel,
'created_utc' => $datetime->format('Y-m-d H:i:s')
));
try {
$this->client->send($this->request);
} catch (FormattingException $e) {
}
} | [
"public",
"function",
"message",
"(",
"$",
"message",
",",
"$",
"level",
",",
"$",
"level_name",
",",
"$",
"channel",
",",
"$",
"datetime",
")",
"{",
"$",
"datetime",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"this",
"->",
"request",
"->",
"setData",
"(",
"array",
"(",
"'message'",
"=>",
"$",
"message",
",",
"'status_code'",
"=>",
"$",
"level",
",",
"'status_name'",
"=>",
"$",
"level_name",
",",
"'channel'",
"=>",
"$",
"channel",
",",
"'created_utc'",
"=>",
"$",
"datetime",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"this",
"->",
"request",
")",
";",
"}",
"catch",
"(",
"FormattingException",
"$",
"e",
")",
"{",
"}",
"}"
] | Build message to send to AtomLogger
@param string $message
@param integer $level
@param string $level_name
@param string $channel
@param \DateTime $datetime | [
"Build",
"message",
"to",
"send",
"to",
"AtomLogger"
] | c48823e4b3772e498b366867f27e6581f613f733 | https://github.com/frodosghost/AtomLoggerBundle/blob/c48823e4b3772e498b366867f27e6581f613f733/Log/AtomLogger.php#L48-L65 | train |
JumpGateio/Core | src/JumpGate/Core/Http/Routes/BaseRoute.php | BaseRoute.getContext | public function getContext($name = null)
{
if (is_null($name)) {
$name = $this->context;
}
return isset($this->contexts[$name]) ? $this->contexts[$name] : null;
} | php | public function getContext($name = null)
{
if (is_null($name)) {
$name = $this->context;
}
return isset($this->contexts[$name]) ? $this->contexts[$name] : null;
} | [
"public",
"function",
"getContext",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"context",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"contexts",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"contexts",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Get a context URI from the array.
@param string|null $name
@return string | [
"Get",
"a",
"context",
"URI",
"from",
"the",
"array",
"."
] | 485b5cf03b3072267bffbee428b81e48d407d6b6 | https://github.com/JumpGateio/Core/blob/485b5cf03b3072267bffbee428b81e48d407d6b6/src/JumpGate/Core/Http/Routes/BaseRoute.php#L72-L79 | train |
JumpGateio/Core | src/JumpGate/Core/Http/Routes/BaseRoute.php | BaseRoute.getPrefix | public function getPrefix()
{
$prefix = null;
if (! is_null($this->getContext())) {
$prefix = $this->getContext();
}
if (! is_string($this->prefix)) {
return $prefix;
}
return $prefix . $this->prefix;
} | php | public function getPrefix()
{
$prefix = null;
if (! is_null($this->getContext())) {
$prefix = $this->getContext();
}
if (! is_string($this->prefix)) {
return $prefix;
}
return $prefix . $this->prefix;
} | [
"public",
"function",
"getPrefix",
"(",
")",
"{",
"$",
"prefix",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getContext",
"(",
")",
")",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"return",
"$",
"prefix",
";",
"}",
"return",
"$",
"prefix",
".",
"$",
"this",
"->",
"prefix",
";",
"}"
] | Get the prefix for this route group.
@return string|null | [
"Get",
"the",
"prefix",
"for",
"this",
"route",
"group",
"."
] | 485b5cf03b3072267bffbee428b81e48d407d6b6 | https://github.com/JumpGateio/Core/blob/485b5cf03b3072267bffbee428b81e48d407d6b6/src/JumpGate/Core/Http/Routes/BaseRoute.php#L100-L113 | train |
g4code/buffer | src/Buffer.php | Buffer._overflowHandler | protected function _overflowHandler() {
return $this->_getAdapter()->overflow(
$this->_cacheKey,
$this->getUsage() - $this->getSize() + 1,
$this->getUsage()
);
} | php | protected function _overflowHandler() {
return $this->_getAdapter()->overflow(
$this->_cacheKey,
$this->getUsage() - $this->getSize() + 1,
$this->getUsage()
);
} | [
"protected",
"function",
"_overflowHandler",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"_getAdapter",
"(",
")",
"->",
"overflow",
"(",
"$",
"this",
"->",
"_cacheKey",
",",
"$",
"this",
"->",
"getUsage",
"(",
")",
"-",
"$",
"this",
"->",
"getSize",
"(",
")",
"+",
"1",
",",
"$",
"this",
"->",
"getUsage",
"(",
")",
")",
";",
"}"
] | Buffer overflow handler
@param void
@return boolean | [
"Buffer",
"overflow",
"handler"
] | 2f98fe8681f337095aac60542e31ca9034a795be | https://github.com/g4code/buffer/blob/2f98fe8681f337095aac60542e31ca9034a795be/src/Buffer.php#L131-L137 | train |
g4code/buffer | src/Buffer.php | Buffer.add | public function add($data)
{
if(empty($data) || !$this->_getAdapter()->isClientConnected()) {
return false;
}
if(!$this->_getAdapter()->add($this->_cacheKey, json_encode($data))) {
return false;
}
// overflow handling
if($this->getUsage() >= $this->getSize()) {
if (!empty ($this->_overflowCallback) && is_callable ($this->_overflowCallback)) {
call_user_func_array ($this->_overflowCallback, array ($this->readAndFlush()));
} else {
$this->_overflowHandler();
}
}
} | php | public function add($data)
{
if(empty($data) || !$this->_getAdapter()->isClientConnected()) {
return false;
}
if(!$this->_getAdapter()->add($this->_cacheKey, json_encode($data))) {
return false;
}
// overflow handling
if($this->getUsage() >= $this->getSize()) {
if (!empty ($this->_overflowCallback) && is_callable ($this->_overflowCallback)) {
call_user_func_array ($this->_overflowCallback, array ($this->readAndFlush()));
} else {
$this->_overflowHandler();
}
}
} | [
"public",
"function",
"add",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
"||",
"!",
"$",
"this",
"->",
"_getAdapter",
"(",
")",
"->",
"isClientConnected",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_getAdapter",
"(",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"_cacheKey",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// overflow handling",
"if",
"(",
"$",
"this",
"->",
"getUsage",
"(",
")",
">=",
"$",
"this",
"->",
"getSize",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_overflowCallback",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"_overflowCallback",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"_overflowCallback",
",",
"array",
"(",
"$",
"this",
"->",
"readAndFlush",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_overflowHandler",
"(",
")",
";",
"}",
"}",
"}"
] | Add data to buffer
@param mixed $data
@return boolean | [
"Add",
"data",
"to",
"buffer"
] | 2f98fe8681f337095aac60542e31ca9034a795be | https://github.com/g4code/buffer/blob/2f98fe8681f337095aac60542e31ca9034a795be/src/Buffer.php#L145-L164 | train |
g4code/buffer | src/Buffer.php | Buffer.read | public function read()
{
$data = $this->_getAdapter()->read($this->_cacheKey);
if(!empty($data) && is_array($data)) {
foreach($data as &$row) { // @todo: check what to do with this
$row = json_decode($row, 1);
}
}
return $data;
} | php | public function read()
{
$data = $this->_getAdapter()->read($this->_cacheKey);
if(!empty($data) && is_array($data)) {
foreach($data as &$row) { // @todo: check what to do with this
$row = json_decode($row, 1);
}
}
return $data;
} | [
"public",
"function",
"read",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_getAdapter",
"(",
")",
"->",
"read",
"(",
"$",
"this",
"->",
"_cacheKey",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
"&&",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"row",
")",
"{",
"// @todo: check what to do with this",
"$",
"row",
"=",
"json_decode",
"(",
"$",
"row",
",",
"1",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] | Read data from buffer
@todo: remove json encode from buffer, move it to adapter
@return mixed | [
"Read",
"data",
"from",
"buffer"
] | 2f98fe8681f337095aac60542e31ca9034a795be | https://github.com/g4code/buffer/blob/2f98fe8681f337095aac60542e31ca9034a795be/src/Buffer.php#L173-L184 | train |
e-commit/EcommitUtilBundle | Doctrine/ClearEntityManager.php | ClearEntityManager.clearEntityManager | public function clearEntityManager($managerName = null)
{
if (null === $this->doctrine) {
throw new \Exception('Doctrine is required');
}
if (null === $managerName) {
$managerName = $this->doctrine->getDefaultConnectionName();
}
if (!array_key_exists($managerName, $this->snapshots)) {
throw new \Exception('The snapshot was not done');
}
$snapshot = $this->snapshots[$managerName];
$em = $this->doctrine->getManager($managerName);
$identityMap = $em->getUnitOfWork()->getIdentityMap();
foreach ($identityMap as $class => $objects) {
foreach ($objects as $id => $object) {
if (!array_key_exists($class, $snapshot) || !array_key_exists($id, $snapshot[$class])) {
$em->detach($object);
}
}
}
} | php | public function clearEntityManager($managerName = null)
{
if (null === $this->doctrine) {
throw new \Exception('Doctrine is required');
}
if (null === $managerName) {
$managerName = $this->doctrine->getDefaultConnectionName();
}
if (!array_key_exists($managerName, $this->snapshots)) {
throw new \Exception('The snapshot was not done');
}
$snapshot = $this->snapshots[$managerName];
$em = $this->doctrine->getManager($managerName);
$identityMap = $em->getUnitOfWork()->getIdentityMap();
foreach ($identityMap as $class => $objects) {
foreach ($objects as $id => $object) {
if (!array_key_exists($class, $snapshot) || !array_key_exists($id, $snapshot[$class])) {
$em->detach($object);
}
}
}
} | [
"public",
"function",
"clearEntityManager",
"(",
"$",
"managerName",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"doctrine",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Doctrine is required'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"managerName",
")",
"{",
"$",
"managerName",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getDefaultConnectionName",
"(",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"managerName",
",",
"$",
"this",
"->",
"snapshots",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The snapshot was not done'",
")",
";",
"}",
"$",
"snapshot",
"=",
"$",
"this",
"->",
"snapshots",
"[",
"$",
"managerName",
"]",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
"$",
"managerName",
")",
";",
"$",
"identityMap",
"=",
"$",
"em",
"->",
"getUnitOfWork",
"(",
")",
"->",
"getIdentityMap",
"(",
")",
";",
"foreach",
"(",
"$",
"identityMap",
"as",
"$",
"class",
"=>",
"$",
"objects",
")",
"{",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"id",
"=>",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"class",
",",
"$",
"snapshot",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"snapshot",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"em",
"->",
"detach",
"(",
"$",
"object",
")",
";",
"}",
"}",
"}",
"}"
] | Detach all objects in EntityManager persisted since snapshot
@param string|null $managerName | [
"Detach",
"all",
"objects",
"in",
"EntityManager",
"persisted",
"since",
"snapshot"
] | 2ee5ddae7709e8ad4412739cbecda28e0590da8b | https://github.com/e-commit/EcommitUtilBundle/blob/2ee5ddae7709e8ad4412739cbecda28e0590da8b/Doctrine/ClearEntityManager.php#L53-L76 | train |
leogitpro/php-zf3-base-module | module/src/Module.php | Module.onBootstrap | public function onBootstrap(MvcEvent $event)
{
$sharedEventManager = $event->getApplication()->getEventManager()->getSharedManager();
$sharedEventManager->attach(
AbstractActionController::class,
MvcEvent::EVENT_DISPATCH,
[$this, 'onDispatchedListener'],
self::DISPATCH_PRIORITY
);
} | php | public function onBootstrap(MvcEvent $event)
{
$sharedEventManager = $event->getApplication()->getEventManager()->getSharedManager();
$sharedEventManager->attach(
AbstractActionController::class,
MvcEvent::EVENT_DISPATCH,
[$this, 'onDispatchedListener'],
self::DISPATCH_PRIORITY
);
} | [
"public",
"function",
"onBootstrap",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"$",
"sharedEventManager",
"=",
"$",
"event",
"->",
"getApplication",
"(",
")",
"->",
"getEventManager",
"(",
")",
"->",
"getSharedManager",
"(",
")",
";",
"$",
"sharedEventManager",
"->",
"attach",
"(",
"AbstractActionController",
"::",
"class",
",",
"MvcEvent",
"::",
"EVENT_DISPATCH",
",",
"[",
"$",
"this",
",",
"'onDispatchedListener'",
"]",
",",
"self",
"::",
"DISPATCH_PRIORITY",
")",
";",
"}"
] | Module bootstrap handler
@param MvcEvent $event | [
"Module",
"bootstrap",
"handler"
] | 596fc89c25033eaef8f796418a4a3399c47a9638 | https://github.com/leogitpro/php-zf3-base-module/blob/596fc89c25033eaef8f796418a4a3399c47a9638/module/src/Module.php#L33-L42 | train |
leogitpro/php-zf3-base-module | module/src/Module.php | Module.getControllerPluginConfig | public function getControllerPluginConfig()
{
return [
'factories' => [
Controller\Plugin\Config::class => Controller\Plugin\Factory\ConfigFactory::class,
Controller\Plugin\Env::class => Controller\Plugin\Factory\EnvFactory::class,
Controller\Plugin\Server::class => Controller\Plugin\Factory\ServerFactory::class,
],
'aliases' => [
'pluginConfig' => Controller\Plugin\Config::class,
'pluginEnv' => Controller\Plugin\Env::class,
'pluginServer' => Controller\Plugin\Server::class,
],
];
} | php | public function getControllerPluginConfig()
{
return [
'factories' => [
Controller\Plugin\Config::class => Controller\Plugin\Factory\ConfigFactory::class,
Controller\Plugin\Env::class => Controller\Plugin\Factory\EnvFactory::class,
Controller\Plugin\Server::class => Controller\Plugin\Factory\ServerFactory::class,
],
'aliases' => [
'pluginConfig' => Controller\Plugin\Config::class,
'pluginEnv' => Controller\Plugin\Env::class,
'pluginServer' => Controller\Plugin\Server::class,
],
];
} | [
"public",
"function",
"getControllerPluginConfig",
"(",
")",
"{",
"return",
"[",
"'factories'",
"=>",
"[",
"Controller",
"\\",
"Plugin",
"\\",
"Config",
"::",
"class",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Factory",
"\\",
"ConfigFactory",
"::",
"class",
",",
"Controller",
"\\",
"Plugin",
"\\",
"Env",
"::",
"class",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Factory",
"\\",
"EnvFactory",
"::",
"class",
",",
"Controller",
"\\",
"Plugin",
"\\",
"Server",
"::",
"class",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Factory",
"\\",
"ServerFactory",
"::",
"class",
",",
"]",
",",
"'aliases'",
"=>",
"[",
"'pluginConfig'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Config",
"::",
"class",
",",
"'pluginEnv'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Env",
"::",
"class",
",",
"'pluginServer'",
"=>",
"Controller",
"\\",
"Plugin",
"\\",
"Server",
"::",
"class",
",",
"]",
",",
"]",
";",
"}"
] | Configuration controller plugin
@return array | [
"Configuration",
"controller",
"plugin"
] | 596fc89c25033eaef8f796418a4a3399c47a9638 | https://github.com/leogitpro/php-zf3-base-module/blob/596fc89c25033eaef8f796418a4a3399c47a9638/module/src/Module.php#L254-L268 | train |
leogitpro/php-zf3-base-module | module/src/Module.php | Module.getViewHelperConfig | public function getViewHelperConfig()
{
return [
'factories' => [
View\Helper\Params::class => View\Helper\Factory\ParamsFactory::class,
View\Helper\Config::class => View\Helper\Factory\ConfigFactory::class,
View\Helper\Env::class => View\Helper\Factory\EnvFactory::class,
View\Helper\CdnVersion::class => View\Helper\Factory\EnvFactory::class,
View\Helper\FormLocalMessage::class => InvokableFactory::class,
//\Zend\Form\View\Helper\FormElementErrors::class => View\Helper\Factory\FormElementErrorsFactory::class,
],
'aliases' => [
'helperParams' => View\Helper\Params::class,
'helperConfig' => View\Helper\Config::class,
'helperEnv' => View\Helper\Env::class,
'helperCdnVersion' => View\Helper\CdnVersion::class,
'formLocalMessage' => View\Helper\FormLocalMessage::class,
'helperFormLocalMessage' => View\Helper\FormLocalMessage::class,
],
];
} | php | public function getViewHelperConfig()
{
return [
'factories' => [
View\Helper\Params::class => View\Helper\Factory\ParamsFactory::class,
View\Helper\Config::class => View\Helper\Factory\ConfigFactory::class,
View\Helper\Env::class => View\Helper\Factory\EnvFactory::class,
View\Helper\CdnVersion::class => View\Helper\Factory\EnvFactory::class,
View\Helper\FormLocalMessage::class => InvokableFactory::class,
//\Zend\Form\View\Helper\FormElementErrors::class => View\Helper\Factory\FormElementErrorsFactory::class,
],
'aliases' => [
'helperParams' => View\Helper\Params::class,
'helperConfig' => View\Helper\Config::class,
'helperEnv' => View\Helper\Env::class,
'helperCdnVersion' => View\Helper\CdnVersion::class,
'formLocalMessage' => View\Helper\FormLocalMessage::class,
'helperFormLocalMessage' => View\Helper\FormLocalMessage::class,
],
];
} | [
"public",
"function",
"getViewHelperConfig",
"(",
")",
"{",
"return",
"[",
"'factories'",
"=>",
"[",
"View",
"\\",
"Helper",
"\\",
"Params",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"Factory",
"\\",
"ParamsFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"Config",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"Factory",
"\\",
"ConfigFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"Env",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"Factory",
"\\",
"EnvFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"CdnVersion",
"::",
"class",
"=>",
"View",
"\\",
"Helper",
"\\",
"Factory",
"\\",
"EnvFactory",
"::",
"class",
",",
"View",
"\\",
"Helper",
"\\",
"FormLocalMessage",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"//\\Zend\\Form\\View\\Helper\\FormElementErrors::class => View\\Helper\\Factory\\FormElementErrorsFactory::class,",
"]",
",",
"'aliases'",
"=>",
"[",
"'helperParams'",
"=>",
"View",
"\\",
"Helper",
"\\",
"Params",
"::",
"class",
",",
"'helperConfig'",
"=>",
"View",
"\\",
"Helper",
"\\",
"Config",
"::",
"class",
",",
"'helperEnv'",
"=>",
"View",
"\\",
"Helper",
"\\",
"Env",
"::",
"class",
",",
"'helperCdnVersion'",
"=>",
"View",
"\\",
"Helper",
"\\",
"CdnVersion",
"::",
"class",
",",
"'formLocalMessage'",
"=>",
"View",
"\\",
"Helper",
"\\",
"FormLocalMessage",
"::",
"class",
",",
"'helperFormLocalMessage'",
"=>",
"View",
"\\",
"Helper",
"\\",
"FormLocalMessage",
"::",
"class",
",",
"]",
",",
"]",
";",
"}"
] | Configuration view helper
@return array | [
"Configuration",
"view",
"helper"
] | 596fc89c25033eaef8f796418a4a3399c47a9638 | https://github.com/leogitpro/php-zf3-base-module/blob/596fc89c25033eaef8f796418a4a3399c47a9638/module/src/Module.php#L277-L297 | train |
mtils/cmsable | src/Cmsable/Http/ContentTypeMorpher.php | ContentTypeMorpher.morphResponseIfNeeded | protected function morphResponseIfNeeded($response)
{
$contentType = $this->detectContentType($response);
if ($newResponse = $this->getFromListeners($contentType, $response)) {
return $newResponse;
}
} | php | protected function morphResponseIfNeeded($response)
{
$contentType = $this->detectContentType($response);
if ($newResponse = $this->getFromListeners($contentType, $response)) {
return $newResponse;
}
} | [
"protected",
"function",
"morphResponseIfNeeded",
"(",
"$",
"response",
")",
"{",
"$",
"contentType",
"=",
"$",
"this",
"->",
"detectContentType",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"newResponse",
"=",
"$",
"this",
"->",
"getFromListeners",
"(",
"$",
"contentType",
",",
"$",
"response",
")",
")",
"{",
"return",
"$",
"newResponse",
";",
"}",
"}"
] | Does the actual work. Looks if a morpher is set and call it if needed
@param mixed $response
@return null|$response | [
"Does",
"the",
"actual",
"work",
".",
"Looks",
"if",
"a",
"morpher",
"is",
"set",
"and",
"call",
"it",
"if",
"needed"
] | 03ae84ee3c7d46146f2a1cf687e5c29d6de4286d | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Http/ContentTypeMorpher.php#L87-L96 | train |
mtils/cmsable | src/Cmsable/Http/ContentTypeMorpher.php | ContentTypeMorpher.detectContentType | protected function detectContentType($response)
{
if (!$this->contentTypeDetector) {
return $this->defaultContentType;
}
if ($contentType = call_user_func($this->contentTypeDetector, $response, $this)) {
return $contentType;
}
return $this->defaultContentType;
} | php | protected function detectContentType($response)
{
if (!$this->contentTypeDetector) {
return $this->defaultContentType;
}
if ($contentType = call_user_func($this->contentTypeDetector, $response, $this)) {
return $contentType;
}
return $this->defaultContentType;
} | [
"protected",
"function",
"detectContentType",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"contentTypeDetector",
")",
"{",
"return",
"$",
"this",
"->",
"defaultContentType",
";",
"}",
"if",
"(",
"$",
"contentType",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"contentTypeDetector",
",",
"$",
"response",
",",
"$",
"this",
")",
")",
"{",
"return",
"$",
"contentType",
";",
"}",
"return",
"$",
"this",
"->",
"defaultContentType",
";",
"}"
] | Detects the content type
@param mixed $response
@return string | [
"Detects",
"the",
"content",
"type"
] | 03ae84ee3c7d46146f2a1cf687e5c29d6de4286d | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Http/ContentTypeMorpher.php#L104-L115 | train |
mtils/cmsable | src/Cmsable/Http/ContentTypeMorpher.php | ContentTypeMorpher.getFromListeners | protected function getFromListeners($contentType, $response)
{
foreach (['before', 'after'] as $position) {
foreach ($this->getAfterOrBeforeListeners('handle',
$position) as $listener) {
if($result = $listener($contentType, $response, $this)) {
return $result;
}
}
}
return null;
} | php | protected function getFromListeners($contentType, $response)
{
foreach (['before', 'after'] as $position) {
foreach ($this->getAfterOrBeforeListeners('handle',
$position) as $listener) {
if($result = $listener($contentType, $response, $this)) {
return $result;
}
}
}
return null;
} | [
"protected",
"function",
"getFromListeners",
"(",
"$",
"contentType",
",",
"$",
"response",
")",
"{",
"foreach",
"(",
"[",
"'before'",
",",
"'after'",
"]",
"as",
"$",
"position",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAfterOrBeforeListeners",
"(",
"'handle'",
",",
"$",
"position",
")",
"as",
"$",
"listener",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"$",
"listener",
"(",
"$",
"contentType",
",",
"$",
"response",
",",
"$",
"this",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Fires the event and returns the result if there were some
@param string $contentType
@param \Illuminate\Http\Response $response
@return \Illuminate\Http\Response|null | [
"Fires",
"the",
"event",
"and",
"returns",
"the",
"result",
"if",
"there",
"were",
"some"
] | 03ae84ee3c7d46146f2a1cf687e5c29d6de4286d | https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Http/ContentTypeMorpher.php#L124-L139 | train |
ekyna/SettingBundle | Entity/RedirectionRepository.php | RedirectionRepository.findByPath | public function findByPath($path)
{
$qb = $this->createQueryBuilder('r');
$query = $qb
->andWhere($qb->expr()->eq('r.fromPath', ':path'))
->andWhere($qb->expr()->eq('r.enabled', ':enabled'))
->getQuery()
->setMaxResults(1)
// TODO cache
;
return $query
->setParameters([
'path' => $path,
'enabled' => true,
])
->getOneOrNullResult()
;
} | php | public function findByPath($path)
{
$qb = $this->createQueryBuilder('r');
$query = $qb
->andWhere($qb->expr()->eq('r.fromPath', ':path'))
->andWhere($qb->expr()->eq('r.enabled', ':enabled'))
->getQuery()
->setMaxResults(1)
// TODO cache
;
return $query
->setParameters([
'path' => $path,
'enabled' => true,
])
->getOneOrNullResult()
;
} | [
"public",
"function",
"findByPath",
"(",
"$",
"path",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'r'",
")",
";",
"$",
"query",
"=",
"$",
"qb",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'r.fromPath'",
",",
"':path'",
")",
")",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"'r.enabled'",
",",
"':enabled'",
")",
")",
"->",
"getQuery",
"(",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"// TODO cache",
";",
"return",
"$",
"query",
"->",
"setParameters",
"(",
"[",
"'path'",
"=>",
"$",
"path",
",",
"'enabled'",
"=>",
"true",
",",
"]",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"}"
] | Finds the redirection by "from path".
@param string $path
@return Redirection|null | [
"Finds",
"the",
"redirection",
"by",
"from",
"path",
"."
] | df58f83eb3a01ef56cd76ea73639322c581e75c1 | https://github.com/ekyna/SettingBundle/blob/df58f83eb3a01ef56cd76ea73639322c581e75c1/Entity/RedirectionRepository.php#L21-L40 | train |
frodosghost/AtomLoggerBundle | Connection/Client.php | Client.send | public function send(Request $request)
{
$headers = array('Content-Type' => $request->getContentType());
$content = $request->formatData();
if ($this->hasSiteKey()) {
$headers = array_merge($headers, array('x-atom-log-id' => $this->getSiteKey()));
}
try {
$response = $this->getBrowser()->post($this->getAtomUri(), $headers, $content);
} catch(\Exception $e) {
throw new \RuntimeException($e->getMessage());
}
return $response;
} | php | public function send(Request $request)
{
$headers = array('Content-Type' => $request->getContentType());
$content = $request->formatData();
if ($this->hasSiteKey()) {
$headers = array_merge($headers, array('x-atom-log-id' => $this->getSiteKey()));
}
try {
$response = $this->getBrowser()->post($this->getAtomUri(), $headers, $content);
} catch(\Exception $e) {
throw new \RuntimeException($e->getMessage());
}
return $response;
} | [
"public",
"function",
"send",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
"'Content-Type'",
"=>",
"$",
"request",
"->",
"getContentType",
"(",
")",
")",
";",
"$",
"content",
"=",
"$",
"request",
"->",
"formatData",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasSiteKey",
"(",
")",
")",
"{",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"headers",
",",
"array",
"(",
"'x-atom-log-id'",
"=>",
"$",
"this",
"->",
"getSiteKey",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getBrowser",
"(",
")",
"->",
"post",
"(",
"$",
"this",
"->",
"getAtomUri",
"(",
")",
",",
"$",
"headers",
",",
"$",
"content",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Send the Request
@param Request $request
@return Response | [
"Send",
"the",
"Request"
] | c48823e4b3772e498b366867f27e6581f613f733 | https://github.com/frodosghost/AtomLoggerBundle/blob/c48823e4b3772e498b366867f27e6581f613f733/Connection/Client.php#L64-L80 | train |
jabernardo/lollipop-php | Library/HTTP/Route.php | Route.resolve | static public function resolve($callback, \Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res, array $args = []) {
if (is_string($callback)) {
// If callback was string then
// Explode it by (dot) to determine the Controller and Action
$ctoks = explode('.', $callback);
$output = '';
switch (count($ctoks)) {
case 1: // Function only
if (!function_exists($action = $ctoks[0]))
throw new \Lollipop\Exception\HTTP\Route('Callback is not a function');
ob_start();
$output = call_user_func($action, $req, $res, $args); // Update callback
ob_get_clean();
break;
case 2: // Controller and Action
if (class_exists($ctoks[0]) &&
is_callable([ $controller = new $ctoks[0], $action = $ctoks[1] ])) {
ob_start();
$output = call_user_func([ $controller, $action ], $req, $res, $args);
ob_get_clean();
} else {
throw new \Lollipop\Exception\HTTP\Route("Cannot find controller and action");
}
break;
default: // Invalid callback
throw new \Lollipop\Exception\HTTP\Route('Callback is not a function');
break;
}
}
// Only if sent parameter is callable
if (is_callable($callback)) {
ob_start();
$output = call_user_func($callback, $req, $res, $args); // Return anonymous function
ob_get_clean();
}
// Set response object
if ($output instanceof Response) {
$res = $output;
} else {
$res = new Response($output);
}
return $res;
} | php | static public function resolve($callback, \Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res, array $args = []) {
if (is_string($callback)) {
// If callback was string then
// Explode it by (dot) to determine the Controller and Action
$ctoks = explode('.', $callback);
$output = '';
switch (count($ctoks)) {
case 1: // Function only
if (!function_exists($action = $ctoks[0]))
throw new \Lollipop\Exception\HTTP\Route('Callback is not a function');
ob_start();
$output = call_user_func($action, $req, $res, $args); // Update callback
ob_get_clean();
break;
case 2: // Controller and Action
if (class_exists($ctoks[0]) &&
is_callable([ $controller = new $ctoks[0], $action = $ctoks[1] ])) {
ob_start();
$output = call_user_func([ $controller, $action ], $req, $res, $args);
ob_get_clean();
} else {
throw new \Lollipop\Exception\HTTP\Route("Cannot find controller and action");
}
break;
default: // Invalid callback
throw new \Lollipop\Exception\HTTP\Route('Callback is not a function');
break;
}
}
// Only if sent parameter is callable
if (is_callable($callback)) {
ob_start();
$output = call_user_func($callback, $req, $res, $args); // Return anonymous function
ob_get_clean();
}
// Set response object
if ($output instanceof Response) {
$res = $output;
} else {
$res = new Response($output);
}
return $res;
} | [
"static",
"public",
"function",
"resolve",
"(",
"$",
"callback",
",",
"\\",
"Lollipop",
"\\",
"HTTP",
"\\",
"Request",
"$",
"req",
",",
"\\",
"Lollipop",
"\\",
"HTTP",
"\\",
"Response",
"$",
"res",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"// If callback was string then",
"// Explode it by (dot) to determine the Controller and Action",
"$",
"ctoks",
"=",
"explode",
"(",
"'.'",
",",
"$",
"callback",
")",
";",
"$",
"output",
"=",
"''",
";",
"switch",
"(",
"count",
"(",
"$",
"ctoks",
")",
")",
"{",
"case",
"1",
":",
"// Function only",
"if",
"(",
"!",
"function_exists",
"(",
"$",
"action",
"=",
"$",
"ctoks",
"[",
"0",
"]",
")",
")",
"throw",
"new",
"\\",
"Lollipop",
"\\",
"Exception",
"\\",
"HTTP",
"\\",
"Route",
"(",
"'Callback is not a function'",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"output",
"=",
"call_user_func",
"(",
"$",
"action",
",",
"$",
"req",
",",
"$",
"res",
",",
"$",
"args",
")",
";",
"// Update callback",
"ob_get_clean",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"// Controller and Action",
"if",
"(",
"class_exists",
"(",
"$",
"ctoks",
"[",
"0",
"]",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"controller",
"=",
"new",
"$",
"ctoks",
"[",
"0",
"]",
",",
"$",
"action",
"=",
"$",
"ctoks",
"[",
"1",
"]",
"]",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"output",
"=",
"call_user_func",
"(",
"[",
"$",
"controller",
",",
"$",
"action",
"]",
",",
"$",
"req",
",",
"$",
"res",
",",
"$",
"args",
")",
";",
"ob_get_clean",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Lollipop",
"\\",
"Exception",
"\\",
"HTTP",
"\\",
"Route",
"(",
"\"Cannot find controller and action\"",
")",
";",
"}",
"break",
";",
"default",
":",
"// Invalid callback",
"throw",
"new",
"\\",
"Lollipop",
"\\",
"Exception",
"\\",
"HTTP",
"\\",
"Route",
"(",
"'Callback is not a function'",
")",
";",
"break",
";",
"}",
"}",
"// Only if sent parameter is callable",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"output",
"=",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"req",
",",
"$",
"res",
",",
"$",
"args",
")",
";",
"// Return anonymous function",
"ob_get_clean",
"(",
")",
";",
"}",
"// Set response object",
"if",
"(",
"$",
"output",
"instanceof",
"Response",
")",
"{",
"$",
"res",
"=",
"$",
"output",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"new",
"Response",
"(",
"$",
"output",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Call callback and return data
@access private
@param mixed $callback (string or callable) string must be {abc}.{abc} format to use controller action
@param \Lollipop\HTTP\Request $req Request Object
@param \Lollipop\HTTP\Response $res Response Object
@param array $args Parameters to be passed to callback
@throws \Lollipop\Exception\HTTP\Route
@return \Lollipop\HTTP\Response | [
"Call",
"callback",
"and",
"return",
"data"
] | 004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5 | https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/HTTP/Route.php#L32-L85 | train |
miguelibero/meinhof | src/Meinhof/Action/UpdateAssetsAction.php | UpdateAssetsAction.addAssets | public function addAssets(array $assets)
{
foreach ($assets as $asset) {
if (!is_array($asset)) {
throw new \InvalidArgumentException('Each element needs to be an array.');
}
$this->addAsset($asset);
}
} | php | public function addAssets(array $assets)
{
foreach ($assets as $asset) {
if (!is_array($asset)) {
throw new \InvalidArgumentException('Each element needs to be an array.');
}
$this->addAsset($asset);
}
} | [
"public",
"function",
"addAssets",
"(",
"array",
"$",
"assets",
")",
"{",
"foreach",
"(",
"$",
"assets",
"as",
"$",
"asset",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"asset",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Each element needs to be an array.'",
")",
";",
"}",
"$",
"this",
"->",
"addAsset",
"(",
"$",
"asset",
")",
";",
"}",
"}"
] | Adds a list of assets to be processed by the asset writer.
@param array assets the asset list | [
"Adds",
"a",
"list",
"of",
"assets",
"to",
"be",
"processed",
"by",
"the",
"asset",
"writer",
"."
] | 3a090f08485dc0da3e27463cf349dba374201072 | https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Action/UpdateAssetsAction.php#L48-L56 | train |
miguelibero/meinhof | src/Meinhof/Action/UpdateAssetsAction.php | UpdateAssetsAction.addAsset | public function addAsset(array $asset)
{
if (!isset($asset['input'])) {
throw new \InvalidArgumentException('Asset needs an input.');
}
if (!isset($asset['name'])) {
$asset['name'] = uniqid();
}
if (!isset($asset['filter'])) {
$asset['filter'] = array();
}
if (!is_array($asset['filter'])) {
$asset['filter'] = explode(',', $asset['filter']);
}
if (!isset($asset['options']) || !is_array($asset['options'])) {
$asset['options'] = array();
}
if (!isset($asset['options']['output']) && isset($asset['output'])) {
$asset['options']['output'] = $asset['output'];
}
$this->manager->setFormula($asset['name'], array(
$asset['input'],
$asset['filter'],
$asset['options']
));
} | php | public function addAsset(array $asset)
{
if (!isset($asset['input'])) {
throw new \InvalidArgumentException('Asset needs an input.');
}
if (!isset($asset['name'])) {
$asset['name'] = uniqid();
}
if (!isset($asset['filter'])) {
$asset['filter'] = array();
}
if (!is_array($asset['filter'])) {
$asset['filter'] = explode(',', $asset['filter']);
}
if (!isset($asset['options']) || !is_array($asset['options'])) {
$asset['options'] = array();
}
if (!isset($asset['options']['output']) && isset($asset['output'])) {
$asset['options']['output'] = $asset['output'];
}
$this->manager->setFormula($asset['name'], array(
$asset['input'],
$asset['filter'],
$asset['options']
));
} | [
"public",
"function",
"addAsset",
"(",
"array",
"$",
"asset",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"asset",
"[",
"'input'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Asset needs an input.'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"asset",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"asset",
"[",
"'name'",
"]",
"=",
"uniqid",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"asset",
"[",
"'filter'",
"]",
")",
")",
"{",
"$",
"asset",
"[",
"'filter'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"asset",
"[",
"'filter'",
"]",
")",
")",
"{",
"$",
"asset",
"[",
"'filter'",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"asset",
"[",
"'filter'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"asset",
"[",
"'options'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"asset",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"asset",
"[",
"'options'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"asset",
"[",
"'options'",
"]",
"[",
"'output'",
"]",
")",
"&&",
"isset",
"(",
"$",
"asset",
"[",
"'output'",
"]",
")",
")",
"{",
"$",
"asset",
"[",
"'options'",
"]",
"[",
"'output'",
"]",
"=",
"$",
"asset",
"[",
"'output'",
"]",
";",
"}",
"$",
"this",
"->",
"manager",
"->",
"setFormula",
"(",
"$",
"asset",
"[",
"'name'",
"]",
",",
"array",
"(",
"$",
"asset",
"[",
"'input'",
"]",
",",
"$",
"asset",
"[",
"'filter'",
"]",
",",
"$",
"asset",
"[",
"'options'",
"]",
")",
")",
";",
"}"
] | Adds an asset to be processed by the asset writer.
Accepted keys in the asset array are:
* `name`: the name of the asset
* `input`: the input assets (required)
* `filter`: the assetic filters to be applied (by default)
* `output`: the output path (by default the same as input)
* `options`: other asset options
@param array asset the asset configuration | [
"Adds",
"an",
"asset",
"to",
"be",
"processed",
"by",
"the",
"asset",
"writer",
"."
] | 3a090f08485dc0da3e27463cf349dba374201072 | https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Action/UpdateAssetsAction.php#L70-L96 | train |
vaniocz/stdlib | src/LinkedHashMap.php | LinkedHashMap.offsetGet | public function offsetGet($key)
{
if (($index = $this->keysIndices[self::keyString($key)] ?? null) === null) {
return null;
}
return $this->values[$index];
} | php | public function offsetGet($key)
{
if (($index = $this->keysIndices[self::keyString($key)] ?? null) === null) {
return null;
}
return $this->values[$index];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"(",
"$",
"index",
"=",
"$",
"this",
"->",
"keysIndices",
"[",
"self",
"::",
"keyString",
"(",
"$",
"key",
")",
"]",
"??",
"null",
")",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"index",
"]",
";",
"}"
] | Retrieve a value with the given key.
@param mixed $key
@return mixed A value with the given key. | [
"Retrieve",
"a",
"value",
"with",
"the",
"given",
"key",
"."
] | 06a8343c42829d8fdeecad2bb5c30946fbd73e74 | https://github.com/vaniocz/stdlib/blob/06a8343c42829d8fdeecad2bb5c30946fbd73e74/src/LinkedHashMap.php#L52-L59 | train |
vaniocz/stdlib | src/LinkedHashMap.php | LinkedHashMap.offsetSet | public function offsetSet($key, $value)
{
if ($key === null) {
$intKeys = array_filter($this->keys, 'is_int');
$this->keys[] = $i = empty($intKeys) ? 0 : max(max($intKeys) + 1, 0);
$this->values[] = $value;
$this->keysIndices[$i] = count($this->values) - 1;
} elseif (($index = $this->keysIndices[self::keyString($key)] ?? null) === null) {
$this->keys[] = $key;
$this->values[] = $value;
$this->keysIndices[self::keyString($key)] = count($this->values) - 1;
} else {
$this->values[$index] = $value;
}
} | php | public function offsetSet($key, $value)
{
if ($key === null) {
$intKeys = array_filter($this->keys, 'is_int');
$this->keys[] = $i = empty($intKeys) ? 0 : max(max($intKeys) + 1, 0);
$this->values[] = $value;
$this->keysIndices[$i] = count($this->values) - 1;
} elseif (($index = $this->keysIndices[self::keyString($key)] ?? null) === null) {
$this->keys[] = $key;
$this->values[] = $value;
$this->keysIndices[self::keyString($key)] = count($this->values) - 1;
} else {
$this->values[$index] = $value;
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"$",
"intKeys",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"keys",
",",
"'is_int'",
")",
";",
"$",
"this",
"->",
"keys",
"[",
"]",
"=",
"$",
"i",
"=",
"empty",
"(",
"$",
"intKeys",
")",
"?",
"0",
":",
"max",
"(",
"max",
"(",
"$",
"intKeys",
")",
"+",
"1",
",",
"0",
")",
";",
"$",
"this",
"->",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"keysIndices",
"[",
"$",
"i",
"]",
"=",
"count",
"(",
"$",
"this",
"->",
"values",
")",
"-",
"1",
";",
"}",
"elseif",
"(",
"(",
"$",
"index",
"=",
"$",
"this",
"->",
"keysIndices",
"[",
"self",
"::",
"keyString",
"(",
"$",
"key",
")",
"]",
"??",
"null",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"keys",
"[",
"]",
"=",
"$",
"key",
";",
"$",
"this",
"->",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"keysIndices",
"[",
"self",
"::",
"keyString",
"(",
"$",
"key",
")",
"]",
"=",
"count",
"(",
"$",
"this",
"->",
"values",
")",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Insert the given value with the given key.
@param mixed $key
@param mixed $value | [
"Insert",
"the",
"given",
"value",
"with",
"the",
"given",
"key",
"."
] | 06a8343c42829d8fdeecad2bb5c30946fbd73e74 | https://github.com/vaniocz/stdlib/blob/06a8343c42829d8fdeecad2bb5c30946fbd73e74/src/LinkedHashMap.php#L67-L81 | train |
vaniocz/stdlib | src/LinkedHashMap.php | LinkedHashMap.offsetUnset | public function offsetUnset($key)
{
$keyString = self::keyString($key);
if (($index = $this->keysIndices[$keyString] ?? null) !== null) {
unset($this->keys[$index], $this->values[$index], $this->keysIndices[$keyString]);
}
} | php | public function offsetUnset($key)
{
$keyString = self::keyString($key);
if (($index = $this->keysIndices[$keyString] ?? null) !== null) {
unset($this->keys[$index], $this->values[$index], $this->keysIndices[$keyString]);
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"key",
")",
"{",
"$",
"keyString",
"=",
"self",
"::",
"keyString",
"(",
"$",
"key",
")",
";",
"if",
"(",
"(",
"$",
"index",
"=",
"$",
"this",
"->",
"keysIndices",
"[",
"$",
"keyString",
"]",
"??",
"null",
")",
"!==",
"null",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"keys",
"[",
"$",
"index",
"]",
",",
"$",
"this",
"->",
"values",
"[",
"$",
"index",
"]",
",",
"$",
"this",
"->",
"keysIndices",
"[",
"$",
"keyString",
"]",
")",
";",
"}",
"}"
] | Remove a value with the given key from the map.
@param mixed $key | [
"Remove",
"a",
"value",
"with",
"the",
"given",
"key",
"from",
"the",
"map",
"."
] | 06a8343c42829d8fdeecad2bb5c30946fbd73e74 | https://github.com/vaniocz/stdlib/blob/06a8343c42829d8fdeecad2bb5c30946fbd73e74/src/LinkedHashMap.php#L88-L94 | train |
vaniocz/stdlib | src/LinkedHashMap.php | LinkedHashMap.getIterator | public function getIterator(): Traversable
{
foreach ($this->values as $index => &$value) {
yield $this->keys[$index] => $value;
}
} | php | public function getIterator(): Traversable
{
foreach ($this->values as $index => &$value) {
yield $this->keys[$index] => $value;
}
} | [
"public",
"function",
"getIterator",
"(",
")",
":",
"Traversable",
"{",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"index",
"=>",
"&",
"$",
"value",
")",
"{",
"yield",
"$",
"this",
"->",
"keys",
"[",
"$",
"index",
"]",
"=>",
"$",
"value",
";",
"}",
"}"
] | Get the map iterator.
@return Traversable The map iterator. | [
"Get",
"the",
"map",
"iterator",
"."
] | 06a8343c42829d8fdeecad2bb5c30946fbd73e74 | https://github.com/vaniocz/stdlib/blob/06a8343c42829d8fdeecad2bb5c30946fbd73e74/src/LinkedHashMap.php#L111-L116 | train |
mcustiel/phiremock-client | src/Phiremock.php | Phiremock.reset | public function reset()
{
$uri = $this->createBaseUri()->withPath(self::API_RESET_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('post');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | php | public function reset()
{
$uri = $this->createBaseUri()->withPath(self::API_RESET_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('post');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"createBaseUri",
"(",
")",
"->",
"withPath",
"(",
"self",
"::",
"API_RESET_URL",
")",
";",
"$",
"request",
"=",
"(",
"new",
"PsrRequest",
"(",
")",
")",
"->",
"withUri",
"(",
"$",
"uri",
")",
"->",
"withMethod",
"(",
"'post'",
")",
";",
"$",
"this",
"->",
"ensureIsNotErrorResponse",
"(",
"$",
"this",
"->",
"connection",
"->",
"send",
"(",
"$",
"request",
")",
")",
";",
"}"
] | Restores pre-defined expectations and resets scenarios and requests counter. | [
"Restores",
"pre",
"-",
"defined",
"expectations",
"and",
"resets",
"scenarios",
"and",
"requests",
"counter",
"."
] | 2e4c6948ad1573451bb4d2e72aee779d4343b9fd | https://github.com/mcustiel/phiremock-client/blob/2e4c6948ad1573451bb4d2e72aee779d4343b9fd/src/Phiremock.php#L90-L96 | train |
mcustiel/phiremock-client | src/Phiremock.php | Phiremock.resetScenarios | public function resetScenarios()
{
$uri = $this->createBaseUri()->withPath(self::API_SCENARIOS_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('delete');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | php | public function resetScenarios()
{
$uri = $this->createBaseUri()->withPath(self::API_SCENARIOS_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('delete');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | [
"public",
"function",
"resetScenarios",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"createBaseUri",
"(",
")",
"->",
"withPath",
"(",
"self",
"::",
"API_SCENARIOS_URL",
")",
";",
"$",
"request",
"=",
"(",
"new",
"PsrRequest",
"(",
")",
")",
"->",
"withUri",
"(",
"$",
"uri",
")",
"->",
"withMethod",
"(",
"'delete'",
")",
";",
"$",
"this",
"->",
"ensureIsNotErrorResponse",
"(",
"$",
"this",
"->",
"connection",
"->",
"send",
"(",
"$",
"request",
")",
")",
";",
"}"
] | Resets all the scenarios to start state. | [
"Resets",
"all",
"the",
"scenarios",
"to",
"start",
"state",
"."
] | 2e4c6948ad1573451bb4d2e72aee779d4343b9fd | https://github.com/mcustiel/phiremock-client/blob/2e4c6948ad1573451bb4d2e72aee779d4343b9fd/src/Phiremock.php#L210-L216 | train |
mcustiel/phiremock-client | src/Phiremock.php | Phiremock.resetRequestsCounter | public function resetRequestsCounter()
{
$uri = $this->createBaseUri()->withPath(self::API_EXECUTIONS_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('delete');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | php | public function resetRequestsCounter()
{
$uri = $this->createBaseUri()->withPath(self::API_EXECUTIONS_URL);
$request = (new PsrRequest())->withUri($uri)->withMethod('delete');
$this->ensureIsNotErrorResponse($this->connection->send($request));
} | [
"public",
"function",
"resetRequestsCounter",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"createBaseUri",
"(",
")",
"->",
"withPath",
"(",
"self",
"::",
"API_EXECUTIONS_URL",
")",
";",
"$",
"request",
"=",
"(",
"new",
"PsrRequest",
"(",
")",
")",
"->",
"withUri",
"(",
"$",
"uri",
")",
"->",
"withMethod",
"(",
"'delete'",
")",
";",
"$",
"this",
"->",
"ensureIsNotErrorResponse",
"(",
"$",
"this",
"->",
"connection",
"->",
"send",
"(",
"$",
"request",
")",
")",
";",
"}"
] | Resets all the requests counters to 0. | [
"Resets",
"all",
"the",
"requests",
"counters",
"to",
"0",
"."
] | 2e4c6948ad1573451bb4d2e72aee779d4343b9fd | https://github.com/mcustiel/phiremock-client/blob/2e4c6948ad1573451bb4d2e72aee779d4343b9fd/src/Phiremock.php#L221-L227 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.keep | public function keep($key)
{
if (isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_NEW;
return true;
}
return false;
} | php | public function keep($key)
{
if (isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_NEW;
return true;
}
return false;
} | [
"public",
"function",
"keep",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"=",
"static",
"::",
"EXPIRE_STATE_NEW",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Reset the expiry state on the given key
@param string $key
@return boolean | [
"Reset",
"the",
"expiry",
"state",
"on",
"the",
"given",
"key"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L123-L132 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.expiration | public function expiration($key)
{
if (isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
$expiration = array(
$this->data[static::EXPIRE_DATA_KEY][$key][0] == EXPIRE_ON_REQUEST ? 'EXPIRE_ON_REQUEST' : 'EXPIRE_ON_GET',
$this->data[static::EXPIRE_DATA_KEY][$key][1] == static::EXPIRE_STATE_NEW ? 'STATE_NEW' : ($this->data[static::EXPIRE_DATA_KEY][$key][1] == static::EXPIRE_STATE_LOADED ? 'STATE_LOADED' : 'STATE_EXPIRED'),
);
return $expiration;
}
return false;
} | php | public function expiration($key)
{
if (isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
$expiration = array(
$this->data[static::EXPIRE_DATA_KEY][$key][0] == EXPIRE_ON_REQUEST ? 'EXPIRE_ON_REQUEST' : 'EXPIRE_ON_GET',
$this->data[static::EXPIRE_DATA_KEY][$key][1] == static::EXPIRE_STATE_NEW ? 'STATE_NEW' : ($this->data[static::EXPIRE_DATA_KEY][$key][1] == static::EXPIRE_STATE_LOADED ? 'STATE_LOADED' : 'STATE_EXPIRED'),
);
return $expiration;
}
return false;
} | [
"public",
"function",
"expiration",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"expiration",
"=",
"array",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"==",
"EXPIRE_ON_REQUEST",
"?",
"'EXPIRE_ON_REQUEST'",
":",
"'EXPIRE_ON_GET'",
",",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"==",
"static",
"::",
"EXPIRE_STATE_NEW",
"?",
"'STATE_NEW'",
":",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"==",
"static",
"::",
"EXPIRE_STATE_LOADED",
"?",
"'STATE_LOADED'",
":",
"'STATE_EXPIRED'",
")",
",",
")",
";",
"return",
"$",
"expiration",
";",
"}",
"return",
"false",
";",
"}"
] | Returns the expiry state on the given key
@param string $key
@return array | [
"Returns",
"the",
"expiry",
"state",
"on",
"the",
"given",
"key"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L141-L153 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.get | public function get($key, $default = null)
{
// check if we have this key
if (parent::has($this->prefixKey($key)))
{
// do we have expiry information?
if ( ! isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
// nope, simply return the data
return parent::get($this->prefixKey($key), $default);
}
// return the data if we don't have expiry information or if the data is valid
if ($this->data[static::EXPIRE_DATA_KEY][$key][1] !== static::EXPIRE_STATE_EXPIRED)
{
// check the expiry strategy
if ($this->data[static::EXPIRE_DATA_KEY][$key][0] === EXPIRE_ON_GET)
{
// expire on get, so expire it
$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_EXPIRED;
}
// return the data
return parent::get($this->prefixKey($key), $default);
}
}
// no dice, return the default
return $default;
} | php | public function get($key, $default = null)
{
// check if we have this key
if (parent::has($this->prefixKey($key)))
{
// do we have expiry information?
if ( ! isset($this->data[static::EXPIRE_DATA_KEY][$key]))
{
// nope, simply return the data
return parent::get($this->prefixKey($key), $default);
}
// return the data if we don't have expiry information or if the data is valid
if ($this->data[static::EXPIRE_DATA_KEY][$key][1] !== static::EXPIRE_STATE_EXPIRED)
{
// check the expiry strategy
if ($this->data[static::EXPIRE_DATA_KEY][$key][0] === EXPIRE_ON_GET)
{
// expire on get, so expire it
$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_EXPIRED;
}
// return the data
return parent::get($this->prefixKey($key), $default);
}
}
// no dice, return the default
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// check if we have this key",
"if",
"(",
"parent",
"::",
"has",
"(",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
")",
")",
"{",
"// do we have expiry information?",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// nope, simply return the data",
"return",
"parent",
"::",
"get",
"(",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
",",
"$",
"default",
")",
";",
"}",
"// return the data if we don't have expiry information or if the data is valid",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"!==",
"static",
"::",
"EXPIRE_STATE_EXPIRED",
")",
"{",
"// check the expiry strategy",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"===",
"EXPIRE_ON_GET",
")",
"{",
"// expire on get, so expire it",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"=",
"static",
"::",
"EXPIRE_STATE_EXPIRED",
";",
"}",
"// return the data",
"return",
"parent",
"::",
"get",
"(",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
",",
"$",
"default",
")",
";",
"}",
"}",
"// no dice, return the default",
"return",
"$",
"default",
";",
"}"
] | Returns a key's value from this bag's data
@param string $key
@param mixed $default
@return mixed | [
"Returns",
"a",
"key",
"s",
"value",
"from",
"this",
"bag",
"s",
"data"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L163-L192 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.delete | public function delete($key)
{
// remove the expiration tracking for this key
unset($this->data[static::EXPIRE_DATA_KEY][$key]);
// and delete the key itself
return parent::delete($this->prefixKey($key));
} | php | public function delete($key)
{
// remove the expiration tracking for this key
unset($this->data[static::EXPIRE_DATA_KEY][$key]);
// and delete the key itself
return parent::delete($this->prefixKey($key));
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"// remove the expiration tracking for this key",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
";",
"// and delete the key itself",
"return",
"parent",
"::",
"delete",
"(",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
")",
";",
"}"
] | Deletes data from the container
@param string $key
@return boolean | [
"Deletes",
"data",
"from",
"the",
"container"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L234-L241 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.setContents | public function setContents(array $data)
{
// make sure we have our expire data key
if (isset($data[static::EXPIRE_DATA_KEY]))
{
// process the expiration settings
foreach($data[static::EXPIRE_DATA_KEY] as $key => $expiration)
{
// if it was set on the last request, make it as loaded
if ($expiration[1] === static::EXPIRE_STATE_NEW)
{
$data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_LOADED;
}
// if it was already loaded on the last request, and we expire on request, delete it
elseif ($expiration[0] === EXPIRE_ON_REQUEST and $expiration[1] === static::EXPIRE_STATE_LOADED)
{
unset($data[static::EXPIRE_DATA_KEY][$key]);
\Arr::delete($data, $this->prefixKey($key));
}
}
}
else
{
// not set, create an empty one to start with
$data[static::EXPIRE_DATA_KEY] = array();
}
// store the data
parent::setContents($data);
} | php | public function setContents(array $data)
{
// make sure we have our expire data key
if (isset($data[static::EXPIRE_DATA_KEY]))
{
// process the expiration settings
foreach($data[static::EXPIRE_DATA_KEY] as $key => $expiration)
{
// if it was set on the last request, make it as loaded
if ($expiration[1] === static::EXPIRE_STATE_NEW)
{
$data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_LOADED;
}
// if it was already loaded on the last request, and we expire on request, delete it
elseif ($expiration[0] === EXPIRE_ON_REQUEST and $expiration[1] === static::EXPIRE_STATE_LOADED)
{
unset($data[static::EXPIRE_DATA_KEY][$key]);
\Arr::delete($data, $this->prefixKey($key));
}
}
}
else
{
// not set, create an empty one to start with
$data[static::EXPIRE_DATA_KEY] = array();
}
// store the data
parent::setContents($data);
} | [
"public",
"function",
"setContents",
"(",
"array",
"$",
"data",
")",
"{",
"// make sure we have our expire data key",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
")",
")",
"{",
"// process the expiration settings",
"foreach",
"(",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"as",
"$",
"key",
"=>",
"$",
"expiration",
")",
"{",
"// if it was set on the last request, make it as loaded",
"if",
"(",
"$",
"expiration",
"[",
"1",
"]",
"===",
"static",
"::",
"EXPIRE_STATE_NEW",
")",
"{",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
"[",
"1",
"]",
"=",
"static",
"::",
"EXPIRE_STATE_LOADED",
";",
"}",
"// if it was already loaded on the last request, and we expire on request, delete it",
"elseif",
"(",
"$",
"expiration",
"[",
"0",
"]",
"===",
"EXPIRE_ON_REQUEST",
"and",
"$",
"expiration",
"[",
"1",
"]",
"===",
"static",
"::",
"EXPIRE_STATE_LOADED",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
";",
"\\",
"Arr",
"::",
"delete",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// not set, create an empty one to start with",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"=",
"array",
"(",
")",
";",
"}",
"// store the data",
"parent",
"::",
"setContents",
"(",
"$",
"data",
")",
";",
"}"
] | Replaces the container's data
@param array $data
@throws \RuntimeException | [
"Replaces",
"the",
"container",
"s",
"data"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L250-L280 | train |
fuelphp-storage/session | src/FlashContainer.php | FlashContainer.getContents | public function getContents()
{
// make a copy to leave the original container untouched
$data = $this->data;
// delete all expired variables
foreach($data[static::EXPIRE_DATA_KEY] as $key => $expiration)
{
if ($expiration[1] === static::EXPIRE_STATE_EXPIRED)
{
unset($data[static::EXPIRE_DATA_KEY][$key]);
\Arr::delete($data, $this->prefixKey($key));
}
}
// and return what's left over
return $data;
} | php | public function getContents()
{
// make a copy to leave the original container untouched
$data = $this->data;
// delete all expired variables
foreach($data[static::EXPIRE_DATA_KEY] as $key => $expiration)
{
if ($expiration[1] === static::EXPIRE_STATE_EXPIRED)
{
unset($data[static::EXPIRE_DATA_KEY][$key]);
\Arr::delete($data, $this->prefixKey($key));
}
}
// and return what's left over
return $data;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"// make a copy to leave the original container untouched",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"// delete all expired variables",
"foreach",
"(",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"as",
"$",
"key",
"=>",
"$",
"expiration",
")",
"{",
"if",
"(",
"$",
"expiration",
"[",
"1",
"]",
"===",
"static",
"::",
"EXPIRE_STATE_EXPIRED",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"static",
"::",
"EXPIRE_DATA_KEY",
"]",
"[",
"$",
"key",
"]",
")",
";",
"\\",
"Arr",
"::",
"delete",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"prefixKey",
"(",
"$",
"key",
")",
")",
";",
"}",
"}",
"// and return what's left over",
"return",
"$",
"data",
";",
"}"
] | Returns the container's data
@return array | [
"Returns",
"the",
"container",
"s",
"data"
] | 948fd2b45286e65e7fababf65de89ca6aaca3c4a | https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/FlashContainer.php#L287-L304 | train |
gplcart/cli | controllers/commands/Library.php | Library.cmdGetLibrary | public function cmdGetLibrary()
{
$list = $this->getListLibrary();
$this->outputFormat($list);
$this->outputFormatTableLibrary($list);
$this->output();
} | php | public function cmdGetLibrary()
{
$list = $this->getListLibrary();
$this->outputFormat($list);
$this->outputFormatTableLibrary($list);
$this->output();
} | [
"public",
"function",
"cmdGetLibrary",
"(",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getListLibrary",
"(",
")",
";",
"$",
"this",
"->",
"outputFormat",
"(",
"$",
"list",
")",
";",
"$",
"this",
"->",
"outputFormatTableLibrary",
"(",
"$",
"list",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] | Callback for "library-get" command | [
"Callback",
"for",
"library",
"-",
"get",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Library.php#L40-L46 | train |
OxfordInfoLabs/kinikit-core | src/Util/ClassUtils.php | ClassUtils.doesClassExtendClass | public static function doesClassExtendClass($childClassName, $parentClassName) {
$reflectionClass = new \ReflectionClass ($childClassName);
do {
if ($reflectionClass->getName() == $parentClassName)
return true;
$reflectionClass = $reflectionClass->getParentClass();
} while ($reflectionClass);
// Assume false if we get this far
return false;
} | php | public static function doesClassExtendClass($childClassName, $parentClassName) {
$reflectionClass = new \ReflectionClass ($childClassName);
do {
if ($reflectionClass->getName() == $parentClassName)
return true;
$reflectionClass = $reflectionClass->getParentClass();
} while ($reflectionClass);
// Assume false if we get this far
return false;
} | [
"public",
"static",
"function",
"doesClassExtendClass",
"(",
"$",
"childClassName",
",",
"$",
"parentClassName",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"childClassName",
")",
";",
"do",
"{",
"if",
"(",
"$",
"reflectionClass",
"->",
"getName",
"(",
")",
"==",
"$",
"parentClassName",
")",
"return",
"true",
";",
"$",
"reflectionClass",
"=",
"$",
"reflectionClass",
"->",
"getParentClass",
"(",
")",
";",
"}",
"while",
"(",
"$",
"reflectionClass",
")",
";",
"// Assume false if we get this far",
"return",
"false",
";",
"}"
] | Check to see whether or not a given child class extends a given parent class
@param $childClassName
@param $parentClassName | [
"Check",
"to",
"see",
"whether",
"or",
"not",
"a",
"given",
"child",
"class",
"extends",
"a",
"given",
"parent",
"class"
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/ClassUtils.php#L26-L38 | train |
Dhii/placeholder-template-abstract | src/PlaceholderTemplateAwareCapableTrait.php | PlaceholderTemplateAwareCapableTrait._setPlaceholderTemplate | protected function _setPlaceholderTemplate($template)
{
if (!is_null($template)) {
$template = $this->_normalizeStringable($template);
}
$this->placeholderTemplate = $template;
} | php | protected function _setPlaceholderTemplate($template)
{
if (!is_null($template)) {
$template = $this->_normalizeStringable($template);
}
$this->placeholderTemplate = $template;
} | [
"protected",
"function",
"_setPlaceholderTemplate",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"template",
")",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"_normalizeStringable",
"(",
"$",
"template",
")",
";",
"}",
"$",
"this",
"->",
"placeholderTemplate",
"=",
"$",
"template",
";",
"}"
] | Assigns the placeholder template to this instance.
@since [*next-version*]
@param Stringable|string|int|float|bool|null $template The template. | [
"Assigns",
"the",
"placeholder",
"template",
"to",
"this",
"instance",
"."
] | bfa7cea3b1e078b19bcf59d9a3da63b8c12ed03b | https://github.com/Dhii/placeholder-template-abstract/blob/bfa7cea3b1e078b19bcf59d9a3da63b8c12ed03b/src/PlaceholderTemplateAwareCapableTrait.php#L31-L38 | train |
raframework/rapkg | src/Rapkg/Cli/App.php | App.run | public function run(array $args)
{
$command = (string)$args[1];
$this->router->match($command);
$args = array_slice($args, 2);
return $this->router->executeCommand($args);
} | php | public function run(array $args)
{
$command = (string)$args[1];
$this->router->match($command);
$args = array_slice($args, 2);
return $this->router->executeCommand($args);
} | [
"public",
"function",
"run",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"command",
"=",
"(",
"string",
")",
"$",
"args",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"router",
"->",
"match",
"(",
"$",
"command",
")",
";",
"$",
"args",
"=",
"array_slice",
"(",
"$",
"args",
",",
"2",
")",
";",
"return",
"$",
"this",
"->",
"router",
"->",
"executeCommand",
"(",
"$",
"args",
")",
";",
"}"
] | run run the command and return exit code.
@param array $args
@return int | [
"run",
"run",
"the",
"command",
"and",
"return",
"exit",
"code",
"."
] | 7c4371911369d7c9d4463127bcd285144d7347ee | https://github.com/raframework/rapkg/blob/7c4371911369d7c9d4463127bcd285144d7347ee/src/Rapkg/Cli/App.php#L60-L67 | train |
Kris-Kuiper/sFire-Framework | src/MVC/Service.php | Service.config | protected function config($data = []) {
if(null === $data) {
$data = [];
}
if(false === is_array($data)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
}
$module = Router :: getRoute() -> getModule();
return Config :: get(array_merge([$module], $data));
} | php | protected function config($data = []) {
if(null === $data) {
$data = [];
}
if(false === is_array($data)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
}
$module = Router :: getRoute() -> getModule();
return Config :: get(array_merge([$module], $data));
} | [
"protected",
"function",
"config",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"false",
"===",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 passed to %s() must be of the type array, \"%s\" given'",
",",
"__METHOD__",
",",
"gettype",
"(",
"$",
"data",
")",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"$",
"module",
"=",
"Router",
"::",
"getRoute",
"(",
")",
"->",
"getModule",
"(",
")",
";",
"return",
"Config",
"::",
"get",
"(",
"array_merge",
"(",
"[",
"$",
"module",
"]",
",",
"$",
"data",
")",
")",
";",
"}"
] | Returns the config for the current module
@param array $data
@return mixed | [
"Returns",
"the",
"config",
"for",
"the",
"current",
"module"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/Service.php#L59-L72 | train |
praxigento/mobi_mod_pv | Plugin/Magento/Catalog/Block/Product/ListProduct.php | ListProduct.aroundGetProductPrice | public function aroundGetProductPrice(
\Magento\Catalog\Block\Product\ListProduct $subject,
\Closure $proceed,
\Magento\Catalog\Model\Product $product
) {
$result = $proceed($product);
$canSeePv = $this->hlpCust->canSeePv();
if ($canSeePv) {
$domId = "prxgt_pv_" . $product->getId();
$pvProd = $product->getData(AProdCollFactory::A_PV_PRODUCT);
$pvProd = $this->hlpFormat->toNumber($pvProd);
$html = "<div id=\"$domId\"><span>$pvProd</span> PV</div>";
$result = $html . $result;
}
return $result;
} | php | public function aroundGetProductPrice(
\Magento\Catalog\Block\Product\ListProduct $subject,
\Closure $proceed,
\Magento\Catalog\Model\Product $product
) {
$result = $proceed($product);
$canSeePv = $this->hlpCust->canSeePv();
if ($canSeePv) {
$domId = "prxgt_pv_" . $product->getId();
$pvProd = $product->getData(AProdCollFactory::A_PV_PRODUCT);
$pvProd = $this->hlpFormat->toNumber($pvProd);
$html = "<div id=\"$domId\"><span>$pvProd</span> PV</div>";
$result = $html . $result;
}
return $result;
} | [
"public",
"function",
"aroundGetProductPrice",
"(",
"\\",
"Magento",
"\\",
"Catalog",
"\\",
"Block",
"\\",
"Product",
"\\",
"ListProduct",
"$",
"subject",
",",
"\\",
"Closure",
"$",
"proceed",
",",
"\\",
"Magento",
"\\",
"Catalog",
"\\",
"Model",
"\\",
"Product",
"$",
"product",
")",
"{",
"$",
"result",
"=",
"$",
"proceed",
"(",
"$",
"product",
")",
";",
"$",
"canSeePv",
"=",
"$",
"this",
"->",
"hlpCust",
"->",
"canSeePv",
"(",
")",
";",
"if",
"(",
"$",
"canSeePv",
")",
"{",
"$",
"domId",
"=",
"\"prxgt_pv_\"",
".",
"$",
"product",
"->",
"getId",
"(",
")",
";",
"$",
"pvProd",
"=",
"$",
"product",
"->",
"getData",
"(",
"AProdCollFactory",
"::",
"A_PV_PRODUCT",
")",
";",
"$",
"pvProd",
"=",
"$",
"this",
"->",
"hlpFormat",
"->",
"toNumber",
"(",
"$",
"pvProd",
")",
";",
"$",
"html",
"=",
"\"<div id=\\\"$domId\\\"><span>$pvProd</span> PV</div>\"",
";",
"$",
"result",
"=",
"$",
"html",
".",
"$",
"result",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Insert PV HTML before product price HTML.
@param \Magento\Catalog\Block\Product\ListProduct $subject
@param \Closure $proceed
@param \Magento\Catalog\Model\Product $product
@return mixed|string | [
"Insert",
"PV",
"HTML",
"before",
"product",
"price",
"HTML",
"."
] | d1540b7e94264527006e8b9fa68904a72a63928e | https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Plugin/Magento/Catalog/Block/Product/ListProduct.php#L33-L48 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility.drawByBlock | public function drawByBlock ( array $text ) {
$maxWidth = 0;
foreach ( $text as $line ) {
$this->drawByLine($line, true);
$lineWidth = $this->_getActualLength($line);
if ( $lineWidth > $maxWidth ) {
$maxWidth = $lineWidth;
}
}
$this->_canvasSize[0] += $maxWidth;
echo $this->_cursor
->setAncor()
->move($maxWidth, -count($text))
->getEscapeSequencesByPath();
return $this;
} | php | public function drawByBlock ( array $text ) {
$maxWidth = 0;
foreach ( $text as $line ) {
$this->drawByLine($line, true);
$lineWidth = $this->_getActualLength($line);
if ( $lineWidth > $maxWidth ) {
$maxWidth = $lineWidth;
}
}
$this->_canvasSize[0] += $maxWidth;
echo $this->_cursor
->setAncor()
->move($maxWidth, -count($text))
->getEscapeSequencesByPath();
return $this;
} | [
"public",
"function",
"drawByBlock",
"(",
"array",
"$",
"text",
")",
"{",
"$",
"maxWidth",
"=",
"0",
";",
"foreach",
"(",
"$",
"text",
"as",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"drawByLine",
"(",
"$",
"line",
",",
"true",
")",
";",
"$",
"lineWidth",
"=",
"$",
"this",
"->",
"_getActualLength",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"lineWidth",
">",
"$",
"maxWidth",
")",
"{",
"$",
"maxWidth",
"=",
"$",
"lineWidth",
";",
"}",
"}",
"$",
"this",
"->",
"_canvasSize",
"[",
"0",
"]",
"+=",
"$",
"maxWidth",
";",
"echo",
"$",
"this",
"->",
"_cursor",
"->",
"setAncor",
"(",
")",
"->",
"move",
"(",
"$",
"maxWidth",
",",
"-",
"count",
"(",
"$",
"text",
")",
")",
"->",
"getEscapeSequencesByPath",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Draw by block
@param array $text Drawing text with decoration tags
@return CuiUtility Self instance | [
"Draw",
"by",
"block"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L94-L109 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility.drawByLine | public function drawByLine ( $text, $insertLineFeeds = true ) {
$convertedText = $this->_convertTagsToEscapeSequences($text);
echo $convertedText;
if ( $insertLineFeeds === true ) {
$width = $this->_getActualLength($text);
echo $this->_cursor
->insertLineFeeds($width)
->getEscapeSequencesByPath();
}
return $this;
} | php | public function drawByLine ( $text, $insertLineFeeds = true ) {
$convertedText = $this->_convertTagsToEscapeSequences($text);
echo $convertedText;
if ( $insertLineFeeds === true ) {
$width = $this->_getActualLength($text);
echo $this->_cursor
->insertLineFeeds($width)
->getEscapeSequencesByPath();
}
return $this;
} | [
"public",
"function",
"drawByLine",
"(",
"$",
"text",
",",
"$",
"insertLineFeeds",
"=",
"true",
")",
"{",
"$",
"convertedText",
"=",
"$",
"this",
"->",
"_convertTagsToEscapeSequences",
"(",
"$",
"text",
")",
";",
"echo",
"$",
"convertedText",
";",
"if",
"(",
"$",
"insertLineFeeds",
"===",
"true",
")",
"{",
"$",
"width",
"=",
"$",
"this",
"->",
"_getActualLength",
"(",
"$",
"text",
")",
";",
"echo",
"$",
"this",
"->",
"_cursor",
"->",
"insertLineFeeds",
"(",
"$",
"width",
")",
"->",
"getEscapeSequencesByPath",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Draw by line
@param string $text Drawing text with decoration tags
@param bool $insertLineFeeds Which insert line feeds
@return CuiUtility Self instance | [
"Draw",
"by",
"line"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L118-L128 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility.finishDrawingByBlock | public function finishDrawingByBlock ( ) {
$canvasHeight = $this->_canvasSize[1];
echo str_repeat("\n", $canvasHeight);
$this->_cursor->moveHome()
->move(0, $canvasHeight);
return $this;
} | php | public function finishDrawingByBlock ( ) {
$canvasHeight = $this->_canvasSize[1];
echo str_repeat("\n", $canvasHeight);
$this->_cursor->moveHome()
->move(0, $canvasHeight);
return $this;
} | [
"public",
"function",
"finishDrawingByBlock",
"(",
")",
"{",
"$",
"canvasHeight",
"=",
"$",
"this",
"->",
"_canvasSize",
"[",
"1",
"]",
";",
"echo",
"str_repeat",
"(",
"\"\\n\"",
",",
"$",
"canvasHeight",
")",
";",
"$",
"this",
"->",
"_cursor",
"->",
"moveHome",
"(",
")",
"->",
"move",
"(",
"0",
",",
"$",
"canvasHeight",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Finish drawing by block
@return CuiUtility Self instance | [
"Finish",
"drawing",
"by",
"block"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L135-L141 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility.getWindowSize | public static function getWindowSize ( ) {
$terminal = exec('echo $TERM_PROGRAM');
if ( $terminal === 'Apple_Terminal' ) {
$windowWidth = exec('tput cols');
$windowHeight = exec('tput lines');
}
$windowWidth = ( $windowWidth > 0 ) ? $windowWidth : self::DEFAULT_WINDOW_WIDTH;
$windowHeight = ( $windowHeight > 0 ) ? $windowHeight : self::DEFAULT_WINDOW_HEIGHT;
return array($windowWidth, $windowHeight);
} | php | public static function getWindowSize ( ) {
$terminal = exec('echo $TERM_PROGRAM');
if ( $terminal === 'Apple_Terminal' ) {
$windowWidth = exec('tput cols');
$windowHeight = exec('tput lines');
}
$windowWidth = ( $windowWidth > 0 ) ? $windowWidth : self::DEFAULT_WINDOW_WIDTH;
$windowHeight = ( $windowHeight > 0 ) ? $windowHeight : self::DEFAULT_WINDOW_HEIGHT;
return array($windowWidth, $windowHeight);
} | [
"public",
"static",
"function",
"getWindowSize",
"(",
")",
"{",
"$",
"terminal",
"=",
"exec",
"(",
"'echo $TERM_PROGRAM'",
")",
";",
"if",
"(",
"$",
"terminal",
"===",
"'Apple_Terminal'",
")",
"{",
"$",
"windowWidth",
"=",
"exec",
"(",
"'tput cols'",
")",
";",
"$",
"windowHeight",
"=",
"exec",
"(",
"'tput lines'",
")",
";",
"}",
"$",
"windowWidth",
"=",
"(",
"$",
"windowWidth",
">",
"0",
")",
"?",
"$",
"windowWidth",
":",
"self",
"::",
"DEFAULT_WINDOW_WIDTH",
";",
"$",
"windowHeight",
"=",
"(",
"$",
"windowHeight",
">",
"0",
")",
"?",
"$",
"windowHeight",
":",
"self",
"::",
"DEFAULT_WINDOW_HEIGHT",
";",
"return",
"array",
"(",
"$",
"windowWidth",
",",
"$",
"windowHeight",
")",
";",
"}"
] | Get terminal window size
@return array (width, height) | [
"Get",
"terminal",
"window",
"size"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L148-L157 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility._convertTagsToEscapeSequences | private function _convertTagsToEscapeSequences ( $text ) {
list($patterns, $replacements) = $this->_getConvertingDictionary();
$convertedText = preg_replace($patterns, $replacements, $text);
return $convertedText;
} | php | private function _convertTagsToEscapeSequences ( $text ) {
list($patterns, $replacements) = $this->_getConvertingDictionary();
$convertedText = preg_replace($patterns, $replacements, $text);
return $convertedText;
} | [
"private",
"function",
"_convertTagsToEscapeSequences",
"(",
"$",
"text",
")",
"{",
"list",
"(",
"$",
"patterns",
",",
"$",
"replacements",
")",
"=",
"$",
"this",
"->",
"_getConvertingDictionary",
"(",
")",
";",
"$",
"convertedText",
"=",
"preg_replace",
"(",
"$",
"patterns",
",",
"$",
"replacements",
",",
"$",
"text",
")",
";",
"return",
"$",
"convertedText",
";",
"}"
] | Convert tags to escape sequences
@param string $text Text with decoration tags
@return string Converted text | [
"Convert",
"tags",
"to",
"escape",
"sequences"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L165-L169 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility._getActualLength | private function _getActualLength ( $text ) {
$convertedText = $this->_convertTagsToEscapeSequences($text);
$strippedText = $this->_stripEscapeSequences($convertedText);
$length = mb_strlen($strippedText, 'utf-8');
return $length;
} | php | private function _getActualLength ( $text ) {
$convertedText = $this->_convertTagsToEscapeSequences($text);
$strippedText = $this->_stripEscapeSequences($convertedText);
$length = mb_strlen($strippedText, 'utf-8');
return $length;
} | [
"private",
"function",
"_getActualLength",
"(",
"$",
"text",
")",
"{",
"$",
"convertedText",
"=",
"$",
"this",
"->",
"_convertTagsToEscapeSequences",
"(",
"$",
"text",
")",
";",
"$",
"strippedText",
"=",
"$",
"this",
"->",
"_stripEscapeSequences",
"(",
"$",
"convertedText",
")",
";",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"strippedText",
",",
"'utf-8'",
")",
";",
"return",
"$",
"length",
";",
"}"
] | Get actual length
@param string $text Original text
@return int Actual length | [
"Get",
"actual",
"length"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L189-L194 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/CuiUtility.php | CuiUtility._getConvertingDictionary | private function _getConvertingDictionary ( ) {
$definedColors = DecorationsObject::getDefinedColors();
foreach ( $definedColors as $colorName => $escapeSequences ) {
list($textColorEscapeSequence, $backgroundColorEscapeSequence) = $escapeSequences;
$patterns[] = "|<tc:$colorName>|";
$replacements[] = $textColorEscapeSequence;
$patterns[] = "|<bc:$colorName>|";
$replacements[] = $backgroundColorEscapeSequence;
}
$resetEscapeSequences = $definedColors['reset'];
$patterns[] = '|</tc>|';
$replacements[] = $resetEscapeSequences[0];
$patterns[] = '|</bc>|';
$replacements[] = $resetEscapeSequences[1];
$definedStyles = DecorationsObject::getDefinedStyles();
$resetEscapeSequence = $definedStyles['reset'];
foreach ( $definedStyles as $styleName => $escapeSequence ) {
$patterns[] = "|<$styleName>|";
$replacements[] = $escapeSequence;
$patterns[] = "|</$styleName>|";
$replacements[] = $escapeSequence;
}
$dictionary = array($patterns, $replacements);
return $dictionary;
} | php | private function _getConvertingDictionary ( ) {
$definedColors = DecorationsObject::getDefinedColors();
foreach ( $definedColors as $colorName => $escapeSequences ) {
list($textColorEscapeSequence, $backgroundColorEscapeSequence) = $escapeSequences;
$patterns[] = "|<tc:$colorName>|";
$replacements[] = $textColorEscapeSequence;
$patterns[] = "|<bc:$colorName>|";
$replacements[] = $backgroundColorEscapeSequence;
}
$resetEscapeSequences = $definedColors['reset'];
$patterns[] = '|</tc>|';
$replacements[] = $resetEscapeSequences[0];
$patterns[] = '|</bc>|';
$replacements[] = $resetEscapeSequences[1];
$definedStyles = DecorationsObject::getDefinedStyles();
$resetEscapeSequence = $definedStyles['reset'];
foreach ( $definedStyles as $styleName => $escapeSequence ) {
$patterns[] = "|<$styleName>|";
$replacements[] = $escapeSequence;
$patterns[] = "|</$styleName>|";
$replacements[] = $escapeSequence;
}
$dictionary = array($patterns, $replacements);
return $dictionary;
} | [
"private",
"function",
"_getConvertingDictionary",
"(",
")",
"{",
"$",
"definedColors",
"=",
"DecorationsObject",
"::",
"getDefinedColors",
"(",
")",
";",
"foreach",
"(",
"$",
"definedColors",
"as",
"$",
"colorName",
"=>",
"$",
"escapeSequences",
")",
"{",
"list",
"(",
"$",
"textColorEscapeSequence",
",",
"$",
"backgroundColorEscapeSequence",
")",
"=",
"$",
"escapeSequences",
";",
"$",
"patterns",
"[",
"]",
"=",
"\"|<tc:$colorName>|\"",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"textColorEscapeSequence",
";",
"$",
"patterns",
"[",
"]",
"=",
"\"|<bc:$colorName>|\"",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"backgroundColorEscapeSequence",
";",
"}",
"$",
"resetEscapeSequences",
"=",
"$",
"definedColors",
"[",
"'reset'",
"]",
";",
"$",
"patterns",
"[",
"]",
"=",
"'|</tc>|'",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"resetEscapeSequences",
"[",
"0",
"]",
";",
"$",
"patterns",
"[",
"]",
"=",
"'|</bc>|'",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"resetEscapeSequences",
"[",
"1",
"]",
";",
"$",
"definedStyles",
"=",
"DecorationsObject",
"::",
"getDefinedStyles",
"(",
")",
";",
"$",
"resetEscapeSequence",
"=",
"$",
"definedStyles",
"[",
"'reset'",
"]",
";",
"foreach",
"(",
"$",
"definedStyles",
"as",
"$",
"styleName",
"=>",
"$",
"escapeSequence",
")",
"{",
"$",
"patterns",
"[",
"]",
"=",
"\"|<$styleName>|\"",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"escapeSequence",
";",
"$",
"patterns",
"[",
"]",
"=",
"\"|</$styleName>|\"",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"escapeSequence",
";",
"}",
"$",
"dictionary",
"=",
"array",
"(",
"$",
"patterns",
",",
"$",
"replacements",
")",
";",
"return",
"$",
"dictionary",
";",
"}"
] | Get converting dictionary
@return array Converting dictionary | [
"Get",
"converting",
"dictionary"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility.php#L201-L228 | train |
Sectorr/Core | Sectorr/Core/Http/Redirect.php | Redirect.back | public static function back()
{
$referer = $_SERVER['HTTP_REFERER'];
if (! empty($referer)) {
return self::redirect($referer);
}
return self::redirect('/');
} | php | public static function back()
{
$referer = $_SERVER['HTTP_REFERER'];
if (! empty($referer)) {
return self::redirect($referer);
}
return self::redirect('/');
} | [
"public",
"static",
"function",
"back",
"(",
")",
"{",
"$",
"referer",
"=",
"$",
"_SERVER",
"[",
"'HTTP_REFERER'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"referer",
")",
")",
"{",
"return",
"self",
"::",
"redirect",
"(",
"$",
"referer",
")",
";",
"}",
"return",
"self",
"::",
"redirect",
"(",
"'/'",
")",
";",
"}"
] | Redirect to HTTP referer.
@return mixed | [
"Redirect",
"to",
"HTTP",
"referer",
"."
] | 31df852dc6cc61642b0b87d9f0ae56c8e7da5a27 | https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Http/Redirect.php#L52-L61 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.index | public function index($trashed = false)
{
$this->authorize(PostsPolicy::PERMISSION_LIST);
$posts = $this->post->with(['author', 'category'])->when($trashed, function ($query) {
return $query->onlyTrashed();
})->paginate(30);
$title = trans('blog::posts.titles.posts-list');
$this->setTitle($title . ($trashed ? ' - '.trans('core::generals.trashed') : ''));
$this->addBreadcrumb($title);
return $this->view('admin.posts.index', compact('trashed', 'posts'));
} | php | public function index($trashed = false)
{
$this->authorize(PostsPolicy::PERMISSION_LIST);
$posts = $this->post->with(['author', 'category'])->when($trashed, function ($query) {
return $query->onlyTrashed();
})->paginate(30);
$title = trans('blog::posts.titles.posts-list');
$this->setTitle($title . ($trashed ? ' - '.trans('core::generals.trashed') : ''));
$this->addBreadcrumb($title);
return $this->view('admin.posts.index', compact('trashed', 'posts'));
} | [
"public",
"function",
"index",
"(",
"$",
"trashed",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_LIST",
")",
";",
"$",
"posts",
"=",
"$",
"this",
"->",
"post",
"->",
"with",
"(",
"[",
"'author'",
",",
"'category'",
"]",
")",
"->",
"when",
"(",
"$",
"trashed",
",",
"function",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"onlyTrashed",
"(",
")",
";",
"}",
")",
"->",
"paginate",
"(",
"30",
")",
";",
"$",
"title",
"=",
"trans",
"(",
"'blog::posts.titles.posts-list'",
")",
";",
"$",
"this",
"->",
"setTitle",
"(",
"$",
"title",
".",
"(",
"$",
"trashed",
"?",
"' - '",
".",
"trans",
"(",
"'core::generals.trashed'",
")",
":",
"''",
")",
")",
";",
"$",
"this",
"->",
"addBreadcrumb",
"(",
"$",
"title",
")",
";",
"return",
"$",
"this",
"->",
"view",
"(",
"'admin.posts.index'",
",",
"compact",
"(",
"'trashed'",
",",
"'posts'",
")",
")",
";",
"}"
] | List the posts.
@param bool $trashed
@return \Illuminate\View\View | [
"List",
"the",
"posts",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L63-L76 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.store | public function store(CreatePostRequest $request)
{
$this->authorize(PostsPolicy::PERMISSION_CREATE);
$post = Post::createOne($request->getValidatedData());
$this->transNotification('created', ['title' => $post->title], $post->toArray());
return redirect()->route('admin::blog.posts.show', [$post]);
} | php | public function store(CreatePostRequest $request)
{
$this->authorize(PostsPolicy::PERMISSION_CREATE);
$post = Post::createOne($request->getValidatedData());
$this->transNotification('created', ['title' => $post->title], $post->toArray());
return redirect()->route('admin::blog.posts.show', [$post]);
} | [
"public",
"function",
"store",
"(",
"CreatePostRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_CREATE",
")",
";",
"$",
"post",
"=",
"Post",
"::",
"createOne",
"(",
"$",
"request",
"->",
"getValidatedData",
"(",
")",
")",
";",
"$",
"this",
"->",
"transNotification",
"(",
"'created'",
",",
"[",
"'title'",
"=>",
"$",
"post",
"->",
"title",
"]",
",",
"$",
"post",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'admin::blog.posts.show'",
",",
"[",
"$",
"post",
"]",
")",
";",
"}"
] | Store the post.
@param \Arcanesoft\Blog\Http\Requests\Admin\Posts\CreatePostRequest $request
@return \Illuminate\Http\RedirectResponse | [
"Store",
"the",
"post",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L114-L123 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.show | public function show(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_SHOW);
$post = $post->load(['author', 'category', 'tags', 'seo']);
$this->setTitle(trans('blog::posts.titles.post-details'));
$this->addBreadcrumb($post->title);
return $this->view('admin.posts.show', compact('post'));
} | php | public function show(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_SHOW);
$post = $post->load(['author', 'category', 'tags', 'seo']);
$this->setTitle(trans('blog::posts.titles.post-details'));
$this->addBreadcrumb($post->title);
return $this->view('admin.posts.show', compact('post'));
} | [
"public",
"function",
"show",
"(",
"Post",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_SHOW",
")",
";",
"$",
"post",
"=",
"$",
"post",
"->",
"load",
"(",
"[",
"'author'",
",",
"'category'",
",",
"'tags'",
",",
"'seo'",
"]",
")",
";",
"$",
"this",
"->",
"setTitle",
"(",
"trans",
"(",
"'blog::posts.titles.post-details'",
")",
")",
";",
"$",
"this",
"->",
"addBreadcrumb",
"(",
"$",
"post",
"->",
"title",
")",
";",
"return",
"$",
"this",
"->",
"view",
"(",
"'admin.posts.show'",
",",
"compact",
"(",
"'post'",
")",
")",
";",
"}"
] | Show a post.
@param \Arcanesoft\Blog\Models\Post $post
@return \Illuminate\View\View | [
"Show",
"a",
"post",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L132-L142 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.edit | public function edit(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
$this->setTitle($title = trans('blog::posts.titles.edit-post'));
$this->addBreadcrumb($title);
$categories = Category::getSelectData();
$tags = Tag::getSelectData();
$statuses = Post::getStatuses();
return $this->view('admin.posts.edit', compact('post', 'categories', 'tags', 'statuses'));
} | php | public function edit(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
$this->setTitle($title = trans('blog::posts.titles.edit-post'));
$this->addBreadcrumb($title);
$categories = Category::getSelectData();
$tags = Tag::getSelectData();
$statuses = Post::getStatuses();
return $this->view('admin.posts.edit', compact('post', 'categories', 'tags', 'statuses'));
} | [
"public",
"function",
"edit",
"(",
"Post",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_UPDATE",
")",
";",
"$",
"this",
"->",
"setTitle",
"(",
"$",
"title",
"=",
"trans",
"(",
"'blog::posts.titles.edit-post'",
")",
")",
";",
"$",
"this",
"->",
"addBreadcrumb",
"(",
"$",
"title",
")",
";",
"$",
"categories",
"=",
"Category",
"::",
"getSelectData",
"(",
")",
";",
"$",
"tags",
"=",
"Tag",
"::",
"getSelectData",
"(",
")",
";",
"$",
"statuses",
"=",
"Post",
"::",
"getStatuses",
"(",
")",
";",
"return",
"$",
"this",
"->",
"view",
"(",
"'admin.posts.edit'",
",",
"compact",
"(",
"'post'",
",",
"'categories'",
",",
"'tags'",
",",
"'statuses'",
")",
")",
";",
"}"
] | Edit a post.
@param \Arcanesoft\Blog\Models\Post $post
@return \Illuminate\View\View | [
"Edit",
"a",
"post",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L151-L163 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.update | public function update(Post $post, UpdatePostRequest $request)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
$post->updateOne($request->getValidatedData());
$this->transNotification('updated', ['title' => $post->title], $post->toArray());
return redirect()->route('admin::blog.posts.show', [$post]);
} | php | public function update(Post $post, UpdatePostRequest $request)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
$post->updateOne($request->getValidatedData());
$this->transNotification('updated', ['title' => $post->title], $post->toArray());
return redirect()->route('admin::blog.posts.show', [$post]);
} | [
"public",
"function",
"update",
"(",
"Post",
"$",
"post",
",",
"UpdatePostRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_UPDATE",
")",
";",
"$",
"post",
"->",
"updateOne",
"(",
"$",
"request",
"->",
"getValidatedData",
"(",
")",
")",
";",
"$",
"this",
"->",
"transNotification",
"(",
"'updated'",
",",
"[",
"'title'",
"=>",
"$",
"post",
"->",
"title",
"]",
",",
"$",
"post",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'admin::blog.posts.show'",
",",
"[",
"$",
"post",
"]",
")",
";",
"}"
] | Update the post.
@param \Arcanesoft\Blog\Models\Post $post
@param \Arcanesoft\Blog\Http\Requests\Admin\Posts\UpdatePostRequest $request
@return \Illuminate\Http\RedirectResponse | [
"Update",
"the",
"post",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L173-L182 | train |
ARCANESOFT/Blog | src/Http/Controllers/Admin/PostsController.php | PostsController.restore | public function restore(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
try {
$post->restore();
return $this->jsonResponseSuccess([
'message' => $this->transNotification('restored', ['title' => $post->title], $post->toArray())
]);
}
catch (\Exception $e) {
return $this->jsonResponseError(['message' => $e->getMessage()], 500);
}
} | php | public function restore(Post $post)
{
$this->authorize(PostsPolicy::PERMISSION_UPDATE);
try {
$post->restore();
return $this->jsonResponseSuccess([
'message' => $this->transNotification('restored', ['title' => $post->title], $post->toArray())
]);
}
catch (\Exception $e) {
return $this->jsonResponseError(['message' => $e->getMessage()], 500);
}
} | [
"public",
"function",
"restore",
"(",
"Post",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"PostsPolicy",
"::",
"PERMISSION_UPDATE",
")",
";",
"try",
"{",
"$",
"post",
"->",
"restore",
"(",
")",
";",
"return",
"$",
"this",
"->",
"jsonResponseSuccess",
"(",
"[",
"'message'",
"=>",
"$",
"this",
"->",
"transNotification",
"(",
"'restored'",
",",
"[",
"'title'",
"=>",
"$",
"post",
"->",
"title",
"]",
",",
"$",
"post",
"->",
"toArray",
"(",
")",
")",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResponseError",
"(",
"[",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
",",
"500",
")",
";",
"}",
"}"
] | Restore a trashed post.
@param \Arcanesoft\Blog\Models\Post $post
@return \Illuminate\Http\JsonResponse | [
"Restore",
"a",
"trashed",
"post",
"."
] | 2078fdfdcbccda161c02899b9e1f344f011b2859 | https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Controllers/Admin/PostsController.php#L205-L219 | train |
miaoxing/plugin | src/Model/SoftDeleteTrait.php | SoftDeleteTrait.executeDestroy | protected function executeDestroy()
{
if ($this->reallyDestroy) {
parent::executeDestroy();
} else {
$this->saveData([
$this->deletedAtColumn => date('Y-m-d H:i:s'),
$this->deletedByColumn => $this->curUser['id'],
]);
}
} | php | protected function executeDestroy()
{
if ($this->reallyDestroy) {
parent::executeDestroy();
} else {
$this->saveData([
$this->deletedAtColumn => date('Y-m-d H:i:s'),
$this->deletedByColumn => $this->curUser['id'],
]);
}
} | [
"protected",
"function",
"executeDestroy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reallyDestroy",
")",
"{",
"parent",
"::",
"executeDestroy",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"saveData",
"(",
"[",
"$",
"this",
"->",
"deletedAtColumn",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"$",
"this",
"->",
"deletedByColumn",
"=>",
"$",
"this",
"->",
"curUser",
"[",
"'id'",
"]",
",",
"]",
")",
";",
"}",
"}"
] | Overwrite original destroy logic. | [
"Overwrite",
"original",
"destroy",
"logic",
"."
] | f287a1e6c97abba6f06906255b8c26e8ab0afe61 | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Model/SoftDeleteTrait.php#L91-L101 | train |
chee-commerce/CheeVersion | src/Version.php | Version.getFloatMajor | public function getFloatMajor()
{
if ($this->startsWith($this->major, '0'))
return (float) ('0.'.substr($this->major, 1));
return (float) $this->major;
} | php | public function getFloatMajor()
{
if ($this->startsWith($this->major, '0'))
return (float) ('0.'.substr($this->major, 1));
return (float) $this->major;
} | [
"public",
"function",
"getFloatMajor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"major",
",",
"'0'",
")",
")",
"return",
"(",
"float",
")",
"(",
"'0.'",
".",
"substr",
"(",
"$",
"this",
"->",
"major",
",",
"1",
")",
")",
";",
"return",
"(",
"float",
")",
"$",
"this",
"->",
"major",
";",
"}"
] | Get floated major
@return float | [
"Get",
"floated",
"major"
] | b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c | https://github.com/chee-commerce/CheeVersion/blob/b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c/src/Version.php#L117-L122 | train |
chee-commerce/CheeVersion | src/Version.php | Version.getFloatMinor | public function getFloatMinor()
{
if ($this->startsWith($this->minor, '0'))
return (float) ('0.'.substr($this->minor, 1));
return (float) $this->minor;
} | php | public function getFloatMinor()
{
if ($this->startsWith($this->minor, '0'))
return (float) ('0.'.substr($this->minor, 1));
return (float) $this->minor;
} | [
"public",
"function",
"getFloatMinor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"minor",
",",
"'0'",
")",
")",
"return",
"(",
"float",
")",
"(",
"'0.'",
".",
"substr",
"(",
"$",
"this",
"->",
"minor",
",",
"1",
")",
")",
";",
"return",
"(",
"float",
")",
"$",
"this",
"->",
"minor",
";",
"}"
] | Get floated minor
@return float | [
"Get",
"floated",
"minor"
] | b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c | https://github.com/chee-commerce/CheeVersion/blob/b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c/src/Version.php#L139-L144 | train |
chee-commerce/CheeVersion | src/Version.php | Version.getFloatPath | public function getFloatPath()
{
if ($this->startsWith($this->path, '0'))
return (float) ('0.'.substr($this->path, 1));
return (float) $this->path;
} | php | public function getFloatPath()
{
if ($this->startsWith($this->path, '0'))
return (float) ('0.'.substr($this->path, 1));
return (float) $this->path;
} | [
"public",
"function",
"getFloatPath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"path",
",",
"'0'",
")",
")",
"return",
"(",
"float",
")",
"(",
"'0.'",
".",
"substr",
"(",
"$",
"this",
"->",
"path",
",",
"1",
")",
")",
";",
"return",
"(",
"float",
")",
"$",
"this",
"->",
"path",
";",
"}"
] | Get floated path
@return float | [
"Get",
"floated",
"path"
] | b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c | https://github.com/chee-commerce/CheeVersion/blob/b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c/src/Version.php#L161-L166 | train |
chee-commerce/CheeVersion | src/Version.php | Version.isPartOf | public function isPartOf(Version $version)
{
if (is_null($version->getOperator()))
{
if ($this->major == $version->getMajor() && $this->minor == $version->getMinor() && $this->path == $version->getPath())
return true;
return false;
}
switch ($version->getOperator())
{
case self::GREATER:
return $this->mustGreaterThan($version);
break;
case self::GREATER_EQUAL:
return $this->mustGreaterEqualThan($version);
break;
case self::TILDE:
return $this->mustTilde($version);
break;
}
} | php | public function isPartOf(Version $version)
{
if (is_null($version->getOperator()))
{
if ($this->major == $version->getMajor() && $this->minor == $version->getMinor() && $this->path == $version->getPath())
return true;
return false;
}
switch ($version->getOperator())
{
case self::GREATER:
return $this->mustGreaterThan($version);
break;
case self::GREATER_EQUAL:
return $this->mustGreaterEqualThan($version);
break;
case self::TILDE:
return $this->mustTilde($version);
break;
}
} | [
"public",
"function",
"isPartOf",
"(",
"Version",
"$",
"version",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"version",
"->",
"getOperator",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"major",
"==",
"$",
"version",
"->",
"getMajor",
"(",
")",
"&&",
"$",
"this",
"->",
"minor",
"==",
"$",
"version",
"->",
"getMinor",
"(",
")",
"&&",
"$",
"this",
"->",
"path",
"==",
"$",
"version",
"->",
"getPath",
"(",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}",
"switch",
"(",
"$",
"version",
"->",
"getOperator",
"(",
")",
")",
"{",
"case",
"self",
"::",
"GREATER",
":",
"return",
"$",
"this",
"->",
"mustGreaterThan",
"(",
"$",
"version",
")",
";",
"break",
";",
"case",
"self",
"::",
"GREATER_EQUAL",
":",
"return",
"$",
"this",
"->",
"mustGreaterEqualThan",
"(",
"$",
"version",
")",
";",
"break",
";",
"case",
"self",
"::",
"TILDE",
":",
"return",
"$",
"this",
"->",
"mustTilde",
"(",
"$",
"version",
")",
";",
"break",
";",
"}",
"}"
] | Is this version part of another version?
@param Chee\Version\Version $version
@return bool | [
"Is",
"this",
"version",
"part",
"of",
"another",
"version?"
] | b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c | https://github.com/chee-commerce/CheeVersion/blob/b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c/src/Version.php#L195-L217 | train |
chee-commerce/CheeVersion | src/Version.php | Version.detectOperator | protected function detectOperator()
{
if ($this->startsWith($this->version, self::GREATER_EQUAL))
{
$this->operator = self::GREATER_EQUAL;
$this->version = substr($this->version, 2);
}
else if ($this->startsWith($this->version, self::GREATER))
{
$this->operator = self::GREATER;
$this->version = substr($this->version, 1);
}
else if ($this->startsWith($this->version, self::TILDE))
{
$this->operator = self::TILDE;
$this->version = substr($this->version, 1);
}
} | php | protected function detectOperator()
{
if ($this->startsWith($this->version, self::GREATER_EQUAL))
{
$this->operator = self::GREATER_EQUAL;
$this->version = substr($this->version, 2);
}
else if ($this->startsWith($this->version, self::GREATER))
{
$this->operator = self::GREATER;
$this->version = substr($this->version, 1);
}
else if ($this->startsWith($this->version, self::TILDE))
{
$this->operator = self::TILDE;
$this->version = substr($this->version, 1);
}
} | [
"protected",
"function",
"detectOperator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"version",
",",
"self",
"::",
"GREATER_EQUAL",
")",
")",
"{",
"$",
"this",
"->",
"operator",
"=",
"self",
"::",
"GREATER_EQUAL",
";",
"$",
"this",
"->",
"version",
"=",
"substr",
"(",
"$",
"this",
"->",
"version",
",",
"2",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"version",
",",
"self",
"::",
"GREATER",
")",
")",
"{",
"$",
"this",
"->",
"operator",
"=",
"self",
"::",
"GREATER",
";",
"$",
"this",
"->",
"version",
"=",
"substr",
"(",
"$",
"this",
"->",
"version",
",",
"1",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"this",
"->",
"version",
",",
"self",
"::",
"TILDE",
")",
")",
"{",
"$",
"this",
"->",
"operator",
"=",
"self",
"::",
"TILDE",
";",
"$",
"this",
"->",
"version",
"=",
"substr",
"(",
"$",
"this",
"->",
"version",
",",
"1",
")",
";",
"}",
"}"
] | Detect operator of version
@return void | [
"Detect",
"operator",
"of",
"version"
] | b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c | https://github.com/chee-commerce/CheeVersion/blob/b4d7801f05784e5e4e89fc424dd66ae0f2d35d3c/src/Version.php#L224-L241 | train |
xelax90/xelax-site-config | src/XelaxSiteConfig/Options/Service/SiteConfigService.php | SiteConfigService.getConfig | public function getConfig($prefix){
/* @var $siteConfigService EyeService */
$siteConfigService = $this->getServiceLocator()->get(EyeService::class);
$config = $siteConfigService->getAll();
// get config selected by prefix
$prefixParts = explode('.', $prefix);
$conf = $config;
foreach ($prefixParts as $prefix) {
if(isset($conf[$prefix])){
$conf = $conf[$prefix];
} else {
$conf = array();
}
}
return $conf;
} | php | public function getConfig($prefix){
/* @var $siteConfigService EyeService */
$siteConfigService = $this->getServiceLocator()->get(EyeService::class);
$config = $siteConfigService->getAll();
// get config selected by prefix
$prefixParts = explode('.', $prefix);
$conf = $config;
foreach ($prefixParts as $prefix) {
if(isset($conf[$prefix])){
$conf = $conf[$prefix];
} else {
$conf = array();
}
}
return $conf;
} | [
"public",
"function",
"getConfig",
"(",
"$",
"prefix",
")",
"{",
"/* @var $siteConfigService EyeService */",
"$",
"siteConfigService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"EyeService",
"::",
"class",
")",
";",
"$",
"config",
"=",
"$",
"siteConfigService",
"->",
"getAll",
"(",
")",
";",
"// get config selected by prefix",
"$",
"prefixParts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"prefix",
")",
";",
"$",
"conf",
"=",
"$",
"config",
";",
"foreach",
"(",
"$",
"prefixParts",
"as",
"$",
"prefix",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"conf",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"$",
"conf",
"=",
"$",
"conf",
"[",
"$",
"prefix",
"]",
";",
"}",
"else",
"{",
"$",
"conf",
"=",
"array",
"(",
")",
";",
"}",
"}",
"return",
"$",
"conf",
";",
"}"
] | Get config for specified prefix
@param string $prefix
@return array | [
"Get",
"config",
"for",
"specified",
"prefix"
] | 76c86e2f716fc2c66b59124a69e35c4cadfeb3db | https://github.com/xelax90/xelax-site-config/blob/76c86e2f716fc2c66b59124a69e35c4cadfeb3db/src/XelaxSiteConfig/Options/Service/SiteConfigService.php#L20-L36 | train |
g4code/cron | src/CronExpression.php | CronExpression.setExpression | public function setExpression($value)
{
$this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
if (count($this->cronParts) < 6) {
throw new InvalidArgumentException(
$value . ' is not a valid CRON expression'
);
}
foreach ($this->cronParts as $position => $part) {
$this->setPart($position, $part);
}
return $this;
} | php | public function setExpression($value)
{
$this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY);
if (count($this->cronParts) < 6) {
throw new InvalidArgumentException(
$value . ' is not a valid CRON expression'
);
}
foreach ($this->cronParts as $position => $part) {
$this->setPart($position, $part);
}
return $this;
} | [
"public",
"function",
"setExpression",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"cronParts",
"=",
"preg_split",
"(",
"'/\\s/'",
",",
"$",
"value",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"cronParts",
")",
"<",
"6",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"value",
".",
"' is not a valid CRON expression'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"cronParts",
"as",
"$",
"position",
"=>",
"$",
"part",
")",
"{",
"$",
"this",
"->",
"setPart",
"(",
"$",
"position",
",",
"$",
"part",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set or change the CRON expression
@param string $schedule CRON expression (e.g. 8 * * * *)
@return CronExpression
@throws InvalidArgumentException if not a valid CRON expression | [
"Set",
"or",
"change",
"the",
"CRON",
"expression"
] | aae994c45e85b994ce5c581e9bd69f21ac28b8cb | https://github.com/g4code/cron/blob/aae994c45e85b994ce5c581e9bd69f21ac28b8cb/src/CronExpression.php#L99-L113 | train |
g4code/cron | src/CronExpression.php | CronExpression.setPart | public function setPart($position, $value)
{
if (!$this->fieldFactory->getField($position)->validate($value)) {
throw new InvalidArgumentException(
'Invalid CRON field value ' . $value . ' as position ' . $position
);
}
$this->cronParts[$position] = $value;
return $this;
} | php | public function setPart($position, $value)
{
if (!$this->fieldFactory->getField($position)->validate($value)) {
throw new InvalidArgumentException(
'Invalid CRON field value ' . $value . ' as position ' . $position
);
}
$this->cronParts[$position] = $value;
return $this;
} | [
"public",
"function",
"setPart",
"(",
"$",
"position",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fieldFactory",
"->",
"getField",
"(",
"$",
"position",
")",
"->",
"validate",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid CRON field value '",
".",
"$",
"value",
".",
"' as position '",
".",
"$",
"position",
")",
";",
"}",
"$",
"this",
"->",
"cronParts",
"[",
"$",
"position",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set part of the CRON expression
@param int $position The position of the CRON expression to set
@param string $value The value to set
@return CronExpression
@throws InvalidArgumentException if the value is not valid for the part | [
"Set",
"part",
"of",
"the",
"CRON",
"expression"
] | aae994c45e85b994ce5c581e9bd69f21ac28b8cb | https://github.com/g4code/cron/blob/aae994c45e85b994ce5c581e9bd69f21ac28b8cb/src/CronExpression.php#L124-L135 | train |
g4code/cron | src/CronExpression.php | CronExpression.isDue | public function isDue($currentTime = null)
{
if (null === $currentTime || 'now' === $currentTime) {
$currentDate = date('Y-m-d H:i:s');
$currentTime = strtotime($currentDate);
} elseif ($currentTime instanceof DateTime) {
$currentDate = $currentTime->format('Y-m-d H:i:s');
$currentTime = strtotime($currentDate);
} else {
$currentTime = new DateTime($currentTime);
$currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), $currentTime->format('s'));
$currentDate = $currentTime->format('Y-m-d H:i:s');
$currentTime = $currentTime->getTimeStamp();
}
return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
} | php | public function isDue($currentTime = null)
{
if (null === $currentTime || 'now' === $currentTime) {
$currentDate = date('Y-m-d H:i:s');
$currentTime = strtotime($currentDate);
} elseif ($currentTime instanceof DateTime) {
$currentDate = $currentTime->format('Y-m-d H:i:s');
$currentTime = strtotime($currentDate);
} else {
$currentTime = new DateTime($currentTime);
$currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), $currentTime->format('s'));
$currentDate = $currentTime->format('Y-m-d H:i:s');
$currentTime = $currentTime->getTimeStamp();
}
return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
} | [
"public",
"function",
"isDue",
"(",
"$",
"currentTime",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"currentTime",
"||",
"'now'",
"===",
"$",
"currentTime",
")",
"{",
"$",
"currentDate",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"currentTime",
"=",
"strtotime",
"(",
"$",
"currentDate",
")",
";",
"}",
"elseif",
"(",
"$",
"currentTime",
"instanceof",
"DateTime",
")",
"{",
"$",
"currentDate",
"=",
"$",
"currentTime",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"currentTime",
"=",
"strtotime",
"(",
"$",
"currentDate",
")",
";",
"}",
"else",
"{",
"$",
"currentTime",
"=",
"new",
"DateTime",
"(",
"$",
"currentTime",
")",
";",
"$",
"currentTime",
"->",
"setTime",
"(",
"$",
"currentTime",
"->",
"format",
"(",
"'H'",
")",
",",
"$",
"currentTime",
"->",
"format",
"(",
"'i'",
")",
",",
"$",
"currentTime",
"->",
"format",
"(",
"'s'",
")",
")",
";",
"$",
"currentDate",
"=",
"$",
"currentTime",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"currentTime",
"=",
"$",
"currentTime",
"->",
"getTimeStamp",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getNextRunDate",
"(",
"$",
"currentDate",
",",
"0",
",",
"true",
")",
"->",
"getTimestamp",
"(",
")",
"==",
"$",
"currentTime",
";",
"}"
] | Deterime if the cron is due to run based on the current date or a
specific date. This method assumes that the current number of
seconds are irrelevant, and should be called once per minute.
@param string|DateTime $currentTime (optional) Relative calculation date
@return bool Returns TRUE if the cron is due to run or FALSE if not | [
"Deterime",
"if",
"the",
"cron",
"is",
"due",
"to",
"run",
"based",
"on",
"the",
"current",
"date",
"or",
"a",
"specific",
"date",
".",
"This",
"method",
"assumes",
"that",
"the",
"current",
"number",
"of",
"seconds",
"are",
"irrelevant",
"and",
"should",
"be",
"called",
"once",
"per",
"minute",
"."
] | aae994c45e85b994ce5c581e9bd69f21ac28b8cb | https://github.com/g4code/cron/blob/aae994c45e85b994ce5c581e9bd69f21ac28b8cb/src/CronExpression.php#L166-L182 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.setProtocol | public function setProtocol($protocol)
{
switch(strtoupper($protocol))
{
case 'HTTP/1.0':
case 'HTTP/1.1':
$this->protocol = strtoupper($protocol);
break;
default:
throw new \OutOfRangeException(sprintf('Unsupported protocol: "%s"', $protocol));
}
return $this;
} | php | public function setProtocol($protocol)
{
switch(strtoupper($protocol))
{
case 'HTTP/1.0':
case 'HTTP/1.1':
$this->protocol = strtoupper($protocol);
break;
default:
throw new \OutOfRangeException(sprintf('Unsupported protocol: "%s"', $protocol));
}
return $this;
} | [
"public",
"function",
"setProtocol",
"(",
"$",
"protocol",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"$",
"protocol",
")",
")",
"{",
"case",
"'HTTP/1.0'",
":",
"case",
"'HTTP/1.1'",
":",
"$",
"this",
"->",
"protocol",
"=",
"strtoupper",
"(",
"$",
"protocol",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"OutOfRangeException",
"(",
"sprintf",
"(",
"'Unsupported protocol: \"%s\"'",
",",
"$",
"protocol",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the HTTP protocol being used.
@param string $protocol
@return HttpMessage | [
"Set",
"the",
"HTTP",
"protocol",
"being",
"used",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L83-L96 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.hasHeader | public function hasHeader($header)
{
if($header instanceof HttpHeaderInterface)
{
return !empty($this->headers[strtolower($header->getFieldName())]);
}
return !empty($this->headers[strtolower($header)]);
} | php | public function hasHeader($header)
{
if($header instanceof HttpHeaderInterface)
{
return !empty($this->headers[strtolower($header->getFieldName())]);
}
return !empty($this->headers[strtolower($header)]);
} | [
"public",
"function",
"hasHeader",
"(",
"$",
"header",
")",
"{",
"if",
"(",
"$",
"header",
"instanceof",
"HttpHeaderInterface",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"strtolower",
"(",
"$",
"header",
"->",
"getFieldName",
"(",
")",
")",
"]",
")",
";",
"}",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"strtolower",
"(",
"$",
"header",
")",
"]",
")",
";",
"}"
] | Check if an HTTP header with the given name is set.
@param string $header
@return boolean | [
"Check",
"if",
"an",
"HTTP",
"header",
"with",
"the",
"given",
"name",
"is",
"set",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L104-L112 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.getHeader | public function getHeader($header)
{
$n = ($header instanceof HttpHeaderInterface) ? strtolower($header->getFieldName()) : strtolower($header);
if(!empty($this->headers[$n]))
{
return $this->headers[$n][0][1];
}
if(func_num_args() > 1)
{
return func_get_arg(1);
}
$name = ($header instanceof HttpHeaderInterface) ? $header->getFieldName() : $header;
throw new \OutOfBoundsException(sprintf('HTTP header not found: "%s"', $name));
} | php | public function getHeader($header)
{
$n = ($header instanceof HttpHeaderInterface) ? strtolower($header->getFieldName()) : strtolower($header);
if(!empty($this->headers[$n]))
{
return $this->headers[$n][0][1];
}
if(func_num_args() > 1)
{
return func_get_arg(1);
}
$name = ($header instanceof HttpHeaderInterface) ? $header->getFieldName() : $header;
throw new \OutOfBoundsException(sprintf('HTTP header not found: "%s"', $name));
} | [
"public",
"function",
"getHeader",
"(",
"$",
"header",
")",
"{",
"$",
"n",
"=",
"(",
"$",
"header",
"instanceof",
"HttpHeaderInterface",
")",
"?",
"strtolower",
"(",
"$",
"header",
"->",
"getFieldName",
"(",
")",
")",
":",
"strtolower",
"(",
"$",
"header",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
")",
"{",
"return",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"name",
"=",
"(",
"$",
"header",
"instanceof",
"HttpHeaderInterface",
")",
"?",
"$",
"header",
"->",
"getFieldName",
"(",
")",
":",
"$",
"header",
";",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'HTTP header not found: \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"}"
] | Get the first HTTP header of the given type.
@param mixed $header A header name or an instance of HttpHeaderInterface.
@param mixed $default
@return string
@throws \OutOfBoundsException When no such header is set. | [
"Get",
"the",
"first",
"HTTP",
"header",
"of",
"the",
"given",
"type",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L123-L140 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.addHeader | public function addHeader($header, $value = NULL)
{
if($header instanceof HttpHeaderInterface)
{
$n = strtolower($header->getFieldName());
if(empty($this->headers[$n]))
{
$this->headers[$n] = [[(string)$header->getFieldName(), trim($header->getFieldValue())]];
}
else
{
$this->headers[$n][] = [(string)$header->getFieldName(), trim($header->getFieldValue())];
}
}
else
{
$n = strtolower($header);
if(empty($this->headers[$n]))
{
$this->headers[$n] = [[(string)$header, trim($value)]];
}
else
{
$this->headers[$n][] = [(string)$header, trim($value)];
}
}
return $this;
} | php | public function addHeader($header, $value = NULL)
{
if($header instanceof HttpHeaderInterface)
{
$n = strtolower($header->getFieldName());
if(empty($this->headers[$n]))
{
$this->headers[$n] = [[(string)$header->getFieldName(), trim($header->getFieldValue())]];
}
else
{
$this->headers[$n][] = [(string)$header->getFieldName(), trim($header->getFieldValue())];
}
}
else
{
$n = strtolower($header);
if(empty($this->headers[$n]))
{
$this->headers[$n] = [[(string)$header, trim($value)]];
}
else
{
$this->headers[$n][] = [(string)$header, trim($value)];
}
}
return $this;
} | [
"public",
"function",
"addHeader",
"(",
"$",
"header",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"header",
"instanceof",
"HttpHeaderInterface",
")",
"{",
"$",
"n",
"=",
"strtolower",
"(",
"$",
"header",
"->",
"getFieldName",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
")",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"=",
"[",
"[",
"(",
"string",
")",
"$",
"header",
"->",
"getFieldName",
"(",
")",
",",
"trim",
"(",
"$",
"header",
"->",
"getFieldValue",
"(",
")",
")",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"[",
"]",
"=",
"[",
"(",
"string",
")",
"$",
"header",
"->",
"getFieldName",
"(",
")",
",",
"trim",
"(",
"$",
"header",
"->",
"getFieldValue",
"(",
")",
")",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"n",
"=",
"strtolower",
"(",
"$",
"header",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
")",
")",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"=",
"[",
"[",
"(",
"string",
")",
"$",
"header",
",",
"trim",
"(",
"$",
"value",
")",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"[",
"]",
"=",
"[",
"(",
"string",
")",
"$",
"header",
",",
"trim",
"(",
"$",
"value",
")",
"]",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Add an HTTP header to the message.
@param mixed $header A header name or an instance of HttpHeaderInterface.
@param string $value
@return HttpMessage | [
"Add",
"an",
"HTTP",
"header",
"to",
"the",
"message",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L170-L200 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.removeHeader | public function removeHeader($header)
{
if($header instanceof HttpHeaderInterface)
{
unset($this->headers[strtolower($header->getFieldName())]);
}
else
{
unset($this->headers[strtolower($header)]);
}
return $this;
} | php | public function removeHeader($header)
{
if($header instanceof HttpHeaderInterface)
{
unset($this->headers[strtolower($header->getFieldName())]);
}
else
{
unset($this->headers[strtolower($header)]);
}
return $this;
} | [
"public",
"function",
"removeHeader",
"(",
"$",
"header",
")",
"{",
"if",
"(",
"$",
"header",
"instanceof",
"HttpHeaderInterface",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"strtolower",
"(",
"$",
"header",
"->",
"getFieldName",
"(",
")",
")",
"]",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"strtolower",
"(",
"$",
"header",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove all HTTP headers of the given type from the message.
@param mixed $header A header name or an instance of HttpHeaderInterface.
@return HttpMessage | [
"Remove",
"all",
"HTTP",
"headers",
"of",
"the",
"given",
"type",
"from",
"the",
"message",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L208-L220 | train |
koolkode/http | src/HttpMessage.php | HttpMessage.getHeaders | public function getHeaders($name = NULL)
{
if($name === NULL)
{
return $this->headers;
}
$n = strtolower($name);
if(empty($this->headers[$n]))
{
return [];
}
$headers = [];
foreach($this->headers[$n] as $data)
{
$headers[] = $data;
}
return $headers;
} | php | public function getHeaders($name = NULL)
{
if($name === NULL)
{
return $this->headers;
}
$n = strtolower($name);
if(empty($this->headers[$n]))
{
return [];
}
$headers = [];
foreach($this->headers[$n] as $data)
{
$headers[] = $data;
}
return $headers;
} | [
"public",
"function",
"getHeaders",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
";",
"}",
"$",
"n",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"n",
"]",
"as",
"$",
"data",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] | Get all HTTP headers of this message.
@param string $name
@return array | [
"Get",
"all",
"HTTP",
"headers",
"of",
"this",
"message",
"."
] | 3c1626d409d5ce5d71d26f0e8f31ae3683a2a966 | https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpMessage.php#L228-L250 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.