id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,400 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.convertTitle | public function convertTitle()
{
if ($this->title === null) {
return '';
}
foreach ($this->splitWords() as $index => $word) {
if ($this->wordShouldBeUppercase($index, $word)) {
$this->rebuildTitle($index, $this->uppercaseWord($word));
}
}
return $this->title;
} | php | public function convertTitle()
{
if ($this->title === null) {
return '';
}
foreach ($this->splitWords() as $index => $word) {
if ($this->wordShouldBeUppercase($index, $word)) {
$this->rebuildTitle($index, $this->uppercaseWord($word));
}
}
return $this->title;
} | [
"public",
"function",
"convertTitle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"title",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"splitWords",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"word",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"wordShouldBeUppercase",
"(",
"$",
"index",
",",
"$",
"word",
")",
")",
"{",
"$",
"this",
"->",
"rebuildTitle",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"uppercaseWord",
"(",
"$",
"word",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"title",
";",
"}"
] | Converts the initial title to a correctly formatted one
@return string | [
"Converts",
"the",
"initial",
"title",
"to",
"a",
"correctly",
"formatted",
"one"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L81-L94 |
6,401 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.setTitle | protected function setTitle($title)
{
$title = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $title)));
if ($title != '') {
$this->title = $title;
}
} | php | protected function setTitle($title)
{
$title = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $title)));
if ($title != '') {
$this->title = $title;
}
} | [
"protected",
"function",
"setTitle",
"(",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/\\s\\s+/'",
",",
"' '",
",",
"str_replace",
"(",
"\"\\n\"",
",",
"\" \"",
",",
"$",
"title",
")",
")",
")",
";",
"if",
"(",
"$",
"title",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
";",
"}",
"}"
] | Sets the title after cleaning up extra spaces
@param string $title | [
"Sets",
"the",
"title",
"after",
"cleaning",
"up",
"extra",
"spaces"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L115-L122 |
6,402 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.splitWords | protected function splitWords()
{
$indexedWords = [];
$offset = 0;
$words = explode($this->separator, $this->title);
foreach ($words as $word) {
if (mb_strlen($word, $this->encoding) == 0) {
continue;
}
$wordIndex = $this->getWordIndex($word, $offset);
if ($this->hasDash($word)) {
$word = TextFormatter::titleCase($word, '-');
$this->rebuildTitle($wordIndex, $word);
}
$indexedWords[$wordIndex] = $word;
$offset += mb_strlen($word, $this->encoding) + 1; // plus space
}
return $this->indexedWords = $indexedWords;
} | php | protected function splitWords()
{
$indexedWords = [];
$offset = 0;
$words = explode($this->separator, $this->title);
foreach ($words as $word) {
if (mb_strlen($word, $this->encoding) == 0) {
continue;
}
$wordIndex = $this->getWordIndex($word, $offset);
if ($this->hasDash($word)) {
$word = TextFormatter::titleCase($word, '-');
$this->rebuildTitle($wordIndex, $word);
}
$indexedWords[$wordIndex] = $word;
$offset += mb_strlen($word, $this->encoding) + 1; // plus space
}
return $this->indexedWords = $indexedWords;
} | [
"protected",
"function",
"splitWords",
"(",
")",
"{",
"$",
"indexedWords",
"=",
"[",
"]",
";",
"$",
"offset",
"=",
"0",
";",
"$",
"words",
"=",
"explode",
"(",
"$",
"this",
"->",
"separator",
",",
"$",
"this",
"->",
"title",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"mb_strlen",
"(",
"$",
"word",
",",
"$",
"this",
"->",
"encoding",
")",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"$",
"wordIndex",
"=",
"$",
"this",
"->",
"getWordIndex",
"(",
"$",
"word",
",",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasDash",
"(",
"$",
"word",
")",
")",
"{",
"$",
"word",
"=",
"TextFormatter",
"::",
"titleCase",
"(",
"$",
"word",
",",
"'-'",
")",
";",
"$",
"this",
"->",
"rebuildTitle",
"(",
"$",
"wordIndex",
",",
"$",
"word",
")",
";",
"}",
"$",
"indexedWords",
"[",
"$",
"wordIndex",
"]",
"=",
"$",
"word",
";",
"$",
"offset",
"+=",
"mb_strlen",
"(",
"$",
"word",
",",
"$",
"this",
"->",
"encoding",
")",
"+",
"1",
";",
"// plus space",
"}",
"return",
"$",
"this",
"->",
"indexedWords",
"=",
"$",
"indexedWords",
";",
"}"
] | Creates an array of words from the title to be formatted | [
"Creates",
"an",
"array",
"of",
"words",
"from",
"the",
"title",
"to",
"be",
"formatted"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L127-L150 |
6,403 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.getWordIndex | protected function getWordIndex($word, $offset)
{
$index = mb_strpos($this->title, $word, $offset, $this->encoding);
return $this->correctIndexOffset($index);
} | php | protected function getWordIndex($word, $offset)
{
$index = mb_strpos($this->title, $word, $offset, $this->encoding);
return $this->correctIndexOffset($index);
} | [
"protected",
"function",
"getWordIndex",
"(",
"$",
"word",
",",
"$",
"offset",
")",
"{",
"$",
"index",
"=",
"mb_strpos",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"word",
",",
"$",
"offset",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"return",
"$",
"this",
"->",
"correctIndexOffset",
"(",
"$",
"index",
")",
";",
"}"
] | Finds the correct index of the word within the title
@param $word
@param $offset
@return int | [
"Finds",
"the",
"correct",
"index",
"of",
"the",
"word",
"within",
"the",
"title"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L159-L163 |
6,404 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.correctIndexOffset | protected function correctIndexOffset($index)
{
return mb_strlen(mb_substr($this->title, 0, $index, $this->encoding), $this->encoding);
} | php | protected function correctIndexOffset($index)
{
return mb_strlen(mb_substr($this->title, 0, $index, $this->encoding), $this->encoding);
} | [
"protected",
"function",
"correctIndexOffset",
"(",
"$",
"index",
")",
"{",
"return",
"mb_strlen",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"title",
",",
"0",
",",
"$",
"index",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] | Corrects the potential offset issue with some UTF-8 characters
@param $index
@return int | [
"Corrects",
"the",
"potential",
"offset",
"issue",
"with",
"some",
"UTF",
"-",
"8",
"characters"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L171-L174 |
6,405 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.rebuildTitle | protected function rebuildTitle($index, $word)
{
$this->title =
mb_substr($this->title, 0, $index, $this->encoding) .
$word .
mb_substr(
$this->title,
$index + mb_strlen($word, $this->encoding),
mb_strlen($this->title, $this->encoding),
$this->encoding
);
} | php | protected function rebuildTitle($index, $word)
{
$this->title =
mb_substr($this->title, 0, $index, $this->encoding) .
$word .
mb_substr(
$this->title,
$index + mb_strlen($word, $this->encoding),
mb_strlen($this->title, $this->encoding),
$this->encoding
);
} | [
"protected",
"function",
"rebuildTitle",
"(",
"$",
"index",
",",
"$",
"word",
")",
"{",
"$",
"this",
"->",
"title",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"title",
",",
"0",
",",
"$",
"index",
",",
"$",
"this",
"->",
"encoding",
")",
".",
"$",
"word",
".",
"mb_substr",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"index",
"+",
"mb_strlen",
"(",
"$",
"word",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"mb_strlen",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] | Replaces a formatted word within the current title
@param int $index
@param string $word | [
"Replaces",
"a",
"formatted",
"word",
"within",
"the",
"current",
"title"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L182-L193 |
6,406 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.uppercaseWord | protected function uppercaseWord($word)
{
// see if first characters are special
$prefix = '';
$hasPunctuation = true;
do {
$first = mb_substr($word, 0, 1, $this->encoding);
if ($this->isPunctuation($first)) {
$prefix .= $first;
$word = mb_substr($word, 1, -1, $this->encoding);
} else {
$hasPunctuation = false;
}
} while ($hasPunctuation === true);
return $prefix . ucwords($word);
} | php | protected function uppercaseWord($word)
{
// see if first characters are special
$prefix = '';
$hasPunctuation = true;
do {
$first = mb_substr($word, 0, 1, $this->encoding);
if ($this->isPunctuation($first)) {
$prefix .= $first;
$word = mb_substr($word, 1, -1, $this->encoding);
} else {
$hasPunctuation = false;
}
} while ($hasPunctuation === true);
return $prefix . ucwords($word);
} | [
"protected",
"function",
"uppercaseWord",
"(",
"$",
"word",
")",
"{",
"// see if first characters are special",
"$",
"prefix",
"=",
"''",
";",
"$",
"hasPunctuation",
"=",
"true",
";",
"do",
"{",
"$",
"first",
"=",
"mb_substr",
"(",
"$",
"word",
",",
"0",
",",
"1",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPunctuation",
"(",
"$",
"first",
")",
")",
"{",
"$",
"prefix",
".=",
"$",
"first",
";",
"$",
"word",
"=",
"mb_substr",
"(",
"$",
"word",
",",
"1",
",",
"-",
"1",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}",
"else",
"{",
"$",
"hasPunctuation",
"=",
"false",
";",
"}",
"}",
"while",
"(",
"$",
"hasPunctuation",
"===",
"true",
")",
";",
"return",
"$",
"prefix",
".",
"ucwords",
"(",
"$",
"word",
")",
";",
"}"
] | Performs the uppercase action on the given word
@param $word
@return string | [
"Performs",
"the",
"uppercase",
"action",
"on",
"the",
"given",
"word"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L201-L217 |
6,407 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.wordShouldBeUppercase | protected function wordShouldBeUppercase($index, $word)
{
return
(
$this->isFirstWordOfSentence($index) ||
$this->isLastWord($word) ||
!$this->isIgnoredWord($word)
) &&
(
!$this->hasUppercaseLetter($word)
);
} | php | protected function wordShouldBeUppercase($index, $word)
{
return
(
$this->isFirstWordOfSentence($index) ||
$this->isLastWord($word) ||
!$this->isIgnoredWord($word)
) &&
(
!$this->hasUppercaseLetter($word)
);
} | [
"protected",
"function",
"wordShouldBeUppercase",
"(",
"$",
"index",
",",
"$",
"word",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"isFirstWordOfSentence",
"(",
"$",
"index",
")",
"||",
"$",
"this",
"->",
"isLastWord",
"(",
"$",
"word",
")",
"||",
"!",
"$",
"this",
"->",
"isIgnoredWord",
"(",
"$",
"word",
")",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"hasUppercaseLetter",
"(",
"$",
"word",
")",
")",
";",
"}"
] | Condition to see if the given word should be uppercase
@param $index
@param $word
@return bool | [
"Condition",
"to",
"see",
"if",
"the",
"given",
"word",
"should",
"be",
"uppercase"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L226-L237 |
6,408 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.isFirstWordOfSentence | protected function isFirstWordOfSentence($index)
{
if ($index == 0) {
return true;
}
$twoCharactersBack = mb_substr($this->title, $index - 2, 1, $this->encoding);
if ($this->isPunctuation($twoCharactersBack)) {
return true;
}
return false;
} | php | protected function isFirstWordOfSentence($index)
{
if ($index == 0) {
return true;
}
$twoCharactersBack = mb_substr($this->title, $index - 2, 1, $this->encoding);
if ($this->isPunctuation($twoCharactersBack)) {
return true;
}
return false;
} | [
"protected",
"function",
"isFirstWordOfSentence",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"$",
"twoCharactersBack",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"index",
"-",
"2",
",",
"1",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPunctuation",
"(",
"$",
"twoCharactersBack",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks to see if the word the start of a new sentence
@param $index
@return bool | [
"Checks",
"to",
"see",
"if",
"the",
"word",
"the",
"start",
"of",
"a",
"new",
"sentence"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L260-L273 |
6,409 | SpartzInc/text-formatter | src/TextFormatter.php | TextFormatter.hasDash | protected function hasDash($word)
{
$wordWithoutDashes = str_replace('-', '', $word);
return preg_match("/\-/", $word) && mb_strlen($wordWithoutDashes, $this->encoding) > 1;
} | php | protected function hasDash($word)
{
$wordWithoutDashes = str_replace('-', '', $word);
return preg_match("/\-/", $word) && mb_strlen($wordWithoutDashes, $this->encoding) > 1;
} | [
"protected",
"function",
"hasDash",
"(",
"$",
"word",
")",
"{",
"$",
"wordWithoutDashes",
"=",
"str_replace",
"(",
"'-'",
",",
"''",
",",
"$",
"word",
")",
";",
"return",
"preg_match",
"(",
"\"/\\-/\"",
",",
"$",
"word",
")",
"&&",
"mb_strlen",
"(",
"$",
"wordWithoutDashes",
",",
"$",
"this",
"->",
"encoding",
")",
">",
"1",
";",
"}"
] | Checks to see if the word has a dash
@param $word
@return int | [
"Checks",
"to",
"see",
"if",
"the",
"word",
"has",
"a",
"dash"
] | 979a1646ab55188b3dfea1df0a8c8568e5905745 | https://github.com/SpartzInc/text-formatter/blob/979a1646ab55188b3dfea1df0a8c8568e5905745/src/TextFormatter.php#L314-L319 |
6,410 | znframework/package-services | CDNAbstract.php | CDNAbstract.getLinks | public function getLinks() : Array
{
if( ! $this->isJsonCheck() || $this->refresh === true )
{
$result = $this->getApiResult();
if( ! is_object($result) )
{
throw new Exception\BadRequestURLException($this->address);
}
$this->putJsonContent($result);
}
$result = $this->decodeArrrayJsonContent();
return $this->convertArrayByKeyValues($result);
} | php | public function getLinks() : Array
{
if( ! $this->isJsonCheck() || $this->refresh === true )
{
$result = $this->getApiResult();
if( ! is_object($result) )
{
throw new Exception\BadRequestURLException($this->address);
}
$this->putJsonContent($result);
}
$result = $this->decodeArrrayJsonContent();
return $this->convertArrayByKeyValues($result);
} | [
"public",
"function",
"getLinks",
"(",
")",
":",
"Array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isJsonCheck",
"(",
")",
"||",
"$",
"this",
"->",
"refresh",
"===",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getApiResult",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"result",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"BadRequestURLException",
"(",
"$",
"this",
"->",
"address",
")",
";",
"}",
"$",
"this",
"->",
"putJsonContent",
"(",
"$",
"result",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"decodeArrrayJsonContent",
"(",
")",
";",
"return",
"$",
"this",
"->",
"convertArrayByKeyValues",
"(",
"$",
"result",
")",
";",
"}"
] | Gets links.
@return array | [
"Gets",
"links",
"."
] | d603667191e2e386cbc2119836c5bed9e3ade141 | https://github.com/znframework/package-services/blob/d603667191e2e386cbc2119836c5bed9e3ade141/CDNAbstract.php#L54-L71 |
6,411 | yujin1st/yii2-user | Module.php | Module.getUserMenu | public function getUserMenu() {
$event = new BuildUserMenuEvent();
$this->trigger(self::EVENT_BUILD_USER_MENU, $event);
$menu = [];
foreach ($event->items as $block => $items) {
foreach ($items as $item) {
$menu[] = $item;
}
}
return $menu;
} | php | public function getUserMenu() {
$event = new BuildUserMenuEvent();
$this->trigger(self::EVENT_BUILD_USER_MENU, $event);
$menu = [];
foreach ($event->items as $block => $items) {
foreach ($items as $item) {
$menu[] = $item;
}
}
return $menu;
} | [
"public",
"function",
"getUserMenu",
"(",
")",
"{",
"$",
"event",
"=",
"new",
"BuildUserMenuEvent",
"(",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BUILD_USER_MENU",
",",
"$",
"event",
")",
";",
"$",
"menu",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"->",
"items",
"as",
"$",
"block",
"=>",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"menu",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"menu",
";",
"}"
] | Collecting side menu over modules | [
"Collecting",
"side",
"menu",
"over",
"modules"
] | b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f | https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/Module.php#L207-L217 |
6,412 | Vibius/Container | src/Container.php | Container.open | public static function open($key, $private = false, $secure = false){
if( !isset(self::$privates[$key]) && ($private === true) ){
self::$privates[$key] = new Container;
self::$privates[$key]->name = $key;
self::$privates[$key]->secure = false;
if($secure){
self::$privates[$key]->secure = true;
}
return self::$privates[$key];
}
if( !isset(self::$instance[$key]) && ($private === false) ){
self::$instance[$key] = new Container;
self::$instance[$key]->name = $key;
self::$instance[$key]->secure = false;
if($secure){
self::$instance[$key]->secure = true;
}
return self::$instance[$key];
}else if( $private === false ){
return self::$instance[$key];
}
throw new Exception("Container instance cannot be opened!");
} | php | public static function open($key, $private = false, $secure = false){
if( !isset(self::$privates[$key]) && ($private === true) ){
self::$privates[$key] = new Container;
self::$privates[$key]->name = $key;
self::$privates[$key]->secure = false;
if($secure){
self::$privates[$key]->secure = true;
}
return self::$privates[$key];
}
if( !isset(self::$instance[$key]) && ($private === false) ){
self::$instance[$key] = new Container;
self::$instance[$key]->name = $key;
self::$instance[$key]->secure = false;
if($secure){
self::$instance[$key]->secure = true;
}
return self::$instance[$key];
}else if( $private === false ){
return self::$instance[$key];
}
throw new Exception("Container instance cannot be opened!");
} | [
"public",
"static",
"function",
"open",
"(",
"$",
"key",
",",
"$",
"private",
"=",
"false",
",",
"$",
"secure",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
")",
"&&",
"(",
"$",
"private",
"===",
"true",
")",
")",
"{",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
"=",
"new",
"Container",
";",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
"->",
"name",
"=",
"$",
"key",
";",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
"->",
"secure",
"=",
"false",
";",
"if",
"(",
"$",
"secure",
")",
"{",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
"->",
"secure",
"=",
"true",
";",
"}",
"return",
"self",
"::",
"$",
"privates",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
")",
"&&",
"(",
"$",
"private",
"===",
"false",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
"=",
"new",
"Container",
";",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
"->",
"name",
"=",
"$",
"key",
";",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
"->",
"secure",
"=",
"false",
";",
"if",
"(",
"$",
"secure",
")",
"{",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
"->",
"secure",
"=",
"true",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"private",
"===",
"false",
")",
"{",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"key",
"]",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"Container instance cannot be opened!\"",
")",
";",
"}"
] | Method is used to open specific instance of container.
@param string $key Identifier for inner storage to find the proper instance to open or create.
@return object Instance of Container class picked by $key. | [
"Method",
"is",
"used",
"to",
"open",
"specific",
"instance",
"of",
"container",
"."
] | 98691c1bc4317d36e4c950ccd47e424ea86dc39c | https://github.com/Vibius/Container/blob/98691c1bc4317d36e4c950ccd47e424ea86dc39c/src/Container.php#L35-L61 |
6,413 | xinc-develop/xinc-core | src/Build/Labeler/DefaultLabeler.php | DefaultLabeler.getLabel | public function getLabel(BuildInterface $build)
{
$buildNo = $build->getNumber();
if ($buildNo == null) {
$buildNo = $this->_firstBuild;
}
$buildLabel = $this->_prefix.$buildNo;
$build->setProperty('build.label', $buildLabel);
return $buildLabel;
} | php | public function getLabel(BuildInterface $build)
{
$buildNo = $build->getNumber();
if ($buildNo == null) {
$buildNo = $this->_firstBuild;
}
$buildLabel = $this->_prefix.$buildNo;
$build->setProperty('build.label', $buildLabel);
return $buildLabel;
} | [
"public",
"function",
"getLabel",
"(",
"BuildInterface",
"$",
"build",
")",
"{",
"$",
"buildNo",
"=",
"$",
"build",
"->",
"getNumber",
"(",
")",
";",
"if",
"(",
"$",
"buildNo",
"==",
"null",
")",
"{",
"$",
"buildNo",
"=",
"$",
"this",
"->",
"_firstBuild",
";",
"}",
"$",
"buildLabel",
"=",
"$",
"this",
"->",
"_prefix",
".",
"$",
"buildNo",
";",
"$",
"build",
"->",
"setProperty",
"(",
"'build.label'",
",",
"$",
"buildLabel",
")",
";",
"return",
"$",
"buildLabel",
";",
"}"
] | Return the label for this build.
@param Xinc_Build_Interface $build
@return string | [
"Return",
"the",
"label",
"for",
"this",
"build",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Build/Labeler/DefaultLabeler.php#L54-L66 |
6,414 | yusukezzz/consolet | src/Consolet/Application.php | Application.prepareContainer | public static function prepareContainer(Container $container)
{
if ( ! isset($container['config'])) {
$container['config'] = [];
}
if ( ! isset($container['files'])) {
$container['files'] = new Filesystem();
}
if ( ! isset($container['providers'])) {
$container['providers'] = [];
}
$providers = $container['providers'];
$providers[] = 'Consolet\DefaultCommandsProvider';
$container['providers'] = $providers;
return $container;
} | php | public static function prepareContainer(Container $container)
{
if ( ! isset($container['config'])) {
$container['config'] = [];
}
if ( ! isset($container['files'])) {
$container['files'] = new Filesystem();
}
if ( ! isset($container['providers'])) {
$container['providers'] = [];
}
$providers = $container['providers'];
$providers[] = 'Consolet\DefaultCommandsProvider';
$container['providers'] = $providers;
return $container;
} | [
"public",
"static",
"function",
"prepareContainer",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'config'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'config'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'files'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'files'",
"]",
"=",
"new",
"Filesystem",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'providers'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'providers'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"providers",
"=",
"$",
"container",
"[",
"'providers'",
"]",
";",
"$",
"providers",
"[",
"]",
"=",
"'Consolet\\DefaultCommandsProvider'",
";",
"$",
"container",
"[",
"'providers'",
"]",
"=",
"$",
"providers",
";",
"return",
"$",
"container",
";",
"}"
] | prepare default dependencies
@param Container $container
@return Container | [
"prepare",
"default",
"dependencies"
] | eceddd0ace37f14c1cf12d793eef265c530924e1 | https://github.com/yusukezzz/consolet/blob/eceddd0ace37f14c1cf12d793eef265c530924e1/src/Consolet/Application.php#L65-L80 |
6,415 | oschildt/SmartFactory | src/SmartFactory/ErrorHandler.php | ErrorHandler.init | public function init($parameters)
{
if (!empty($parameters["app_root"])) {
$this->app_root = $parameters["app_root"];
}
if (empty($parameters["log_path"])) {
throw new \Exception("Log path is not specified!");
}
$this->log_path = $parameters["log_path"];
$file = $this->log_path . "trace.log";
if (!file_exists($this->log_path) || !is_writable($this->log_path) || (file_exists($file) && !is_writable($file))) {
throw new \Exception(sprintf("The trace file '%s' is not writable!", $file));
}
return true;
} | php | public function init($parameters)
{
if (!empty($parameters["app_root"])) {
$this->app_root = $parameters["app_root"];
}
if (empty($parameters["log_path"])) {
throw new \Exception("Log path is not specified!");
}
$this->log_path = $parameters["log_path"];
$file = $this->log_path . "trace.log";
if (!file_exists($this->log_path) || !is_writable($this->log_path) || (file_exists($file) && !is_writable($file))) {
throw new \Exception(sprintf("The trace file '%s' is not writable!", $file));
}
return true;
} | [
"public",
"function",
"init",
"(",
"$",
"parameters",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
"[",
"\"app_root\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app_root",
"=",
"$",
"parameters",
"[",
"\"app_root\"",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"parameters",
"[",
"\"log_path\"",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Log path is not specified!\"",
")",
";",
"}",
"$",
"this",
"->",
"log_path",
"=",
"$",
"parameters",
"[",
"\"log_path\"",
"]",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"log_path",
".",
"\"trace.log\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"log_path",
")",
"||",
"!",
"is_writable",
"(",
"$",
"this",
"->",
"log_path",
")",
"||",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"!",
"is_writable",
"(",
"$",
"file",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The trace file '%s' is not writable!\"",
",",
"$",
"file",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Initializes the error handler with parameters.
@param array $parameters
Settings for logging as an associative array in the form key => value:
- $parameters["app_root"] - the root directory of the application.
- $parameters["log_path"] - the target file path where the logs should be stored.
@return boolean
Returns true upon successful initialization, otherwise false.
@throws \Exception
It might throw an exception in the case of any errors:
- if the log path is not specified.
- if the trace file is not writable.
@author Oleg Schildt | [
"Initializes",
"the",
"error",
"handler",
"with",
"parameters",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/ErrorHandler.php#L86-L105 |
6,416 | oschildt/SmartFactory | src/SmartFactory/ErrorHandler.php | ErrorHandler.handleError | public function handleError($errno, $errstr, $errfile, $errline)
{
$this->setLastError($errstr);
$errortype = [
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
E_COMPILE_ERROR => "Compile Error",
E_COMPILE_WARNING => "Compile Warning",
E_USER_ERROR => "User Error",
E_USER_WARNING => "User Warning",
E_USER_NOTICE => "User Notice",
E_STRICT => "Runtime Notice",
E_DEPRECATED => "Deprecated Notice"
];
if (empty($errortype[$errno])) {
$etype = $errno;
} else {
$etype = $errortype[$errno];
}
$this->trace_message($this->format_backtrace(debug_backtrace()));
event()->fireEvent("php_error", ["etype" => $etype, "errstr" => $errstr, "errfile" => $errfile, "errline" => $errline]);
} | php | public function handleError($errno, $errstr, $errfile, $errline)
{
$this->setLastError($errstr);
$errortype = [
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
E_COMPILE_ERROR => "Compile Error",
E_COMPILE_WARNING => "Compile Warning",
E_USER_ERROR => "User Error",
E_USER_WARNING => "User Warning",
E_USER_NOTICE => "User Notice",
E_STRICT => "Runtime Notice",
E_DEPRECATED => "Deprecated Notice"
];
if (empty($errortype[$errno])) {
$etype = $errno;
} else {
$etype = $errortype[$errno];
}
$this->trace_message($this->format_backtrace(debug_backtrace()));
event()->fireEvent("php_error", ["etype" => $etype, "errstr" => $errstr, "errfile" => $errfile, "errline" => $errline]);
} | [
"public",
"function",
"handleError",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"$",
"this",
"->",
"setLastError",
"(",
"$",
"errstr",
")",
";",
"$",
"errortype",
"=",
"[",
"E_ERROR",
"=>",
"\"Error\"",
",",
"E_WARNING",
"=>",
"\"Warning\"",
",",
"E_PARSE",
"=>",
"\"Parsing Error\"",
",",
"E_NOTICE",
"=>",
"\"Notice\"",
",",
"E_CORE_ERROR",
"=>",
"\"Core Error\"",
",",
"E_CORE_WARNING",
"=>",
"\"Core Warning\"",
",",
"E_COMPILE_ERROR",
"=>",
"\"Compile Error\"",
",",
"E_COMPILE_WARNING",
"=>",
"\"Compile Warning\"",
",",
"E_USER_ERROR",
"=>",
"\"User Error\"",
",",
"E_USER_WARNING",
"=>",
"\"User Warning\"",
",",
"E_USER_NOTICE",
"=>",
"\"User Notice\"",
",",
"E_STRICT",
"=>",
"\"Runtime Notice\"",
",",
"E_DEPRECATED",
"=>",
"\"Deprecated Notice\"",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"errortype",
"[",
"$",
"errno",
"]",
")",
")",
"{",
"$",
"etype",
"=",
"$",
"errno",
";",
"}",
"else",
"{",
"$",
"etype",
"=",
"$",
"errortype",
"[",
"$",
"errno",
"]",
";",
"}",
"$",
"this",
"->",
"trace_message",
"(",
"$",
"this",
"->",
"format_backtrace",
"(",
"debug_backtrace",
"(",
")",
")",
")",
";",
"event",
"(",
")",
"->",
"fireEvent",
"(",
"\"php_error\"",
",",
"[",
"\"etype\"",
"=>",
"$",
"etype",
",",
"\"errstr\"",
"=>",
"$",
"errstr",
",",
"\"errfile\"",
"=>",
"$",
"errfile",
",",
"\"errline\"",
"=>",
"$",
"errline",
"]",
")",
";",
"}"
] | This is the function for handling of the PHP errors. It is set a the
error handler.
@param int $errno
Error code.
@param string $errstr
Error text.
@param string $errfile
Source file where the error occured.
@param int $errline
Line number where the error occured.
@return void
@author Oleg Schildt | [
"This",
"is",
"the",
"function",
"for",
"handling",
"of",
"the",
"PHP",
"errors",
".",
"It",
"is",
"set",
"a",
"the",
"error",
"handler",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/ErrorHandler.php#L321-L350 |
6,417 | aurorahttp/http-handler | src/ReplaceableTrait.php | ReplaceableTrait.replace | public function replace($handler, $bindTo = true)
{
if ($bindTo && $handler instanceof Closure) {
$handler = $handler->bindTo($this, $this);
}
$this->handler = $handler;
} | php | public function replace($handler, $bindTo = true)
{
if ($bindTo && $handler instanceof Closure) {
$handler = $handler->bindTo($this, $this);
}
$this->handler = $handler;
} | [
"public",
"function",
"replace",
"(",
"$",
"handler",
",",
"$",
"bindTo",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"bindTo",
"&&",
"$",
"handler",
"instanceof",
"Closure",
")",
"{",
"$",
"handler",
"=",
"$",
"handler",
"->",
"bindTo",
"(",
"$",
"this",
",",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"handler",
"=",
"$",
"handler",
";",
"}"
] | Replace class handle method.
@param callable $handler
@param bool $bindTo | [
"Replace",
"class",
"handle",
"method",
"."
] | 2dc12a964b15b497f5a81b2b2ab389fe95bcd460 | https://github.com/aurorahttp/http-handler/blob/2dc12a964b15b497f5a81b2b2ab389fe95bcd460/src/ReplaceableTrait.php#L20-L26 |
6,418 | flowcode/AmulenPageBundle | src/Flowcode/PageBundle/Services/MenuService.php | MenuService.reorder | public function reorder(Menu $menu, $field = 'position')
{
$roots = $this->menuItemRepository->getRootNodes();
$rootItem = null;
foreach ($roots as $root) {
if ($root->getMenu() == $menu) {
$rootItem = $root;
}
}
if ($rootItem) {
$this->menuItemRepository->reorder($rootItem, $field);
return true;
}
return false;
} | php | public function reorder(Menu $menu, $field = 'position')
{
$roots = $this->menuItemRepository->getRootNodes();
$rootItem = null;
foreach ($roots as $root) {
if ($root->getMenu() == $menu) {
$rootItem = $root;
}
}
if ($rootItem) {
$this->menuItemRepository->reorder($rootItem, $field);
return true;
}
return false;
} | [
"public",
"function",
"reorder",
"(",
"Menu",
"$",
"menu",
",",
"$",
"field",
"=",
"'position'",
")",
"{",
"$",
"roots",
"=",
"$",
"this",
"->",
"menuItemRepository",
"->",
"getRootNodes",
"(",
")",
";",
"$",
"rootItem",
"=",
"null",
";",
"foreach",
"(",
"$",
"roots",
"as",
"$",
"root",
")",
"{",
"if",
"(",
"$",
"root",
"->",
"getMenu",
"(",
")",
"==",
"$",
"menu",
")",
"{",
"$",
"rootItem",
"=",
"$",
"root",
";",
"}",
"}",
"if",
"(",
"$",
"rootItem",
")",
"{",
"$",
"this",
"->",
"menuItemRepository",
"->",
"reorder",
"(",
"$",
"rootItem",
",",
"$",
"field",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Reorder Menu tree.
@param Menu $menu
@param string $field
@return bool | [
"Reorder",
"Menu",
"tree",
"."
] | 41c90e1860d5f51aeda13cb42993b17cf14cf89f | https://github.com/flowcode/AmulenPageBundle/blob/41c90e1860d5f51aeda13cb42993b17cf14cf89f/src/Flowcode/PageBundle/Services/MenuService.php#L31-L48 |
6,419 | marando/phpSOFA | src/Marando/IAU/iauAb.php | iauAb.Ab | public static function Ab(array $pnat, array $v, $s, $bm1, array &$ppr) {
$i;
$pdv;
$w1;
$w2;
$r2;
$w;
$p = [];
$r;
$pdv = static::Pdp($pnat, $v);
$w1 = 1.0 + $pdv / (1.0 + $bm1);
$w2 = SRS / $s;
$r2 = 0.0;
for ($i = 0; $i < 3; $i++) {
$w = $pnat[$i] * $bm1 + $w1 * $v[$i] + $w2 * ($v[$i] -
$pdv * $pnat[$i]);
$p[$i] = $w;
$r2 = $r2 + $w * $w;
}
$r = sqrt($r2);
for ($i = 0; $i < 3; $i++) {
$ppr[$i] = $p[$i] / $r;
}
} | php | public static function Ab(array $pnat, array $v, $s, $bm1, array &$ppr) {
$i;
$pdv;
$w1;
$w2;
$r2;
$w;
$p = [];
$r;
$pdv = static::Pdp($pnat, $v);
$w1 = 1.0 + $pdv / (1.0 + $bm1);
$w2 = SRS / $s;
$r2 = 0.0;
for ($i = 0; $i < 3; $i++) {
$w = $pnat[$i] * $bm1 + $w1 * $v[$i] + $w2 * ($v[$i] -
$pdv * $pnat[$i]);
$p[$i] = $w;
$r2 = $r2 + $w * $w;
}
$r = sqrt($r2);
for ($i = 0; $i < 3; $i++) {
$ppr[$i] = $p[$i] / $r;
}
} | [
"public",
"static",
"function",
"Ab",
"(",
"array",
"$",
"pnat",
",",
"array",
"$",
"v",
",",
"$",
"s",
",",
"$",
"bm1",
",",
"array",
"&",
"$",
"ppr",
")",
"{",
"$",
"i",
";",
"$",
"pdv",
";",
"$",
"w1",
";",
"$",
"w2",
";",
"$",
"r2",
";",
"$",
"w",
";",
"$",
"p",
"=",
"[",
"]",
";",
"$",
"r",
";",
"$",
"pdv",
"=",
"static",
"::",
"Pdp",
"(",
"$",
"pnat",
",",
"$",
"v",
")",
";",
"$",
"w1",
"=",
"1.0",
"+",
"$",
"pdv",
"/",
"(",
"1.0",
"+",
"$",
"bm1",
")",
";",
"$",
"w2",
"=",
"SRS",
"/",
"$",
"s",
";",
"$",
"r2",
"=",
"0.0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"w",
"=",
"$",
"pnat",
"[",
"$",
"i",
"]",
"*",
"$",
"bm1",
"+",
"$",
"w1",
"*",
"$",
"v",
"[",
"$",
"i",
"]",
"+",
"$",
"w2",
"*",
"(",
"$",
"v",
"[",
"$",
"i",
"]",
"-",
"$",
"pdv",
"*",
"$",
"pnat",
"[",
"$",
"i",
"]",
")",
";",
"$",
"p",
"[",
"$",
"i",
"]",
"=",
"$",
"w",
";",
"$",
"r2",
"=",
"$",
"r2",
"+",
"$",
"w",
"*",
"$",
"w",
";",
"}",
"$",
"r",
"=",
"sqrt",
"(",
"$",
"r2",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"ppr",
"[",
"$",
"i",
"]",
"=",
"$",
"p",
"[",
"$",
"i",
"]",
"/",
"$",
"r",
";",
"}",
"}"
] | - - - - - -
i a u A b
- - - - - -
Apply aberration to transform natural direction into proper
direction.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
pnat double[3] natural direction to the source (unit vector)
v double[3] observer barycentric velocity in units of c
s double distance between the Sun and the observer (au)
bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
Returned:
ppr double[3] proper direction to source (unit vector)
Notes:
1) The algorithm is based on Expr. (7.40) in the Explanatory
Supplement (Urban & Seidelmann 2013), but with the following
changes:
o Rigorous rather than approximate normalization is applied.
o The gravitational potential term from Expr. (7) in
Klioner (2003) is added, taking into account only the Sun's
contribution. This has a maximum effect of about
0.4 microarcsecond.
2) In almost all cases, the maximum accuracy will be limited by the
supplied velocity. For example, if the SOFA iauEpv00 function is
used, errors of up to 5 microarcseconds could occur.
References:
Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to
the Astronomical Almanac, 3rd ed., University Science Books
(2013).
Klioner, Sergei A., "A practical relativistic model for micro-
arcsecond astrometry in space", Astr. J. 125, 1580-1597 (2003).
Called:
iauPdp scalar product of two p-vectors
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"b",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAb.php#L64-L88 |
6,420 | AnonymPHP/Anonym-Library | src/Anonym/Providers/SecurityProvider.php | SecurityProvider.registerFirewallSecurity | private function registerFirewallSecurity(array $firewall = [])
{
if (true === $firewall['status']) {
if (isset($firewall['ip_firewall'])) {
$this->registerIpFirewall($firewall['ip_firewall']);
}
if (isset($firewall['full_firewall'])) {
$this->registerFullFirewall($firewall['full_firewall']);
}
}
} | php | private function registerFirewallSecurity(array $firewall = [])
{
if (true === $firewall['status']) {
if (isset($firewall['ip_firewall'])) {
$this->registerIpFirewall($firewall['ip_firewall']);
}
if (isset($firewall['full_firewall'])) {
$this->registerFullFirewall($firewall['full_firewall']);
}
}
} | [
"private",
"function",
"registerFirewallSecurity",
"(",
"array",
"$",
"firewall",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"firewall",
"[",
"'status'",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"firewall",
"[",
"'ip_firewall'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registerIpFirewall",
"(",
"$",
"firewall",
"[",
"'ip_firewall'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"firewall",
"[",
"'full_firewall'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registerFullFirewall",
"(",
"$",
"firewall",
"[",
"'full_firewall'",
"]",
")",
";",
"}",
"}",
"}"
] | register the firewall
@param array $firewall | [
"register",
"the",
"firewall"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Providers/SecurityProvider.php#L84-L97 |
6,421 | AnonymPHP/Anonym-Library | src/Anonym/Providers/SecurityProvider.php | SecurityProvider.prepareCsrfInstance | private function prepareCsrfInstance(array $configs = [])
{
$configs = Config::get('security.csrf');
$field = $configs['field_name'];
$this->singleton(
'security.csrf',
function () use ($field) {
return (new CsrfToken())->setFormFieldName($field);
}
);
} | php | private function prepareCsrfInstance(array $configs = [])
{
$configs = Config::get('security.csrf');
$field = $configs['field_name'];
$this->singleton(
'security.csrf',
function () use ($field) {
return (new CsrfToken())->setFormFieldName($field);
}
);
} | [
"private",
"function",
"prepareCsrfInstance",
"(",
"array",
"$",
"configs",
"=",
"[",
"]",
")",
"{",
"$",
"configs",
"=",
"Config",
"::",
"get",
"(",
"'security.csrf'",
")",
";",
"$",
"field",
"=",
"$",
"configs",
"[",
"'field_name'",
"]",
";",
"$",
"this",
"->",
"singleton",
"(",
"'security.csrf'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"field",
")",
"{",
"return",
"(",
"new",
"CsrfToken",
"(",
")",
")",
"->",
"setFormFieldName",
"(",
"$",
"field",
")",
";",
"}",
")",
";",
"}"
] | register the csrf token
@param array $configs | [
"register",
"the",
"csrf",
"token"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Providers/SecurityProvider.php#L126-L138 |
6,422 | CatLabInteractive/Neuron | src/Neuron/Mappers/CachedMapper.php | CachedMapper.getModel | protected function getModel ($id) {
return isset ($this->models[$id]) ? $this->models[$id] : null;
} | php | protected function getModel ($id) {
return isset ($this->models[$id]) ? $this->models[$id] : null;
} | [
"protected",
"function",
"getModel",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"models",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"models",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Return model.
@param $id
@return Model|null | [
"Return",
"model",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Mappers/CachedMapper.php#L36-L38 |
6,423 | gintonicweb/menus | src/View/Helper/MenuHelper.php | MenuHelper.create | public function create(array $config = [], array $data = [])
{
$here = $this->_View->request->here();
$menu = new MenuGroup($config, $here);
return $menu->render($data);
} | php | public function create(array $config = [], array $data = [])
{
$here = $this->_View->request->here();
$menu = new MenuGroup($config, $here);
return $menu->render($data);
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"here",
"=",
"$",
"this",
"->",
"_View",
"->",
"request",
"->",
"here",
"(",
")",
";",
"$",
"menu",
"=",
"new",
"MenuGroup",
"(",
"$",
"config",
",",
"$",
"here",
")",
";",
"return",
"$",
"menu",
"->",
"render",
"(",
"$",
"data",
")",
";",
"}"
] | Creates the menu
The menu config defines the templates to be used. Each item of the array
represents a level of nesting. The config is inherited by default, and
each subsequent level can override the previous configuration
```
$config = [
[
'templates' => [
'group' => '<ul class="sidebar-menu">{{group}}</ul>',
'wrapper' => '<li class="{{class}}">{{wrapper}}</li>',
'content' => '<a href="{{url}}"><i class="{{icon}}"></i>{{name}}</a>',
],
'wrapper' => ['class' => 'treeview'],
'content' => ['icon' => 'fa fa-angle-right'],
],
[
'templates' => [
'group' => '<ul class="treeview-menu">{{group}}</ul>',
'wrapper' => '<li class="{{class}}">{{wrapper}}</li>',
],
'content' => ['icon' => 'fa fa-angle-right'],
],
]
```
The data array is defined as follow
$menu = [
[
'content' => ['left' => 'fa fa-users', 'name' => 'users'],
'group' => [
[
'content' => [
'name' => 'index',
'url' => ['controller' => 'users', 'action' => 'index'],
],
],
[
'content' => [
'name' => 'add',
'url' => ['controller' => 'users', 'action' => 'add'],
],
],
],
],
[
'content' => ['left' => 'fa fa-image', 'name' => 'images'],
'group' => [
[
'content' => [
'name' => 'index',
'url' => ['controller' => 'images', 'action' => 'index'],
]
],
],
],
];
The content of the menu can be defined with
@param array $config Configuration options
@param array $data Content of the menu
@return string | [
"Creates",
"the",
"menu"
] | 79ccbef8a014339a7bed9c1886d1837a5ef084b8 | https://github.com/gintonicweb/menus/blob/79ccbef8a014339a7bed9c1886d1837a5ef084b8/src/View/Helper/MenuHelper.php#L77-L82 |
6,424 | joegreen88/zf1-component-http | src/Zend/Http/CookieJar.php | Zend_Http_CookieJar.getMatchingCookies | public function getMatchingCookies($uri, $matchSessionCookies = true,
$ret_as = self::COOKIE_OBJECT, $now = null)
{
if (is_string($uri)) $uri = Zend_Uri::factory($uri);
if (! $uri instanceof Zend_Uri_Http) {
throw new Zend_Http_Exception("Invalid URI string or object passed");
}
// First, reduce the array of cookies to only those matching domain and path
$cookies = $this->_matchDomain($uri->getHost());
$cookies = $this->_matchPath($cookies, $uri->getPath());
$cookies = $this->_flattenCookiesArray($cookies, self::COOKIE_OBJECT);
// Next, run Cookie->match on all cookies to check secure, time and session mathcing
$ret = array();
foreach ($cookies as $cookie)
if ($cookie->match($uri, $matchSessionCookies, $now))
$ret[] = $cookie;
// Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
$ret = $this->_flattenCookiesArray($ret, $ret_as);
if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
$ret = rtrim(trim($ret), ';');
}
return $ret;
} | php | public function getMatchingCookies($uri, $matchSessionCookies = true,
$ret_as = self::COOKIE_OBJECT, $now = null)
{
if (is_string($uri)) $uri = Zend_Uri::factory($uri);
if (! $uri instanceof Zend_Uri_Http) {
throw new Zend_Http_Exception("Invalid URI string or object passed");
}
// First, reduce the array of cookies to only those matching domain and path
$cookies = $this->_matchDomain($uri->getHost());
$cookies = $this->_matchPath($cookies, $uri->getPath());
$cookies = $this->_flattenCookiesArray($cookies, self::COOKIE_OBJECT);
// Next, run Cookie->match on all cookies to check secure, time and session mathcing
$ret = array();
foreach ($cookies as $cookie)
if ($cookie->match($uri, $matchSessionCookies, $now))
$ret[] = $cookie;
// Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
$ret = $this->_flattenCookiesArray($ret, $ret_as);
if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
$ret = rtrim(trim($ret), ';');
}
return $ret;
} | [
"public",
"function",
"getMatchingCookies",
"(",
"$",
"uri",
",",
"$",
"matchSessionCookies",
"=",
"true",
",",
"$",
"ret_as",
"=",
"self",
"::",
"COOKIE_OBJECT",
",",
"$",
"now",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"uri",
")",
")",
"$",
"uri",
"=",
"Zend_Uri",
"::",
"factory",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"$",
"uri",
"instanceof",
"Zend_Uri_Http",
")",
"{",
"throw",
"new",
"Zend_Http_Exception",
"(",
"\"Invalid URI string or object passed\"",
")",
";",
"}",
"// First, reduce the array of cookies to only those matching domain and path",
"$",
"cookies",
"=",
"$",
"this",
"->",
"_matchDomain",
"(",
"$",
"uri",
"->",
"getHost",
"(",
")",
")",
";",
"$",
"cookies",
"=",
"$",
"this",
"->",
"_matchPath",
"(",
"$",
"cookies",
",",
"$",
"uri",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"cookies",
"=",
"$",
"this",
"->",
"_flattenCookiesArray",
"(",
"$",
"cookies",
",",
"self",
"::",
"COOKIE_OBJECT",
")",
";",
"// Next, run Cookie->match on all cookies to check secure, time and session mathcing",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"cookie",
")",
"if",
"(",
"$",
"cookie",
"->",
"match",
"(",
"$",
"uri",
",",
"$",
"matchSessionCookies",
",",
"$",
"now",
")",
")",
"$",
"ret",
"[",
"]",
"=",
"$",
"cookie",
";",
"// Now, use self::_flattenCookiesArray again - only to convert to the return format ;)",
"$",
"ret",
"=",
"$",
"this",
"->",
"_flattenCookiesArray",
"(",
"$",
"ret",
",",
"$",
"ret_as",
")",
";",
"if",
"(",
"$",
"ret_as",
"==",
"self",
"::",
"COOKIE_STRING_CONCAT_STRICT",
")",
"{",
"$",
"ret",
"=",
"rtrim",
"(",
"trim",
"(",
"$",
"ret",
")",
",",
"';'",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Return an array of all cookies matching a specific request according to the request URI,
whether session cookies should be sent or not, and the time to consider as "now" when
checking cookie expiry time.
@param string|Zend_Uri_Http $uri URI to check against (secure, domain, path)
@param boolean $matchSessionCookies Whether to send session cookies
@param int $ret_as Whether to return cookies as objects of Zend_Http_Cookie or as strings
@param int $now Override the current time when checking for expiry time
@return array|string | [
"Return",
"an",
"array",
"of",
"all",
"cookies",
"matching",
"a",
"specific",
"request",
"according",
"to",
"the",
"request",
"URI",
"whether",
"session",
"cookies",
"should",
"be",
"sent",
"or",
"not",
"and",
"the",
"time",
"to",
"consider",
"as",
"now",
"when",
"checking",
"cookie",
"expiry",
"time",
"."
] | 39e834e8f0393cf4223d099a0acaab5fa05e9ad4 | https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/CookieJar.php#L199-L226 |
6,425 | joegreen88/zf1-component-http | src/Zend/Http/CookieJar.php | Zend_Http_CookieJar.getCookie | public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
{
if (is_string($uri)) {
$uri = Zend_Uri::factory($uri);
}
if (! $uri instanceof Zend_Uri_Http) {
throw new Zend_Http_Exception('Invalid URI specified');
}
// Get correct cookie path
$path = $uri->getPath();
$path = substr($path, 0, strrpos($path, '/'));
if (! $path) $path = '/';
if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) {
$cookie = $this->cookies[$uri->getHost()][$path][$cookie_name];
switch ($ret_as) {
case self::COOKIE_OBJECT:
return $cookie;
break;
case self::COOKIE_STRING_CONCAT_STRICT:
return rtrim(trim($cookie->__toString()), ';');
break;
case self::COOKIE_STRING_ARRAY:
case self::COOKIE_STRING_CONCAT:
return $cookie->__toString();
break;
default:
throw new Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}");
break;
}
} else {
return false;
}
} | php | public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
{
if (is_string($uri)) {
$uri = Zend_Uri::factory($uri);
}
if (! $uri instanceof Zend_Uri_Http) {
throw new Zend_Http_Exception('Invalid URI specified');
}
// Get correct cookie path
$path = $uri->getPath();
$path = substr($path, 0, strrpos($path, '/'));
if (! $path) $path = '/';
if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) {
$cookie = $this->cookies[$uri->getHost()][$path][$cookie_name];
switch ($ret_as) {
case self::COOKIE_OBJECT:
return $cookie;
break;
case self::COOKIE_STRING_CONCAT_STRICT:
return rtrim(trim($cookie->__toString()), ';');
break;
case self::COOKIE_STRING_ARRAY:
case self::COOKIE_STRING_CONCAT:
return $cookie->__toString();
break;
default:
throw new Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}");
break;
}
} else {
return false;
}
} | [
"public",
"function",
"getCookie",
"(",
"$",
"uri",
",",
"$",
"cookie_name",
",",
"$",
"ret_as",
"=",
"self",
"::",
"COOKIE_OBJECT",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"uri",
"=",
"Zend_Uri",
"::",
"factory",
"(",
"$",
"uri",
")",
";",
"}",
"if",
"(",
"!",
"$",
"uri",
"instanceof",
"Zend_Uri_Http",
")",
"{",
"throw",
"new",
"Zend_Http_Exception",
"(",
"'Invalid URI specified'",
")",
";",
"}",
"// Get correct cookie path",
"$",
"path",
"=",
"$",
"uri",
"->",
"getPath",
"(",
")",
";",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"strrpos",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"$",
"path",
"=",
"'/'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cookies",
"[",
"$",
"uri",
"->",
"getHost",
"(",
")",
"]",
"[",
"$",
"path",
"]",
"[",
"$",
"cookie_name",
"]",
")",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"cookies",
"[",
"$",
"uri",
"->",
"getHost",
"(",
")",
"]",
"[",
"$",
"path",
"]",
"[",
"$",
"cookie_name",
"]",
";",
"switch",
"(",
"$",
"ret_as",
")",
"{",
"case",
"self",
"::",
"COOKIE_OBJECT",
":",
"return",
"$",
"cookie",
";",
"break",
";",
"case",
"self",
"::",
"COOKIE_STRING_CONCAT_STRICT",
":",
"return",
"rtrim",
"(",
"trim",
"(",
"$",
"cookie",
"->",
"__toString",
"(",
")",
")",
",",
"';'",
")",
";",
"break",
";",
"case",
"self",
"::",
"COOKIE_STRING_ARRAY",
":",
"case",
"self",
"::",
"COOKIE_STRING_CONCAT",
":",
"return",
"$",
"cookie",
"->",
"__toString",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Zend_Http_Exception",
"(",
"\"Invalid value passed for \\$ret_as: {$ret_as}\"",
")",
";",
"break",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Get a specific cookie according to a URI and name
@param Zend_Uri_Http|string $uri The uri (domain and path) to match
@param string $cookie_name The cookie's name
@param int $ret_as Whether to return cookies as objects of Zend_Http_Cookie or as strings
@return Zend_Http_Cookie|string | [
"Get",
"a",
"specific",
"cookie",
"according",
"to",
"a",
"URI",
"and",
"name"
] | 39e834e8f0393cf4223d099a0acaab5fa05e9ad4 | https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/CookieJar.php#L236-L277 |
6,426 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.createImageObject | protected function createImageObject()
{
// Check if the file is a valid file
if ( ! is_file( $this->originalImagePath ) ) {
throw new Exception( sprintf( '%s: No image found.', $this->originalImagePath ) );
}
// Get the mimetype
$this->imageType = exif_imagetype( $this->originalImagePath );
// Get the width and height of image
list($this->width, $this->height) = getimagesize($this->originalImagePath);
// Create GD object based on the mime type
switch ( $this->imageType ) {
case IMAGETYPE_GIF:
$this->image = imagecreatefromgif( $this->originalImagePath );
break;
case IMAGETYPE_PNG:
$this->image = @imagecreatefrompng( $this->originalImagePath );
break;
case IMAGETYPE_JPEG:
$this->image = @imagecreatefromjpeg( $this->originalImagePath );
break;
case IMAGETYPE_BMP:
$this->image = imagecreatefromwbmp( $this->originalImagePath );
break;
// If the image is not one of the previous mimetype
// We throw an exception
default:
throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
break;
}
// Check if the object is successfully opened
if( ! $this->image ) {
throw new Exception( sprintf( 'We could not open this image: %s', $this->originalImagePath ) );
}
} | php | protected function createImageObject()
{
// Check if the file is a valid file
if ( ! is_file( $this->originalImagePath ) ) {
throw new Exception( sprintf( '%s: No image found.', $this->originalImagePath ) );
}
// Get the mimetype
$this->imageType = exif_imagetype( $this->originalImagePath );
// Get the width and height of image
list($this->width, $this->height) = getimagesize($this->originalImagePath);
// Create GD object based on the mime type
switch ( $this->imageType ) {
case IMAGETYPE_GIF:
$this->image = imagecreatefromgif( $this->originalImagePath );
break;
case IMAGETYPE_PNG:
$this->image = @imagecreatefrompng( $this->originalImagePath );
break;
case IMAGETYPE_JPEG:
$this->image = @imagecreatefromjpeg( $this->originalImagePath );
break;
case IMAGETYPE_BMP:
$this->image = imagecreatefromwbmp( $this->originalImagePath );
break;
// If the image is not one of the previous mimetype
// We throw an exception
default:
throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
break;
}
// Check if the object is successfully opened
if( ! $this->image ) {
throw new Exception( sprintf( 'We could not open this image: %s', $this->originalImagePath ) );
}
} | [
"protected",
"function",
"createImageObject",
"(",
")",
"{",
"// Check if the file is a valid file",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'%s: No image found.'",
",",
"$",
"this",
"->",
"originalImagePath",
")",
")",
";",
"}",
"// Get the mimetype",
"$",
"this",
"->",
"imageType",
"=",
"exif_imagetype",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"// Get the width and height of image",
"list",
"(",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
"=",
"getimagesize",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"// Create GD object based on the mime type",
"switch",
"(",
"$",
"this",
"->",
"imageType",
")",
"{",
"case",
"IMAGETYPE_GIF",
":",
"$",
"this",
"->",
"image",
"=",
"imagecreatefromgif",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"break",
";",
"case",
"IMAGETYPE_PNG",
":",
"$",
"this",
"->",
"image",
"=",
"@",
"imagecreatefrompng",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"break",
";",
"case",
"IMAGETYPE_JPEG",
":",
"$",
"this",
"->",
"image",
"=",
"@",
"imagecreatefromjpeg",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"break",
";",
"case",
"IMAGETYPE_BMP",
":",
"$",
"this",
"->",
"image",
"=",
"imagecreatefromwbmp",
"(",
"$",
"this",
"->",
"originalImagePath",
")",
";",
"break",
";",
"// If the image is not one of the previous mimetype",
"// We throw an exception",
"default",
":",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'This MimeType is not supported: %s. Image processed: %s'",
",",
"image_type_to_mime_type",
"(",
"$",
"this",
"->",
"imageType",
")",
",",
"$",
"this",
"->",
"originalImagePath",
")",
")",
";",
"break",
";",
"}",
"// Check if the object is successfully opened",
"if",
"(",
"!",
"$",
"this",
"->",
"image",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'We could not open this image: %s'",
",",
"$",
"this",
"->",
"originalImagePath",
")",
")",
";",
"}",
"}"
] | Create GD Image object based on the mime_type
@return GD object resource | [
"Create",
"GD",
"Image",
"object",
"based",
"on",
"the",
"mime_type"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L73-L118 |
6,427 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.save | public function save($path)
{
switch ( $this->imageType ) {
case IMAGETYPE_GIF:
$returnData = imagegif( $this->image, $path );
break;
case IMAGETYPE_PNG:
$returnData = imagepng( $this->image, $path );
break;
case IMAGETYPE_JPEG:
$returnData = imagejpeg( $this->image, $path );
break;
case IMAGETYPE_BMP:
$returnData = imagewbmp( $this->image, $path );
break;
// If the image is not one of the previous mimetype
// We throw an exception
default:
throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
break;
}
// Return this for chaning
return $this;
} | php | public function save($path)
{
switch ( $this->imageType ) {
case IMAGETYPE_GIF:
$returnData = imagegif( $this->image, $path );
break;
case IMAGETYPE_PNG:
$returnData = imagepng( $this->image, $path );
break;
case IMAGETYPE_JPEG:
$returnData = imagejpeg( $this->image, $path );
break;
case IMAGETYPE_BMP:
$returnData = imagewbmp( $this->image, $path );
break;
// If the image is not one of the previous mimetype
// We throw an exception
default:
throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
break;
}
// Return this for chaning
return $this;
} | [
"public",
"function",
"save",
"(",
"$",
"path",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"imageType",
")",
"{",
"case",
"IMAGETYPE_GIF",
":",
"$",
"returnData",
"=",
"imagegif",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",
")",
";",
"break",
";",
"case",
"IMAGETYPE_PNG",
":",
"$",
"returnData",
"=",
"imagepng",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",
")",
";",
"break",
";",
"case",
"IMAGETYPE_JPEG",
":",
"$",
"returnData",
"=",
"imagejpeg",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",
")",
";",
"break",
";",
"case",
"IMAGETYPE_BMP",
":",
"$",
"returnData",
"=",
"imagewbmp",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",
")",
";",
"break",
";",
"// If the image is not one of the previous mimetype",
"// We throw an exception",
"default",
":",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'This MimeType is not supported: %s. Image processed: %s'",
",",
"image_type_to_mime_type",
"(",
"$",
"this",
"->",
"imageType",
")",
",",
"$",
"this",
"->",
"originalImagePath",
")",
")",
";",
"break",
";",
"}",
"// Return this for chaning",
"return",
"$",
"this",
";",
"}"
] | Save the working image to the new path
@return $this | [
"Save",
"the",
"working",
"image",
"to",
"the",
"new",
"path"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L125-L154 |
6,428 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.cropToFit | public function cropToFit($width, $height, $focusPointX = 0, $focusPointY = 0)
{
$debug = $width == 100 && $height == 100;
// Check if the image is a valid resource
if (!is_resource($this->image)) {
throw new RuntimeException('No image set');
}
// Get the width and height of element
$originalWidth = imagesx( $this->image );
$originalHeight = imagesy( $this->image );
// Check if any of the width and height is null, and set it to the $source size
$width = $width ?: $originalWidth;
$height = $height ?: $originalHeight;
// Calculate the aspect ratio of the existing image
$originalAspectRatio = $originalWidth / $originalHeight;
// Calculate the aspect ratio of the desired image
$desiredAspectRatio = $width / $height;
// Check what value we should use with the aspect ratio
if ( $originalAspectRatio > $desiredAspectRatio ) {
$temp_height = $height;
$temp_width = ( int ) ($height * $originalAspectRatio);
}
else {
$temp_width = $width;
$temp_height = ( int ) ($width / $originalAspectRatio);
}
// Get the center of image based on the focusPoint
$x0 = ( $temp_width - $width ) * ( ( $focusPointX + 1 ) * .5 );
$y0 = ( $temp_height - $height ) * ( ( $focusPointY + 1 ) * .5 );
// If $x0 or $y0 is not a full number increase with one pixel
// to fill black line and fill canvas
if ( ! ctype_digit( $x0 ) || ! ctype_digit( $y0 ) ) {
$temp_width++;
$temp_height++;
}
// Resize the image into the desired image
$this->resize( $temp_width, $temp_height );
// Create canvas for the new image
$canvas = $this->createCanvas( $width, $height );
// Do the cropping of image
imagecopy( $canvas, $this->image, 0, 0, $x0, $y0, $width, $height );
// Replace the image
$this->replace( $canvas );
// Return $this for chaining
return $this;
} | php | public function cropToFit($width, $height, $focusPointX = 0, $focusPointY = 0)
{
$debug = $width == 100 && $height == 100;
// Check if the image is a valid resource
if (!is_resource($this->image)) {
throw new RuntimeException('No image set');
}
// Get the width and height of element
$originalWidth = imagesx( $this->image );
$originalHeight = imagesy( $this->image );
// Check if any of the width and height is null, and set it to the $source size
$width = $width ?: $originalWidth;
$height = $height ?: $originalHeight;
// Calculate the aspect ratio of the existing image
$originalAspectRatio = $originalWidth / $originalHeight;
// Calculate the aspect ratio of the desired image
$desiredAspectRatio = $width / $height;
// Check what value we should use with the aspect ratio
if ( $originalAspectRatio > $desiredAspectRatio ) {
$temp_height = $height;
$temp_width = ( int ) ($height * $originalAspectRatio);
}
else {
$temp_width = $width;
$temp_height = ( int ) ($width / $originalAspectRatio);
}
// Get the center of image based on the focusPoint
$x0 = ( $temp_width - $width ) * ( ( $focusPointX + 1 ) * .5 );
$y0 = ( $temp_height - $height ) * ( ( $focusPointY + 1 ) * .5 );
// If $x0 or $y0 is not a full number increase with one pixel
// to fill black line and fill canvas
if ( ! ctype_digit( $x0 ) || ! ctype_digit( $y0 ) ) {
$temp_width++;
$temp_height++;
}
// Resize the image into the desired image
$this->resize( $temp_width, $temp_height );
// Create canvas for the new image
$canvas = $this->createCanvas( $width, $height );
// Do the cropping of image
imagecopy( $canvas, $this->image, 0, 0, $x0, $y0, $width, $height );
// Replace the image
$this->replace( $canvas );
// Return $this for chaining
return $this;
} | [
"public",
"function",
"cropToFit",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"focusPointX",
"=",
"0",
",",
"$",
"focusPointY",
"=",
"0",
")",
"{",
"$",
"debug",
"=",
"$",
"width",
"==",
"100",
"&&",
"$",
"height",
"==",
"100",
";",
"// Check if the image is a valid resource",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"image",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No image set'",
")",
";",
"}",
"// Get the width and height of element",
"$",
"originalWidth",
"=",
"imagesx",
"(",
"$",
"this",
"->",
"image",
")",
";",
"$",
"originalHeight",
"=",
"imagesy",
"(",
"$",
"this",
"->",
"image",
")",
";",
"// Check if any of the width and height is null, and set it to the $source size",
"$",
"width",
"=",
"$",
"width",
"?",
":",
"$",
"originalWidth",
";",
"$",
"height",
"=",
"$",
"height",
"?",
":",
"$",
"originalHeight",
";",
"// Calculate the aspect ratio of the existing image",
"$",
"originalAspectRatio",
"=",
"$",
"originalWidth",
"/",
"$",
"originalHeight",
";",
"// Calculate the aspect ratio of the desired image",
"$",
"desiredAspectRatio",
"=",
"$",
"width",
"/",
"$",
"height",
";",
"// Check what value we should use with the aspect ratio",
"if",
"(",
"$",
"originalAspectRatio",
">",
"$",
"desiredAspectRatio",
")",
"{",
"$",
"temp_height",
"=",
"$",
"height",
";",
"$",
"temp_width",
"=",
"(",
"int",
")",
"(",
"$",
"height",
"*",
"$",
"originalAspectRatio",
")",
";",
"}",
"else",
"{",
"$",
"temp_width",
"=",
"$",
"width",
";",
"$",
"temp_height",
"=",
"(",
"int",
")",
"(",
"$",
"width",
"/",
"$",
"originalAspectRatio",
")",
";",
"}",
"// Get the center of image based on the focusPoint",
"$",
"x0",
"=",
"(",
"$",
"temp_width",
"-",
"$",
"width",
")",
"*",
"(",
"(",
"$",
"focusPointX",
"+",
"1",
")",
"*",
".5",
")",
";",
"$",
"y0",
"=",
"(",
"$",
"temp_height",
"-",
"$",
"height",
")",
"*",
"(",
"(",
"$",
"focusPointY",
"+",
"1",
")",
"*",
".5",
")",
";",
"// If $x0 or $y0 is not a full number increase with one pixel",
"// to fill black line and fill canvas",
"if",
"(",
"!",
"ctype_digit",
"(",
"$",
"x0",
")",
"||",
"!",
"ctype_digit",
"(",
"$",
"y0",
")",
")",
"{",
"$",
"temp_width",
"++",
";",
"$",
"temp_height",
"++",
";",
"}",
"// Resize the image into the desired image",
"$",
"this",
"->",
"resize",
"(",
"$",
"temp_width",
",",
"$",
"temp_height",
")",
";",
"// Create canvas for the new image",
"$",
"canvas",
"=",
"$",
"this",
"->",
"createCanvas",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"// Do the cropping of image",
"imagecopy",
"(",
"$",
"canvas",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"$",
"x0",
",",
"$",
"y0",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"// Replace the image",
"$",
"this",
"->",
"replace",
"(",
"$",
"canvas",
")",
";",
"// Return $this for chaining",
"return",
"$",
"this",
";",
"}"
] | Crop image To the width and height of the image
@return $this | [
"Crop",
"image",
"To",
"the",
"width",
"and",
"height",
"of",
"the",
"image"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L161-L219 |
6,429 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.resize | public function resize( $width = null, $height = null )
{
// Get the source width and height
$sourceWidth = imagesx( $this->image );
$sourceHeight = imagesy( $this->image );
// Check if any of the width and height is null, and set it to the $source size
// $width = $width ?: $sourceWidth;
// $height = $height ?: $sourceHeight;
$sourceAspectRatio = $sourceWidth / $sourceHeight;
if ( !$width && !$height ) {
$width = $sourceWidth;
$height = $sourceHeight;
}
else if ( ! $width ) {
$width = $height * $sourceAspectRatio;
}
else {
$height = $width / $sourceAspectRatio;
}
$maxCanvasWidth = $width;
$maxCanvasHeight = $height;
$thumbnailAspectRatio = $maxCanvasWidth / $maxCanvasHeight;
// Create canvas for the new image
$canvas = $this->createCanvas( $width, $height );
// Do the resizing of the image
imagecopyresampled($canvas, $this->image, 0, 0, 0, 0, $width, $height, $sourceWidth, $sourceHeight);
// Replace the current image
$this->replace( $canvas );
// Return this for linking
return $this;
} | php | public function resize( $width = null, $height = null )
{
// Get the source width and height
$sourceWidth = imagesx( $this->image );
$sourceHeight = imagesy( $this->image );
// Check if any of the width and height is null, and set it to the $source size
// $width = $width ?: $sourceWidth;
// $height = $height ?: $sourceHeight;
$sourceAspectRatio = $sourceWidth / $sourceHeight;
if ( !$width && !$height ) {
$width = $sourceWidth;
$height = $sourceHeight;
}
else if ( ! $width ) {
$width = $height * $sourceAspectRatio;
}
else {
$height = $width / $sourceAspectRatio;
}
$maxCanvasWidth = $width;
$maxCanvasHeight = $height;
$thumbnailAspectRatio = $maxCanvasWidth / $maxCanvasHeight;
// Create canvas for the new image
$canvas = $this->createCanvas( $width, $height );
// Do the resizing of the image
imagecopyresampled($canvas, $this->image, 0, 0, 0, 0, $width, $height, $sourceWidth, $sourceHeight);
// Replace the current image
$this->replace( $canvas );
// Return this for linking
return $this;
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"// Get the source width and height",
"$",
"sourceWidth",
"=",
"imagesx",
"(",
"$",
"this",
"->",
"image",
")",
";",
"$",
"sourceHeight",
"=",
"imagesy",
"(",
"$",
"this",
"->",
"image",
")",
";",
"// Check if any of the width and height is null, and set it to the $source size",
"// $width = $width ?: $sourceWidth;",
"// $height = $height ?: $sourceHeight;",
"$",
"sourceAspectRatio",
"=",
"$",
"sourceWidth",
"/",
"$",
"sourceHeight",
";",
"if",
"(",
"!",
"$",
"width",
"&&",
"!",
"$",
"height",
")",
"{",
"$",
"width",
"=",
"$",
"sourceWidth",
";",
"$",
"height",
"=",
"$",
"sourceHeight",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"width",
")",
"{",
"$",
"width",
"=",
"$",
"height",
"*",
"$",
"sourceAspectRatio",
";",
"}",
"else",
"{",
"$",
"height",
"=",
"$",
"width",
"/",
"$",
"sourceAspectRatio",
";",
"}",
"$",
"maxCanvasWidth",
"=",
"$",
"width",
";",
"$",
"maxCanvasHeight",
"=",
"$",
"height",
";",
"$",
"thumbnailAspectRatio",
"=",
"$",
"maxCanvasWidth",
"/",
"$",
"maxCanvasHeight",
";",
"// Create canvas for the new image",
"$",
"canvas",
"=",
"$",
"this",
"->",
"createCanvas",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"// Do the resizing of the image",
"imagecopyresampled",
"(",
"$",
"canvas",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"sourceWidth",
",",
"$",
"sourceHeight",
")",
";",
"// Replace the current image",
"$",
"this",
"->",
"replace",
"(",
"$",
"canvas",
")",
";",
"// Return this for linking",
"return",
"$",
"this",
";",
"}"
] | Resize the GD Image
@return $this | [
"Resize",
"the",
"GD",
"Image"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L264-L302 |
6,430 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.createCanvas | protected function createCanvas($width, $height)
{
// Create the canvas element
$canvas = imagecreatetruecolor( $width, $height );
// Check if we should preserve the transparency
if ( $this->imageType == IMAGETYPE_GIF || $this->imageType == IMAGETYPE_PNG ) {
imagealphablending( $canvas, false );
imagesavealpha( $canvas, true );
}
// Return the canvas
return $canvas;
} | php | protected function createCanvas($width, $height)
{
// Create the canvas element
$canvas = imagecreatetruecolor( $width, $height );
// Check if we should preserve the transparency
if ( $this->imageType == IMAGETYPE_GIF || $this->imageType == IMAGETYPE_PNG ) {
imagealphablending( $canvas, false );
imagesavealpha( $canvas, true );
}
// Return the canvas
return $canvas;
} | [
"protected",
"function",
"createCanvas",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"// Create the canvas element",
"$",
"canvas",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"// Check if we should preserve the transparency",
"if",
"(",
"$",
"this",
"->",
"imageType",
"==",
"IMAGETYPE_GIF",
"||",
"$",
"this",
"->",
"imageType",
"==",
"IMAGETYPE_PNG",
")",
"{",
"imagealphablending",
"(",
"$",
"canvas",
",",
"false",
")",
";",
"imagesavealpha",
"(",
"$",
"canvas",
",",
"true",
")",
";",
"}",
"// Return the canvas",
"return",
"$",
"canvas",
";",
"}"
] | Create a new canvas element
@return Resource | [
"Create",
"a",
"new",
"canvas",
"element"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L309-L322 |
6,431 | LasseHaslev/image-handler | src/Modifiers/ImageModifier.php | ImageModifier.replace | public function replace($res)
{
// Check if the image we should replace with is resource
if (!is_resource($res)) {
throw new UnexpectedValueException('Invalid resource');
}
// Check if we can destroy the image
if (is_resource($this->image)) {
imagedestroy($this->image);
}
// Set the new image as image
$this->image = $res;
// Return $this for chaining
return $this;
} | php | public function replace($res)
{
// Check if the image we should replace with is resource
if (!is_resource($res)) {
throw new UnexpectedValueException('Invalid resource');
}
// Check if we can destroy the image
if (is_resource($this->image)) {
imagedestroy($this->image);
}
// Set the new image as image
$this->image = $res;
// Return $this for chaining
return $this;
} | [
"public",
"function",
"replace",
"(",
"$",
"res",
")",
"{",
"// Check if the image we should replace with is resource",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"res",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Invalid resource'",
")",
";",
"}",
"// Check if we can destroy the image",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"image",
")",
")",
"{",
"imagedestroy",
"(",
"$",
"this",
"->",
"image",
")",
";",
"}",
"// Set the new image as image",
"$",
"this",
"->",
"image",
"=",
"$",
"res",
";",
"// Return $this for chaining",
"return",
"$",
"this",
";",
"}"
] | Replaces the image with the new image
@return $this | [
"Replaces",
"the",
"image",
"with",
"the",
"new",
"image"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Modifiers/ImageModifier.php#L330-L348 |
6,432 | laraviet/l5scaffold | src/stubs/Libs/ValueHelper.php | ValueHelper.getOldInput | public static function getOldInput($model, $property)
{
if (\Session::getOldInput($property) !== null) {
return \Session::getOldInput($property);
}
return $model->$property;
} | php | public static function getOldInput($model, $property)
{
if (\Session::getOldInput($property) !== null) {
return \Session::getOldInput($property);
}
return $model->$property;
} | [
"public",
"static",
"function",
"getOldInput",
"(",
"$",
"model",
",",
"$",
"property",
")",
"{",
"if",
"(",
"\\",
"Session",
"::",
"getOldInput",
"(",
"$",
"property",
")",
"!==",
"null",
")",
"{",
"return",
"\\",
"Session",
"::",
"getOldInput",
"(",
"$",
"property",
")",
";",
"}",
"return",
"$",
"model",
"->",
"$",
"property",
";",
"}"
] | Get old input when validate has errors
@param Model instance $model
@param string $property | [
"Get",
"old",
"input",
"when",
"validate",
"has",
"errors"
] | 765188e47fc1fb38d599342ac71a24e53f4dcac9 | https://github.com/laraviet/l5scaffold/blob/765188e47fc1fb38d599342ac71a24e53f4dcac9/src/stubs/Libs/ValueHelper.php#L14-L20 |
6,433 | ProgMiner/image-constructor | lib/Utility.php | Utility.transparentImage | public static function transparentImage(int $width, int $height): Image {
$image = imagecreatetruecolor(max($width, 1), max($height, 1));
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
imagesavealpha($image, true);
return new Image($image);
} | php | public static function transparentImage(int $width, int $height): Image {
$image = imagecreatetruecolor(max($width, 1), max($height, 1));
$transparent = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparent);
imagesavealpha($image, true);
return new Image($image);
} | [
"public",
"static",
"function",
"transparentImage",
"(",
"int",
"$",
"width",
",",
"int",
"$",
"height",
")",
":",
"Image",
"{",
"$",
"image",
"=",
"imagecreatetruecolor",
"(",
"max",
"(",
"$",
"width",
",",
"1",
")",
",",
"max",
"(",
"$",
"height",
",",
"1",
")",
")",
";",
"$",
"transparent",
"=",
"imagecolorallocatealpha",
"(",
"$",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"127",
")",
";",
"imagefill",
"(",
"$",
"image",
",",
"0",
",",
"0",
",",
"$",
"transparent",
")",
";",
"imagesavealpha",
"(",
"$",
"image",
",",
"true",
")",
";",
"return",
"new",
"Image",
"(",
"$",
"image",
")",
";",
"}"
] | Creates empty transparent GD image
@link http://php.net/manual/function.imagefill.php#110186
@param int $width
@param int $height
@return Image | [
"Creates",
"empty",
"transparent",
"GD",
"image"
] | a8d323f7c5f7d9ba131d6e0b4b52155c98dd240c | https://github.com/ProgMiner/image-constructor/blob/a8d323f7c5f7d9ba131d6e0b4b52155c98dd240c/lib/Utility.php#L46-L53 |
6,434 | rodchyn/elephant-lang | lib/ParserGenerator/PHP/ParserGenerator/Symbol.php | PHP_ParserGenerator_Symbol.sortSymbols | public static function sortSymbols($a, $b)
{
$i1 = $a->index + 10000000*(ord($a->name[0]) > ord('Z'));
$i2 = $b->index + 10000000*(ord($b->name[0]) > ord('Z'));
return $i1 - $i2;
} | php | public static function sortSymbols($a, $b)
{
$i1 = $a->index + 10000000*(ord($a->name[0]) > ord('Z'));
$i2 = $b->index + 10000000*(ord($b->name[0]) > ord('Z'));
return $i1 - $i2;
} | [
"public",
"static",
"function",
"sortSymbols",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"i1",
"=",
"$",
"a",
"->",
"index",
"+",
"10000000",
"*",
"(",
"ord",
"(",
"$",
"a",
"->",
"name",
"[",
"0",
"]",
")",
">",
"ord",
"(",
"'Z'",
")",
")",
";",
"$",
"i2",
"=",
"$",
"b",
"->",
"index",
"+",
"10000000",
"*",
"(",
"ord",
"(",
"$",
"b",
"->",
"name",
"[",
"0",
"]",
")",
">",
"ord",
"(",
"'Z'",
")",
")",
";",
"return",
"$",
"i1",
"-",
"$",
"i2",
";",
"}"
] | Sort function helper for symbols
Symbols that begin with upper case letters (terminals or tokens)
must sort before symbols that begin with lower case letters
(non-terminals). Other than that, the order does not matter.
We find experimentally that leaving the symbols in their original
order (the order they appeared in the grammar file) gives the
smallest parser tables in SQLite.
@param PHP_ParserGenerator_Symbol
@param PHP_ParserGenerator_Symbol | [
"Sort",
"function",
"helper",
"for",
"symbols"
] | e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf | https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Symbol.php#L267-L272 |
6,435 | rodchyn/elephant-lang | lib/ParserGenerator/PHP/ParserGenerator/Symbol.php | PHP_ParserGenerator_Symbol.same_symbol | public static function same_symbol(PHP_ParserGenerator_Symbol $a, PHP_ParserGenerator_Symbol $b)
{
if ($a === $b) return 1;
if ($a->type != self::MULTITERMINAL) return 0;
if ($b->type != self::MULTITERMINAL) return 0;
if ($a->nsubsym != $b->nsubsym) return 0;
for ($i = 0; $i < $a->nsubsym; $i++) {
if ($a->subsym[$i] != $b->subsym[$i]) return 0;
}
return 1;
} | php | public static function same_symbol(PHP_ParserGenerator_Symbol $a, PHP_ParserGenerator_Symbol $b)
{
if ($a === $b) return 1;
if ($a->type != self::MULTITERMINAL) return 0;
if ($b->type != self::MULTITERMINAL) return 0;
if ($a->nsubsym != $b->nsubsym) return 0;
for ($i = 0; $i < $a->nsubsym; $i++) {
if ($a->subsym[$i] != $b->subsym[$i]) return 0;
}
return 1;
} | [
"public",
"static",
"function",
"same_symbol",
"(",
"PHP_ParserGenerator_Symbol",
"$",
"a",
",",
"PHP_ParserGenerator_Symbol",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"===",
"$",
"b",
")",
"return",
"1",
";",
"if",
"(",
"$",
"a",
"->",
"type",
"!=",
"self",
"::",
"MULTITERMINAL",
")",
"return",
"0",
";",
"if",
"(",
"$",
"b",
"->",
"type",
"!=",
"self",
"::",
"MULTITERMINAL",
")",
"return",
"0",
";",
"if",
"(",
"$",
"a",
"->",
"nsubsym",
"!=",
"$",
"b",
"->",
"nsubsym",
")",
"return",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"a",
"->",
"nsubsym",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"subsym",
"[",
"$",
"i",
"]",
"!=",
"$",
"b",
"->",
"subsym",
"[",
"$",
"i",
"]",
")",
"return",
"0",
";",
"}",
"return",
"1",
";",
"}"
] | Return true if two symbols are the same. | [
"Return",
"true",
"if",
"two",
"symbols",
"are",
"the",
"same",
"."
] | e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf | https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/Symbol.php#L277-L287 |
6,436 | webbuilders-group/silverstripe-kapost-bridge | code/control/KapostAdmin.php | KapostAdmin.getEditForm | public function getEditForm($id=null, $fields=null) {
$form=parent::getEditForm($id, $fields);
Requirements::css(KAPOST_DIR.'/css/KapostAdmin.css');
Requirements::javascript(KAPOST_DIR.'/javascript/KapostAdmin.js');
if($this->modelClass=='KapostObject' && $gridField=$form->Fields()->dataFieldByName('KapostObject')) {
$gridField->setList($gridField->getList()->filter('IsKapostPreview', 0));
$gridField->getConfig()
->addComponent(new KapostGridFieldRefreshButton('before'))
->removeComponentsByType('GridFieldAddNewButton')
->getComponentByType('GridFieldDataColumns')
->setFieldCasting(array(
'Created'=>'SS_Datetime->FormatFromSettings',
'KapostChangeType'=>'KapostFieldCaster->NiceChangeType',
'ToPublish'=>'KapostFieldCaster->NiceToPublish'
));
$gridField->getConfig()
->getComponentByType('GridFieldDetailForm')
->setItemRequestClass('KapostGridFieldDetailForm_ItemRequest');
}else if($this->modelClass=='KapostConversionHistory' && $gridField=$form->Fields()->dataFieldByName('KapostConversionHistory')) {
$gridField->getConfig()
->removeComponentsByType('GridFieldAddNewButton')
->addComponent(new KapostDestinationAction(), 'GridFieldEditButton');
$dataColumns=$gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$dataColumns->setFieldCasting(array(
'Created'=>'SS_Datetime->FormatFromSettings'
));
$columns=$dataColumns->getDisplayFields($gridField);
$columns['DestinationTypeNice']=_t('KapostConversionHistory.db_DestinationType', '_Destination Type');
$columns['KapostChangeTypeNice']=_t('KapostConversionHistory.db_KapostChangeType', '_Change Type');
$columns=$dataColumns->setDisplayFields($columns);
$gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function(Form $form) {
$form->addExtraClass('KapostAdmin');
});
}
$form->addExtraClass('KapostAdmin');
return $form;
} | php | public function getEditForm($id=null, $fields=null) {
$form=parent::getEditForm($id, $fields);
Requirements::css(KAPOST_DIR.'/css/KapostAdmin.css');
Requirements::javascript(KAPOST_DIR.'/javascript/KapostAdmin.js');
if($this->modelClass=='KapostObject' && $gridField=$form->Fields()->dataFieldByName('KapostObject')) {
$gridField->setList($gridField->getList()->filter('IsKapostPreview', 0));
$gridField->getConfig()
->addComponent(new KapostGridFieldRefreshButton('before'))
->removeComponentsByType('GridFieldAddNewButton')
->getComponentByType('GridFieldDataColumns')
->setFieldCasting(array(
'Created'=>'SS_Datetime->FormatFromSettings',
'KapostChangeType'=>'KapostFieldCaster->NiceChangeType',
'ToPublish'=>'KapostFieldCaster->NiceToPublish'
));
$gridField->getConfig()
->getComponentByType('GridFieldDetailForm')
->setItemRequestClass('KapostGridFieldDetailForm_ItemRequest');
}else if($this->modelClass=='KapostConversionHistory' && $gridField=$form->Fields()->dataFieldByName('KapostConversionHistory')) {
$gridField->getConfig()
->removeComponentsByType('GridFieldAddNewButton')
->addComponent(new KapostDestinationAction(), 'GridFieldEditButton');
$dataColumns=$gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$dataColumns->setFieldCasting(array(
'Created'=>'SS_Datetime->FormatFromSettings'
));
$columns=$dataColumns->getDisplayFields($gridField);
$columns['DestinationTypeNice']=_t('KapostConversionHistory.db_DestinationType', '_Destination Type');
$columns['KapostChangeTypeNice']=_t('KapostConversionHistory.db_KapostChangeType', '_Change Type');
$columns=$dataColumns->setDisplayFields($columns);
$gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function(Form $form) {
$form->addExtraClass('KapostAdmin');
});
}
$form->addExtraClass('KapostAdmin');
return $form;
} | [
"public",
"function",
"getEditForm",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"form",
"=",
"parent",
"::",
"getEditForm",
"(",
"$",
"id",
",",
"$",
"fields",
")",
";",
"Requirements",
"::",
"css",
"(",
"KAPOST_DIR",
".",
"'/css/KapostAdmin.css'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"KAPOST_DIR",
".",
"'/javascript/KapostAdmin.js'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"modelClass",
"==",
"'KapostObject'",
"&&",
"$",
"gridField",
"=",
"$",
"form",
"->",
"Fields",
"(",
")",
"->",
"dataFieldByName",
"(",
"'KapostObject'",
")",
")",
"{",
"$",
"gridField",
"->",
"setList",
"(",
"$",
"gridField",
"->",
"getList",
"(",
")",
"->",
"filter",
"(",
"'IsKapostPreview'",
",",
"0",
")",
")",
";",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"addComponent",
"(",
"new",
"KapostGridFieldRefreshButton",
"(",
"'before'",
")",
")",
"->",
"removeComponentsByType",
"(",
"'GridFieldAddNewButton'",
")",
"->",
"getComponentByType",
"(",
"'GridFieldDataColumns'",
")",
"->",
"setFieldCasting",
"(",
"array",
"(",
"'Created'",
"=>",
"'SS_Datetime->FormatFromSettings'",
",",
"'KapostChangeType'",
"=>",
"'KapostFieldCaster->NiceChangeType'",
",",
"'ToPublish'",
"=>",
"'KapostFieldCaster->NiceToPublish'",
")",
")",
";",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"getComponentByType",
"(",
"'GridFieldDetailForm'",
")",
"->",
"setItemRequestClass",
"(",
"'KapostGridFieldDetailForm_ItemRequest'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"modelClass",
"==",
"'KapostConversionHistory'",
"&&",
"$",
"gridField",
"=",
"$",
"form",
"->",
"Fields",
"(",
")",
"->",
"dataFieldByName",
"(",
"'KapostConversionHistory'",
")",
")",
"{",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"removeComponentsByType",
"(",
"'GridFieldAddNewButton'",
")",
"->",
"addComponent",
"(",
"new",
"KapostDestinationAction",
"(",
")",
",",
"'GridFieldEditButton'",
")",
";",
"$",
"dataColumns",
"=",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"getComponentByType",
"(",
"'GridFieldDataColumns'",
")",
";",
"$",
"dataColumns",
"->",
"setFieldCasting",
"(",
"array",
"(",
"'Created'",
"=>",
"'SS_Datetime->FormatFromSettings'",
")",
")",
";",
"$",
"columns",
"=",
"$",
"dataColumns",
"->",
"getDisplayFields",
"(",
"$",
"gridField",
")",
";",
"$",
"columns",
"[",
"'DestinationTypeNice'",
"]",
"=",
"_t",
"(",
"'KapostConversionHistory.db_DestinationType'",
",",
"'_Destination Type'",
")",
";",
"$",
"columns",
"[",
"'KapostChangeTypeNice'",
"]",
"=",
"_t",
"(",
"'KapostConversionHistory.db_KapostChangeType'",
",",
"'_Change Type'",
")",
";",
"$",
"columns",
"=",
"$",
"dataColumns",
"->",
"setDisplayFields",
"(",
"$",
"columns",
")",
";",
"$",
"gridField",
"->",
"getConfig",
"(",
")",
"->",
"getComponentByType",
"(",
"'GridFieldDetailForm'",
")",
"->",
"setItemEditFormCallback",
"(",
"function",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"addExtraClass",
"(",
"'KapostAdmin'",
")",
";",
"}",
")",
";",
"}",
"$",
"form",
"->",
"addExtraClass",
"(",
"'KapostAdmin'",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Form used for displaying the gridfield in the model admin
@param string $id ID of the form
@param FieldList $fields Fields to use in the form
@return Form Form to be used in the model admin interface | [
"Form",
"used",
"for",
"displaying",
"the",
"gridfield",
"in",
"the",
"model",
"admin"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/control/KapostAdmin.php#L34-L82 |
6,437 | webbuilders-group/silverstripe-kapost-bridge | code/control/KapostAdmin.php | KapostAdmin.getList | public function getList() {
$context=$this->getSearchContext();
$params=$this->getRequest()->requestVar('q');
if(is_array($params)) {
if(array_key_exists('Created', $params) && is_array($params['Created'])) {
$params['Created']=implode(' ', $params['Created']);
}
$params=array_map('trim', $params);
}
$list=$context->getResults($params);
$this->extend('updateList', $list);
return $list;
} | php | public function getList() {
$context=$this->getSearchContext();
$params=$this->getRequest()->requestVar('q');
if(is_array($params)) {
if(array_key_exists('Created', $params) && is_array($params['Created'])) {
$params['Created']=implode(' ', $params['Created']);
}
$params=array_map('trim', $params);
}
$list=$context->getResults($params);
$this->extend('updateList', $list);
return $list;
} | [
"public",
"function",
"getList",
"(",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getSearchContext",
"(",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"requestVar",
"(",
"'q'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'Created'",
",",
"$",
"params",
")",
"&&",
"is_array",
"(",
"$",
"params",
"[",
"'Created'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'Created'",
"]",
"=",
"implode",
"(",
"' '",
",",
"$",
"params",
"[",
"'Created'",
"]",
")",
";",
"}",
"$",
"params",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"params",
")",
";",
"}",
"$",
"list",
"=",
"$",
"context",
"->",
"getResults",
"(",
"$",
"params",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"'updateList'",
",",
"$",
"list",
")",
";",
"return",
"$",
"list",
";",
"}"
] | Gets the list used in the ModelAdmin
@return SS_List | [
"Gets",
"the",
"list",
"used",
"in",
"the",
"ModelAdmin"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/control/KapostAdmin.php#L113-L130 |
6,438 | factorio-item-browser/api-database | src/Filter/DataFilter.php | DataFilter.filter | public function filter(array $data): array
{
/* @var array|DataInterface[] $result */
$result = [];
foreach ($data as $item) {
$key = implode('|', $item->getKeys());
if (!isset($result[$key]) || $result[$key]->getOrder() < $item->getOrder()) {
$result[$key] = $item;
}
}
return array_values($result);
} | php | public function filter(array $data): array
{
/* @var array|DataInterface[] $result */
$result = [];
foreach ($data as $item) {
$key = implode('|', $item->getKeys());
if (!isset($result[$key]) || $result[$key]->getOrder() < $item->getOrder()) {
$result[$key] = $item;
}
}
return array_values($result);
} | [
"public",
"function",
"filter",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"/* @var array|DataInterface[] $result */",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"$",
"key",
"=",
"implode",
"(",
"'|'",
",",
"$",
"item",
"->",
"getKeys",
"(",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"||",
"$",
"result",
"[",
"$",
"key",
"]",
"->",
"getOrder",
"(",
")",
"<",
"$",
"item",
"->",
"getOrder",
"(",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"result",
")",
";",
"}"
] | Filters the data to only contain the items with the highest order.
@param array|DataInterface[] $data
@return array|DataInterface[] | [
"Filters",
"the",
"data",
"to",
"only",
"contain",
"the",
"items",
"with",
"the",
"highest",
"order",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Filter/DataFilter.php#L22-L33 |
6,439 | mizmoz/container | src/InjectContainer.php | InjectContainer.classUses | public static function classUses($class, string $find): bool
{
$uses = class_uses($class);
if (in_array($find, $uses)) {
// found the item
return true;
}
// add any parent classes to the search
$uses = array_merge($uses, class_parents($class));
foreach ($uses as $use) {
if (static::classUses($use, $find)) {
return true;
}
}
return false;
} | php | public static function classUses($class, string $find): bool
{
$uses = class_uses($class);
if (in_array($find, $uses)) {
// found the item
return true;
}
// add any parent classes to the search
$uses = array_merge($uses, class_parents($class));
foreach ($uses as $use) {
if (static::classUses($use, $find)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"classUses",
"(",
"$",
"class",
",",
"string",
"$",
"find",
")",
":",
"bool",
"{",
"$",
"uses",
"=",
"class_uses",
"(",
"$",
"class",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"find",
",",
"$",
"uses",
")",
")",
"{",
"// found the item",
"return",
"true",
";",
"}",
"// add any parent classes to the search",
"$",
"uses",
"=",
"array_merge",
"(",
"$",
"uses",
",",
"class_parents",
"(",
"$",
"class",
")",
")",
";",
"foreach",
"(",
"$",
"uses",
"as",
"$",
"use",
")",
"{",
"if",
"(",
"static",
"::",
"classUses",
"(",
"$",
"use",
",",
"$",
"find",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check to see if the class uses the provided item
@param $class
@param string $find
@return bool | [
"Check",
"to",
"see",
"if",
"the",
"class",
"uses",
"the",
"provided",
"item"
] | 7ae194189595fbcd392445bb41ac8ddb118b5b7c | https://github.com/mizmoz/container/blob/7ae194189595fbcd392445bb41ac8ddb118b5b7c/src/InjectContainer.php#L39-L58 |
6,440 | tarsana/filesystem | src/Filesystem.php | Filesystem.whatIs | public function whatIs($pattern)
{
if (! $this->adapter->isAbsolute($pattern)) {
$pattern = $this->rootPath . $pattern;
}
$paths = $this->adapter->glob($pattern);
if (count($paths) == 0)
return 'nothing';
if (count($paths) == 1)
return ($this->adapter->isFile($paths[0])) ? 'file' : 'dir';
return 'collection';
} | php | public function whatIs($pattern)
{
if (! $this->adapter->isAbsolute($pattern)) {
$pattern = $this->rootPath . $pattern;
}
$paths = $this->adapter->glob($pattern);
if (count($paths) == 0)
return 'nothing';
if (count($paths) == 1)
return ($this->adapter->isFile($paths[0])) ? 'file' : 'dir';
return 'collection';
} | [
"public",
"function",
"whatIs",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"pattern",
")",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"pattern",
";",
"}",
"$",
"paths",
"=",
"$",
"this",
"->",
"adapter",
"->",
"glob",
"(",
"$",
"pattern",
")",
";",
"if",
"(",
"count",
"(",
"$",
"paths",
")",
"==",
"0",
")",
"return",
"'nothing'",
";",
"if",
"(",
"count",
"(",
"$",
"paths",
")",
"==",
"1",
")",
"return",
"(",
"$",
"this",
"->",
"adapter",
"->",
"isFile",
"(",
"$",
"paths",
"[",
"0",
"]",
")",
")",
"?",
"'file'",
":",
"'dir'",
";",
"return",
"'collection'",
";",
"}"
] | Tells what is the given pattern matching, returns 'file' or 'dir' if a
single file or directory matches the pattern. Returns 'collection'
if there are multiple matches and 'nothing' if no match found.
@param string $pattern
@return string | [
"Tells",
"what",
"is",
"the",
"given",
"pattern",
"matching",
"returns",
"file",
"or",
"dir",
"if",
"a",
"single",
"file",
"or",
"directory",
"matches",
"the",
"pattern",
".",
"Returns",
"collection",
"if",
"there",
"are",
"multiple",
"matches",
"and",
"nothing",
"if",
"no",
"match",
"found",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L78-L91 |
6,441 | tarsana/filesystem | src/Filesystem.php | Filesystem.is | protected function is($path, $type)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
switch ($type) {
case 'readable':
return $this->adapter->isReadable($path);
case 'writable':
return $this->adapter->isWritable($path);
case 'executable':
return $this->adapter->isExecutable($path);
case 'file':
return $this->adapter->isFile($path);
case 'dir':
return $this->adapter->isDir($path);
case 'any':
return $this->adapter->fileExists($path);
default:
throw new FilesystemException("Unknown file type '{$type}'");
}
} | php | protected function is($path, $type)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
switch ($type) {
case 'readable':
return $this->adapter->isReadable($path);
case 'writable':
return $this->adapter->isWritable($path);
case 'executable':
return $this->adapter->isExecutable($path);
case 'file':
return $this->adapter->isFile($path);
case 'dir':
return $this->adapter->isDir($path);
case 'any':
return $this->adapter->fileExists($path);
default:
throw new FilesystemException("Unknown file type '{$type}'");
}
} | [
"protected",
"function",
"is",
"(",
"$",
"path",
",",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"path",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'readable'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"isReadable",
"(",
"$",
"path",
")",
";",
"case",
"'writable'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"isWritable",
"(",
"$",
"path",
")",
";",
"case",
"'executable'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"isExecutable",
"(",
"$",
"path",
")",
";",
"case",
"'file'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"isFile",
"(",
"$",
"path",
")",
";",
"case",
"'dir'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"isDir",
"(",
"$",
"path",
")",
";",
"case",
"'any'",
":",
"return",
"$",
"this",
"->",
"adapter",
"->",
"fileExists",
"(",
"$",
"path",
")",
";",
"default",
":",
"throw",
"new",
"FilesystemException",
"(",
"\"Unknown file type '{$type}'\"",
")",
";",
"}",
"}"
] | Checks if the given path is of the given type.
@param string $path
@param string $type
@return boolean | [
"Checks",
"if",
"the",
"given",
"path",
"is",
"of",
"the",
"given",
"type",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L100-L121 |
6,442 | tarsana/filesystem | src/Filesystem.php | Filesystem.are | protected function are($paths, $type)
{
foreach ($paths as $path) {
if (! $this->is($path, $type)) {
return false;
}
}
return (count($paths) == 0) ? false : true;
} | php | protected function are($paths, $type)
{
foreach ($paths as $path) {
if (! $this->is($path, $type)) {
return false;
}
}
return (count($paths) == 0) ? false : true;
} | [
"protected",
"function",
"are",
"(",
"$",
"paths",
",",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"is",
"(",
"$",
"path",
",",
"$",
"type",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"(",
"count",
"(",
"$",
"paths",
")",
"==",
"0",
")",
"?",
"false",
":",
"true",
";",
"}"
] | Checks if the given paths are all of the given type.
@param array $paths
@param string $type
@return boolean | [
"Checks",
"if",
"the",
"given",
"paths",
"are",
"all",
"of",
"the",
"given",
"type",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L130-L138 |
6,443 | tarsana/filesystem | src/Filesystem.php | Filesystem.file | public function file($path, $createMissing = false)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if (! $createMissing && ! $this->isFile($path, true)) {
throw new FilesystemException("Cannot find the file '{$path}'");
}
return new File($path, $this->adapter);
} | php | public function file($path, $createMissing = false)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if (! $createMissing && ! $this->isFile($path, true)) {
throw new FilesystemException("Cannot find the file '{$path}'");
}
return new File($path, $this->adapter);
} | [
"public",
"function",
"file",
"(",
"$",
"path",
",",
"$",
"createMissing",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"path",
";",
"}",
"if",
"(",
"!",
"$",
"createMissing",
"&&",
"!",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
",",
"true",
")",
")",
"{",
"throw",
"new",
"FilesystemException",
"(",
"\"Cannot find the file '{$path}'\"",
")",
";",
"}",
"return",
"new",
"File",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"adapter",
")",
";",
"}"
] | Gets a file by relative or absolute path,
optionally creates the file if missing.
@param string $path
@param boolean $createMissing
@return Tarsana\Filesystem\File
@throws Tarsana\Filesystem\Exceptions\FilesystemException | [
"Gets",
"a",
"file",
"by",
"relative",
"or",
"absolute",
"path",
"optionally",
"creates",
"the",
"file",
"if",
"missing",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L283-L293 |
6,444 | tarsana/filesystem | src/Filesystem.php | Filesystem.files | public function files($paths = false, $createMissing = false)
{
if ($paths === false) {
return $this->find('*')->files();
}
$list = new Collection;
foreach ($paths as $path) {
$list->add($this->file($path, $createMissing));
}
return $list;
} | php | public function files($paths = false, $createMissing = false)
{
if ($paths === false) {
return $this->find('*')->files();
}
$list = new Collection;
foreach ($paths as $path) {
$list->add($this->file($path, $createMissing));
}
return $list;
} | [
"public",
"function",
"files",
"(",
"$",
"paths",
"=",
"false",
",",
"$",
"createMissing",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"paths",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"find",
"(",
"'*'",
")",
"->",
"files",
"(",
")",
";",
"}",
"$",
"list",
"=",
"new",
"Collection",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"list",
"->",
"add",
"(",
"$",
"this",
"->",
"file",
"(",
"$",
"path",
",",
"$",
"createMissing",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Gets files by relative or absolute path,
optionally creates missing files.
@param array $paths
@param boolean $createMissing
@return Tarsana\Filesystem\Collection
@throws Tarsana\Filesystem\Exceptions\FilesystemException | [
"Gets",
"files",
"by",
"relative",
"or",
"absolute",
"path",
"optionally",
"creates",
"missing",
"files",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L305-L316 |
6,445 | tarsana/filesystem | src/Filesystem.php | Filesystem.dir | public function dir($path, $createMissing = false)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if (! $createMissing && ! $this->isDir($path, true)) {
throw new FilesystemException("Cannot find the directory '{$path}'");
}
return new Directory($path, $this->adapter);
} | php | public function dir($path, $createMissing = false)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if (! $createMissing && ! $this->isDir($path, true)) {
throw new FilesystemException("Cannot find the directory '{$path}'");
}
return new Directory($path, $this->adapter);
} | [
"public",
"function",
"dir",
"(",
"$",
"path",
",",
"$",
"createMissing",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"path",
";",
"}",
"if",
"(",
"!",
"$",
"createMissing",
"&&",
"!",
"$",
"this",
"->",
"isDir",
"(",
"$",
"path",
",",
"true",
")",
")",
"{",
"throw",
"new",
"FilesystemException",
"(",
"\"Cannot find the directory '{$path}'\"",
")",
";",
"}",
"return",
"new",
"Directory",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"adapter",
")",
";",
"}"
] | Gets a directory by relative or absolute path,
optionally creates the directory if missing.
@param string $path
@param boolean $createMissing
@return Tarsana\Filesystem\Directory
@throws Tarsana\Filesystem\Exceptions\FilesystemException | [
"Gets",
"a",
"directory",
"by",
"relative",
"or",
"absolute",
"path",
"optionally",
"creates",
"the",
"directory",
"if",
"missing",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L328-L337 |
6,446 | tarsana/filesystem | src/Filesystem.php | Filesystem.dirs | public function dirs($paths = false, $createMissing = false)
{
if ($paths === false) {
return $this->find('*')->dirs();
}
$list = new Collection;
foreach ($paths as $path) {
$list->add($this->dir($path, $createMissing));
}
return $list;
} | php | public function dirs($paths = false, $createMissing = false)
{
if ($paths === false) {
return $this->find('*')->dirs();
}
$list = new Collection;
foreach ($paths as $path) {
$list->add($this->dir($path, $createMissing));
}
return $list;
} | [
"public",
"function",
"dirs",
"(",
"$",
"paths",
"=",
"false",
",",
"$",
"createMissing",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"paths",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"find",
"(",
"'*'",
")",
"->",
"dirs",
"(",
")",
";",
"}",
"$",
"list",
"=",
"new",
"Collection",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"list",
"->",
"add",
"(",
"$",
"this",
"->",
"dir",
"(",
"$",
"path",
",",
"$",
"createMissing",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Gets directories by relative or absolute path,
optionally creates missing directories.
@param array $paths
@param boolean $createMissing
@return Tarsana\Filesystem\Collection
@throws Tarsana\Filesystem\Exceptions\FilesystemException | [
"Gets",
"directories",
"by",
"relative",
"or",
"absolute",
"path",
"optionally",
"creates",
"missing",
"directories",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L349-L360 |
6,447 | tarsana/filesystem | src/Filesystem.php | Filesystem.find | public function find($pattern)
{
if (! $this->adapter->isAbsolute($pattern)) {
$pattern = $this->rootPath . $pattern;
}
$list = new Collection;
foreach ($this->adapter->glob($pattern) as $path) {
if ($this->isFile($path, true)) {
$list->add(new File($path, $this->adapter));
} else {
$list->add(new Directory($path, $this->adapter));
}
}
return $list;
} | php | public function find($pattern)
{
if (! $this->adapter->isAbsolute($pattern)) {
$pattern = $this->rootPath . $pattern;
}
$list = new Collection;
foreach ($this->adapter->glob($pattern) as $path) {
if ($this->isFile($path, true)) {
$list->add(new File($path, $this->adapter));
} else {
$list->add(new Directory($path, $this->adapter));
}
}
return $list;
} | [
"public",
"function",
"find",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"pattern",
")",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"pattern",
";",
"}",
"$",
"list",
"=",
"new",
"Collection",
";",
"foreach",
"(",
"$",
"this",
"->",
"adapter",
"->",
"glob",
"(",
"$",
"pattern",
")",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
",",
"true",
")",
")",
"{",
"$",
"list",
"->",
"add",
"(",
"new",
"File",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"adapter",
")",
")",
";",
"}",
"else",
"{",
"$",
"list",
"->",
"add",
"(",
"new",
"Directory",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"adapter",
")",
")",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] | Finds files and directories matching the given pattern
and returns a collection containing them.
@param string $pattern
@return Tarsana\Filesystem\Collection | [
"Finds",
"files",
"and",
"directories",
"matching",
"the",
"given",
"pattern",
"and",
"returns",
"a",
"collection",
"containing",
"them",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L369-L383 |
6,448 | tarsana/filesystem | src/Filesystem.php | Filesystem.remove | public function remove($path)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if ($this->isFile($path, true)) {
$this->adapter->unlink($path);
} else {
// clean the directory
$path = rtrim($path, '/') . '/';
foreach ($this->adapter->glob($path . '*') as $itemPath) {
$this->remove($itemPath, true);
}
// remove it
$this->adapter->rmdir($path);
}
return $this;
} | php | public function remove($path)
{
if (! $this->adapter->isAbsolute($path)) {
$path = $this->rootPath . $path;
}
if ($this->isFile($path, true)) {
$this->adapter->unlink($path);
} else {
// clean the directory
$path = rtrim($path, '/') . '/';
foreach ($this->adapter->glob($path . '*') as $itemPath) {
$this->remove($itemPath, true);
}
// remove it
$this->adapter->rmdir($path);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adapter",
"->",
"isAbsolute",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"rootPath",
".",
"$",
"path",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"unlink",
"(",
"$",
"path",
")",
";",
"}",
"else",
"{",
"// clean the directory",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
";",
"foreach",
"(",
"$",
"this",
"->",
"adapter",
"->",
"glob",
"(",
"$",
"path",
".",
"'*'",
")",
"as",
"$",
"itemPath",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"itemPath",
",",
"true",
")",
";",
"}",
"// remove it",
"$",
"this",
"->",
"adapter",
"->",
"rmdir",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a file or directory recursively.
@param string $path
@return Tarsana\Filesystem | [
"Removes",
"a",
"file",
"or",
"directory",
"recursively",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Filesystem.php#L391-L408 |
6,449 | cerad/di | Container.php | Container.set | public function set($id,$item,$tagArg = null)
{
if (!is_callable($item)) $this->instances[$id] = $item;
else
{
$this->callables[$id] = $item;
unset($this->instances[$id]);
}
if (!$tagArg) return $this;
$tag = is_array($tagArg) ? $tagArg : ['name' => $tagArg];
$tag['service_id'] = $id;
$name = $tag['name'];
$this->tags[$name][] = $tag;
return $this;
} | php | public function set($id,$item,$tagArg = null)
{
if (!is_callable($item)) $this->instances[$id] = $item;
else
{
$this->callables[$id] = $item;
unset($this->instances[$id]);
}
if (!$tagArg) return $this;
$tag = is_array($tagArg) ? $tagArg : ['name' => $tagArg];
$tag['service_id'] = $id;
$name = $tag['name'];
$this->tags[$name][] = $tag;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"id",
",",
"$",
"item",
",",
"$",
"tagArg",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"item",
")",
")",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]",
"=",
"$",
"item",
";",
"else",
"{",
"$",
"this",
"->",
"callables",
"[",
"$",
"id",
"]",
"=",
"$",
"item",
";",
"unset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"tagArg",
")",
"return",
"$",
"this",
";",
"$",
"tag",
"=",
"is_array",
"(",
"$",
"tagArg",
")",
"?",
"$",
"tagArg",
":",
"[",
"'name'",
"=>",
"$",
"tagArg",
"]",
";",
"$",
"tag",
"[",
"'service_id'",
"]",
"=",
"$",
"id",
";",
"$",
"name",
"=",
"$",
"tag",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"tags",
"[",
"$",
"name",
"]",
"[",
"]",
"=",
"$",
"tag",
";",
"return",
"$",
"this",
";",
"}"
] | Add a service with optional tagging | [
"Add",
"a",
"service",
"with",
"optional",
"tagging"
] | a70c3a562422867a681e37030c4821facdf8fd90 | https://github.com/cerad/di/blob/a70c3a562422867a681e37030c4821facdf8fd90/Container.php#L17-L36 |
6,450 | cerad/di | Container.php | Container.getTags | public function getTags($name = null)
{
if (!$name) return $this->tags;
return isset($this->tags[$name]) ? $this->tags[$name] : [];
} | php | public function getTags($name = null)
{
if (!$name) return $this->tags;
return isset($this->tags[$name]) ? $this->tags[$name] : [];
} | [
"public",
"function",
"getTags",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"return",
"$",
"this",
"->",
"tags",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"name",
"]",
":",
"[",
"]",
";",
"}"
] | List of services for a given tag | [
"List",
"of",
"services",
"for",
"a",
"given",
"tag"
] | a70c3a562422867a681e37030c4821facdf8fd90 | https://github.com/cerad/di/blob/a70c3a562422867a681e37030c4821facdf8fd90/Container.php#L69-L74 |
6,451 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsDir | public static function assertIsDir(string $path, Throwable $exception): string
{
static::makeAssertion(\is_dir($path), $exception);
return $path;
} | php | public static function assertIsDir(string $path, Throwable $exception): string
{
static::makeAssertion(\is_dir($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsDir",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_dir",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is a directory path.
@param string $path The path to check that must be a directory.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The directory path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"a",
"directory",
"path",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L26-L30 |
6,452 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsFile | public static function assertIsFile(string $path, Throwable $exception): string
{
static::makeAssertion(\is_file($path), $exception);
return $path;
} | php | public static function assertIsFile(string $path, Throwable $exception): string
{
static::makeAssertion(\is_file($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsFile",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_file",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is a file path.
@param string $path The path to check that must be a file.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The file path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"a",
"file",
"path",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L39-L43 |
6,453 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsLink | public static function assertIsLink(string $path, Throwable $exception): string
{
static::makeAssertion(\is_link($path), $exception);
return $path;
} | php | public static function assertIsLink(string $path, Throwable $exception): string
{
static::makeAssertion(\is_link($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsLink",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_link",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is a link path.
@param string $path The path to check that must be a link.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The link path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"a",
"link",
"path",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L52-L56 |
6,454 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsReadable | public static function assertIsReadable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_readable($path), $exception);
return $path;
} | php | public static function assertIsReadable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_readable($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsReadable",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_readable",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is readable.
@param string $path The path to check that must be readable.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"readable",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L65-L69 |
6,455 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsWritable | public static function assertIsWritable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_writable($path), $exception);
return $path;
} | php | public static function assertIsWritable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_writable($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsWritable",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_writable",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is writable.
@param string $path The path to check that must be writable.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"writable",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L78-L82 |
6,456 | niconoe-/asserts | src/Asserts/Categories/AssertFileTrait.php | AssertFileTrait.assertIsExecutable | public static function assertIsExecutable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_executable($path), $exception);
return $path;
} | php | public static function assertIsExecutable(string $path, Throwable $exception): string
{
static::makeAssertion(\is_executable($path), $exception);
return $path;
} | [
"public",
"static",
"function",
"assertIsExecutable",
"(",
"string",
"$",
"path",
",",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_executable",
"(",
"$",
"path",
")",
",",
"$",
"exception",
")",
";",
"return",
"$",
"path",
";",
"}"
] | Asserts that the given path is executable.
@param string $path The path to check that must be executable.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The path if the assertion does not fail. | [
"Asserts",
"that",
"the",
"given",
"path",
"is",
"executable",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertFileTrait.php#L91-L95 |
6,457 | chriscollins/general-utils | lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php | CurlHandle.execute | public function execute()
{
$this->initialiseHandle();
$this->applyOptionsToHandle();
$content = curl_exec($this->handle);
$this->info = $this->getInfoFromHandle();
$this->errorCode = $this->getErrorCodeFromHandle();
$this->errorMessage = $this->getErrorMessageFromHandle();
$this->closeHandle();
return $content;
} | php | public function execute()
{
$this->initialiseHandle();
$this->applyOptionsToHandle();
$content = curl_exec($this->handle);
$this->info = $this->getInfoFromHandle();
$this->errorCode = $this->getErrorCodeFromHandle();
$this->errorMessage = $this->getErrorMessageFromHandle();
$this->closeHandle();
return $content;
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"initialiseHandle",
"(",
")",
";",
"$",
"this",
"->",
"applyOptionsToHandle",
"(",
")",
";",
"$",
"content",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"this",
"->",
"info",
"=",
"$",
"this",
"->",
"getInfoFromHandle",
"(",
")",
";",
"$",
"this",
"->",
"errorCode",
"=",
"$",
"this",
"->",
"getErrorCodeFromHandle",
"(",
")",
";",
"$",
"this",
"->",
"errorMessage",
"=",
"$",
"this",
"->",
"getErrorMessageFromHandle",
"(",
")",
";",
"$",
"this",
"->",
"closeHandle",
"(",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Execute the request and return the content.
@return string The content at the URL. | [
"Execute",
"the",
"request",
"and",
"return",
"the",
"content",
"."
] | 3fef519f3dd97bf15aa16ff528152ae663e027ac | https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php#L69-L84 |
6,458 | chriscollins/general-utils | lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php | CurlHandle.getErrorCodeFromHandle | public function getErrorCodeFromHandle()
{
$errorNumber = null;
if ($this->handle !== null) {
$errorNumber = curl_errno($this->handle);
}
return $errorNumber === 0 ? null : $errorNumber;
} | php | public function getErrorCodeFromHandle()
{
$errorNumber = null;
if ($this->handle !== null) {
$errorNumber = curl_errno($this->handle);
}
return $errorNumber === 0 ? null : $errorNumber;
} | [
"public",
"function",
"getErrorCodeFromHandle",
"(",
")",
"{",
"$",
"errorNumber",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"handle",
"!==",
"null",
")",
"{",
"$",
"errorNumber",
"=",
"curl_errno",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"}",
"return",
"$",
"errorNumber",
"===",
"0",
"?",
"null",
":",
"$",
"errorNumber",
";",
"}"
] | Get the last error code that occurred, or null if there were no problems.
@return int|null An integer representing the last error that occurred, or null if there were no problems. | [
"Get",
"the",
"last",
"error",
"code",
"that",
"occurred",
"or",
"null",
"if",
"there",
"were",
"no",
"problems",
"."
] | 3fef519f3dd97bf15aa16ff528152ae663e027ac | https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php#L236-L245 |
6,459 | chriscollins/general-utils | lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php | CurlHandle.getErrorMessageFromHandle | public function getErrorMessageFromHandle()
{
$errorMessage = null;
if ($this->handle !== null) {
$errorMessage = curl_errno($this->handle);
}
return $errorMessage === '' ? null : $errorMessage;
} | php | public function getErrorMessageFromHandle()
{
$errorMessage = null;
if ($this->handle !== null) {
$errorMessage = curl_errno($this->handle);
}
return $errorMessage === '' ? null : $errorMessage;
} | [
"public",
"function",
"getErrorMessageFromHandle",
"(",
")",
"{",
"$",
"errorMessage",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"handle",
"!==",
"null",
")",
"{",
"$",
"errorMessage",
"=",
"curl_errno",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"}",
"return",
"$",
"errorMessage",
"===",
"''",
"?",
"null",
":",
"$",
"errorMessage",
";",
"}"
] | Get the message for the last error that occurred, or null if there were no problems.
@return string|null An error message, or null if there was no error. | [
"Get",
"the",
"message",
"for",
"the",
"last",
"error",
"that",
"occurred",
"or",
"null",
"if",
"there",
"were",
"no",
"problems",
"."
] | 3fef519f3dd97bf15aa16ff528152ae663e027ac | https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Curl/CurlHandle.php#L262-L271 |
6,460 | academic/VipaImportBundle | Importer/PKP/IssueFileImporter.php | IssueFileImporter.importIssueFiles | public function importIssueFiles($issue, $oldId, $slug)
{
$issueFilesSql = "SELECT * FROM issue_files WHERE issue_id = :id";
$issueFilesStatement = $this->dbalConnection->prepare($issueFilesSql);
$issueFilesStatement->bindValue('id', $oldId);
$issueFilesStatement->execute();
$issueFiles = $issueFilesStatement->fetchAll();
foreach ($issueFiles as $issueFile) {
$this->importIssueFile($issueFile['file_id'], $oldId, $issue, $slug);
}
} | php | public function importIssueFiles($issue, $oldId, $slug)
{
$issueFilesSql = "SELECT * FROM issue_files WHERE issue_id = :id";
$issueFilesStatement = $this->dbalConnection->prepare($issueFilesSql);
$issueFilesStatement->bindValue('id', $oldId);
$issueFilesStatement->execute();
$issueFiles = $issueFilesStatement->fetchAll();
foreach ($issueFiles as $issueFile) {
$this->importIssueFile($issueFile['file_id'], $oldId, $issue, $slug);
}
} | [
"public",
"function",
"importIssueFiles",
"(",
"$",
"issue",
",",
"$",
"oldId",
",",
"$",
"slug",
")",
"{",
"$",
"issueFilesSql",
"=",
"\"SELECT * FROM issue_files WHERE issue_id = :id\"",
";",
"$",
"issueFilesStatement",
"=",
"$",
"this",
"->",
"dbalConnection",
"->",
"prepare",
"(",
"$",
"issueFilesSql",
")",
";",
"$",
"issueFilesStatement",
"->",
"bindValue",
"(",
"'id'",
",",
"$",
"oldId",
")",
";",
"$",
"issueFilesStatement",
"->",
"execute",
"(",
")",
";",
"$",
"issueFiles",
"=",
"$",
"issueFilesStatement",
"->",
"fetchAll",
"(",
")",
";",
"foreach",
"(",
"$",
"issueFiles",
"as",
"$",
"issueFile",
")",
"{",
"$",
"this",
"->",
"importIssueFile",
"(",
"$",
"issueFile",
"[",
"'file_id'",
"]",
",",
"$",
"oldId",
",",
"$",
"issue",
",",
"$",
"slug",
")",
";",
"}",
"}"
] | Imports files of given issue
@param Issue $issue The issue whose files are going to be imported
@param int $oldId Old ID of the issue
@param String $slug Journal's slug
@throws \Doctrine\DBAL\DBALException | [
"Imports",
"files",
"of",
"given",
"issue"
] | cee7d9e51613706a4fd6e2eade44041ce1af9ad3 | https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/IssueFileImporter.php#L21-L32 |
6,461 | cmdweb/kernel | Kernel/Controller.php | Controller.Model | public function Model()
{
$file = $this->getAddressModel();
if(file_exists($file)) {
$model = $this->getClassModel();
$this->model = new $model();
}
} | php | public function Model()
{
$file = $this->getAddressModel();
if(file_exists($file)) {
$model = $this->getClassModel();
$this->model = new $model();
}
} | [
"public",
"function",
"Model",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getAddressModel",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getClassModel",
"(",
")",
";",
"$",
"this",
"->",
"model",
"=",
"new",
"$",
"model",
"(",
")",
";",
"}",
"}"
] | Carrega a model | [
"Carrega",
"a",
"model"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Controller.php#L42-L49 |
6,462 | cmdweb/kernel | Kernel/Controller.php | Controller.generateModel | private function generateModel($model){
if(is_object($model))
Session::set(md5(Request::getArea().Request::getController().Request::getAction()), base64_encode(get_class($model)));
} | php | private function generateModel($model){
if(is_object($model))
Session::set(md5(Request::getArea().Request::getController().Request::getAction()), base64_encode(get_class($model)));
} | [
"private",
"function",
"generateModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"model",
")",
")",
"Session",
"::",
"set",
"(",
"md5",
"(",
"Request",
"::",
"getArea",
"(",
")",
".",
"Request",
"::",
"getController",
"(",
")",
".",
"Request",
"::",
"getAction",
"(",
")",
")",
",",
"base64_encode",
"(",
"get_class",
"(",
"$",
"model",
")",
")",
")",
";",
"}"
] | Gera um gid para gravar a tipagem da model por action | [
"Gera",
"um",
"gid",
"para",
"gravar",
"a",
"tipagem",
"da",
"model",
"por",
"action"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Controller.php#L54-L57 |
6,463 | cmdweb/kernel | Kernel/Controller.php | Controller.getTypeModel | public static function getTypeModel(){
$type = base64_decode(Session::get(md5(Request::getArea().Request::getController().Request::getAction())));
if($type == null)
return 'stdClass';
return $type;
} | php | public static function getTypeModel(){
$type = base64_decode(Session::get(md5(Request::getArea().Request::getController().Request::getAction())));
if($type == null)
return 'stdClass';
return $type;
} | [
"public",
"static",
"function",
"getTypeModel",
"(",
")",
"{",
"$",
"type",
"=",
"base64_decode",
"(",
"Session",
"::",
"get",
"(",
"md5",
"(",
"Request",
"::",
"getArea",
"(",
")",
".",
"Request",
"::",
"getController",
"(",
")",
".",
"Request",
"::",
"getAction",
"(",
")",
")",
")",
")",
";",
"if",
"(",
"$",
"type",
"==",
"null",
")",
"return",
"'stdClass'",
";",
"return",
"$",
"type",
";",
"}"
] | Resgata o tipo da model | [
"Resgata",
"o",
"tipo",
"da",
"model"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Controller.php#L62-L68 |
6,464 | andreas-weber/php-config | src/Core/Config.php | Config.convert | private function convert(array $config)
{
foreach ($config as $index => $data) {
if (is_array($data)) {
$config[$index] = new Config($data);
}
}
return $config;
} | php | private function convert(array $config)
{
foreach ($config as $index => $data) {
if (is_array($data)) {
$config[$index] = new Config($data);
}
}
return $config;
} | [
"private",
"function",
"convert",
"(",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"index",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"config",
"[",
"$",
"index",
"]",
"=",
"new",
"Config",
"(",
"$",
"data",
")",
";",
"}",
"}",
"return",
"$",
"config",
";",
"}"
] | Convert each sub array in an own config instance.
@param array $config
@return array | [
"Convert",
"each",
"sub",
"array",
"in",
"an",
"own",
"config",
"instance",
"."
] | f7433a6fcfbd0d788b017540d394de70f4bed320 | https://github.com/andreas-weber/php-config/blob/f7433a6fcfbd0d788b017540d394de70f4bed320/src/Core/Config.php#L47-L56 |
6,465 | andreas-weber/php-config | src/Core/Config.php | Config.merge | public function merge(Config $config)
{
$this->data = array_replace_recursive(
$this->data,
$config->toArray()
);
return $this;
} | php | public function merge(Config $config)
{
$this->data = array_replace_recursive(
$this->data,
$config->toArray()
);
return $this;
} | [
"public",
"function",
"merge",
"(",
"Config",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"config",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Merge another config instance in this config instance.
@param Config $config
@return $this | [
"Merge",
"another",
"config",
"instance",
"in",
"this",
"config",
"instance",
"."
] | f7433a6fcfbd0d788b017540d394de70f4bed320 | https://github.com/andreas-weber/php-config/blob/f7433a6fcfbd0d788b017540d394de70f4bed320/src/Core/Config.php#L65-L73 |
6,466 | webtoucher/yii2-migrate | components/Migration.php | Migration.addCommentOnTable | public function addCommentOnTable($table, $comment)
{
$table = $this->db->quoteTableName($table);
$comment = $this->db->quoteValue($comment);
$this->execute("COMMENT ON TABLE $table IS $comment;");
} | php | public function addCommentOnTable($table, $comment)
{
$table = $this->db->quoteTableName($table);
$comment = $this->db->quoteValue($comment);
$this->execute("COMMENT ON TABLE $table IS $comment;");
} | [
"public",
"function",
"addCommentOnTable",
"(",
"$",
"table",
",",
"$",
"comment",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"db",
"->",
"quoteTableName",
"(",
"$",
"table",
")",
";",
"$",
"comment",
"=",
"$",
"this",
"->",
"db",
"->",
"quoteValue",
"(",
"$",
"comment",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"\"COMMENT ON TABLE $table IS $comment;\"",
")",
";",
"}"
] | Adds comment for a table.
@param string $table
@param string $comment
@return void | [
"Adds",
"comment",
"for",
"a",
"table",
"."
] | bfd8323811d72f68eac64d0405d0f3c40e485c58 | https://github.com/webtoucher/yii2-migrate/blob/bfd8323811d72f68eac64d0405d0f3c40e485c58/components/Migration.php#L55-L61 |
6,467 | webtoucher/yii2-migrate | components/Migration.php | Migration.addCommentOnColumn | public function addCommentOnColumn($table, $column, $comment)
{
$table = $this->db->quoteTableName($table);
$column = $this->db->quoteColumnName($column);
$comment = $this->db->quoteValue($comment);
$this->execute("COMMENT ON COLUMN $table.$column IS $comment;");
} | php | public function addCommentOnColumn($table, $column, $comment)
{
$table = $this->db->quoteTableName($table);
$column = $this->db->quoteColumnName($column);
$comment = $this->db->quoteValue($comment);
$this->execute("COMMENT ON COLUMN $table.$column IS $comment;");
} | [
"public",
"function",
"addCommentOnColumn",
"(",
"$",
"table",
",",
"$",
"column",
",",
"$",
"comment",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"db",
"->",
"quoteTableName",
"(",
"$",
"table",
")",
";",
"$",
"column",
"=",
"$",
"this",
"->",
"db",
"->",
"quoteColumnName",
"(",
"$",
"column",
")",
";",
"$",
"comment",
"=",
"$",
"this",
"->",
"db",
"->",
"quoteValue",
"(",
"$",
"comment",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"\"COMMENT ON COLUMN $table.$column IS $comment;\"",
")",
";",
"}"
] | Adds comment for a table's column.
@param string $table
@param string $column
@param string $comment
@return void | [
"Adds",
"comment",
"for",
"a",
"table",
"s",
"column",
"."
] | bfd8323811d72f68eac64d0405d0f3c40e485c58 | https://github.com/webtoucher/yii2-migrate/blob/bfd8323811d72f68eac64d0405d0f3c40e485c58/components/Migration.php#L71-L78 |
6,468 | asbsoft/yii2module-news_1b_160430 | controllers/MainController.php | MainController.actionView | public function actionView($id, $renderPartial = false)
{
$modelNews = $this->module->model('News');
$model = $modelNews::findOne($id);
$modelI18n = false;
if (!empty($model)) {
$modelsI18n = $modelNews::prepareI18nModels($model);
$modelI18n = $modelsI18n[$this->langCodeMain];
}
$searchModel = $this->module->model('NewsSearchFront');
if ($renderPartial) {
$model = $searchModel::canShow($model, $modelI18n, $ignoreVisibility = true);
} else {
$model = $searchModel::canShow($model, $modelI18n);
}
if (!$model) {
$modelI18n = false;
}
if ($renderPartial) {
return $this->renderPartial('view', compact('model', 'modelI18n'));
} else {
return $this->render('view', compact('model', 'modelI18n'));
}
} | php | public function actionView($id, $renderPartial = false)
{
$modelNews = $this->module->model('News');
$model = $modelNews::findOne($id);
$modelI18n = false;
if (!empty($model)) {
$modelsI18n = $modelNews::prepareI18nModels($model);
$modelI18n = $modelsI18n[$this->langCodeMain];
}
$searchModel = $this->module->model('NewsSearchFront');
if ($renderPartial) {
$model = $searchModel::canShow($model, $modelI18n, $ignoreVisibility = true);
} else {
$model = $searchModel::canShow($model, $modelI18n);
}
if (!$model) {
$modelI18n = false;
}
if ($renderPartial) {
return $this->renderPartial('view', compact('model', 'modelI18n'));
} else {
return $this->render('view', compact('model', 'modelI18n'));
}
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
",",
"$",
"renderPartial",
"=",
"false",
")",
"{",
"$",
"modelNews",
"=",
"$",
"this",
"->",
"module",
"->",
"model",
"(",
"'News'",
")",
";",
"$",
"model",
"=",
"$",
"modelNews",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"$",
"modelI18n",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"model",
")",
")",
"{",
"$",
"modelsI18n",
"=",
"$",
"modelNews",
"::",
"prepareI18nModels",
"(",
"$",
"model",
")",
";",
"$",
"modelI18n",
"=",
"$",
"modelsI18n",
"[",
"$",
"this",
"->",
"langCodeMain",
"]",
";",
"}",
"$",
"searchModel",
"=",
"$",
"this",
"->",
"module",
"->",
"model",
"(",
"'NewsSearchFront'",
")",
";",
"if",
"(",
"$",
"renderPartial",
")",
"{",
"$",
"model",
"=",
"$",
"searchModel",
"::",
"canShow",
"(",
"$",
"model",
",",
"$",
"modelI18n",
",",
"$",
"ignoreVisibility",
"=",
"true",
")",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"searchModel",
"::",
"canShow",
"(",
"$",
"model",
",",
"$",
"modelI18n",
")",
";",
"}",
"if",
"(",
"!",
"$",
"model",
")",
"{",
"$",
"modelI18n",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"renderPartial",
")",
"{",
"return",
"$",
"this",
"->",
"renderPartial",
"(",
"'view'",
",",
"compact",
"(",
"'model'",
",",
"'modelI18n'",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'view'",
",",
"compact",
"(",
"'model'",
",",
"'modelI18n'",
")",
")",
";",
"}",
"}"
] | Render article's body.
@param integer $id
@param boolean $renderPartial if true ignore visibility and show without layout by call renderPartial() | [
"Render",
"article",
"s",
"body",
"."
] | ce64b1e70c5a57b572921945cc51384087905461 | https://github.com/asbsoft/yii2module-news_1b_160430/blob/ce64b1e70c5a57b572921945cc51384087905461/controllers/MainController.php#L83-L109 |
6,469 | leonardodarosa23/rose-core | core/Exception/ExceptionHandler.php | ExceptionHandler.logObject | private static function logObject( $obj )
{
$path = config('system.errors.save_dir');
if ($path != null) {
if (!is_dir($path)) {
@mkdir($path, 0755);
}
$name = strftime(config('system.errors.file_name'));
if($name != '' && @touch($path.DIRECTORY_SEPARATOR.$name)){
@error_log(PHP_EOL . $obj . PHP_EOL, 3, $path.DIRECTORY_SEPARATOR.$name);
} else {
@error_log(PHP_EOL . $obj . PHP_EOL, 0);
}
}
} | php | private static function logObject( $obj )
{
$path = config('system.errors.save_dir');
if ($path != null) {
if (!is_dir($path)) {
@mkdir($path, 0755);
}
$name = strftime(config('system.errors.file_name'));
if($name != '' && @touch($path.DIRECTORY_SEPARATOR.$name)){
@error_log(PHP_EOL . $obj . PHP_EOL, 3, $path.DIRECTORY_SEPARATOR.$name);
} else {
@error_log(PHP_EOL . $obj . PHP_EOL, 0);
}
}
} | [
"private",
"static",
"function",
"logObject",
"(",
"$",
"obj",
")",
"{",
"$",
"path",
"=",
"config",
"(",
"'system.errors.save_dir'",
")",
";",
"if",
"(",
"$",
"path",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"@",
"mkdir",
"(",
"$",
"path",
",",
"0755",
")",
";",
"}",
"$",
"name",
"=",
"strftime",
"(",
"config",
"(",
"'system.errors.file_name'",
")",
")",
";",
"if",
"(",
"$",
"name",
"!=",
"''",
"&&",
"@",
"touch",
"(",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
")",
")",
"{",
"@",
"error_log",
"(",
"PHP_EOL",
".",
"$",
"obj",
".",
"PHP_EOL",
",",
"3",
",",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
")",
";",
"}",
"else",
"{",
"@",
"error_log",
"(",
"PHP_EOL",
".",
"$",
"obj",
".",
"PHP_EOL",
",",
"0",
")",
";",
"}",
"}",
"}"
] | Efetua o log do erro nos registros
@param \Exception $obj | [
"Efetua",
"o",
"log",
"do",
"erro",
"nos",
"registros"
] | 998f483ca02347b84940aa4039870b83be5fc360 | https://github.com/leonardodarosa23/rose-core/blob/998f483ca02347b84940aa4039870b83be5fc360/core/Exception/ExceptionHandler.php#L101-L115 |
6,470 | calin-marian/google-supported-languages | src/LanguageFactory.php | LanguageFactory.create | public function create($languageCode) {
$mappings = $this->getMappings();
if (!isset($mappings[$languageCode])) {
throw new \InvalidArgumentException('The language code is not part of the supported list. Please see GoogleSupportedLanguages\LanguageFactory::getMappings() for reference.');
}
return new $mappings[$languageCode]();
} | php | public function create($languageCode) {
$mappings = $this->getMappings();
if (!isset($mappings[$languageCode])) {
throw new \InvalidArgumentException('The language code is not part of the supported list. Please see GoogleSupportedLanguages\LanguageFactory::getMappings() for reference.');
}
return new $mappings[$languageCode]();
} | [
"public",
"function",
"create",
"(",
"$",
"languageCode",
")",
"{",
"$",
"mappings",
"=",
"$",
"this",
"->",
"getMappings",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"mappings",
"[",
"$",
"languageCode",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The language code is not part of the supported list. Please see GoogleSupportedLanguages\\LanguageFactory::getMappings() for reference.'",
")",
";",
"}",
"return",
"new",
"$",
"mappings",
"[",
"$",
"languageCode",
"]",
"(",
")",
";",
"}"
] | Create a language object from the language code.
@param string $languageCode
@return LanguageInterface | [
"Create",
"a",
"language",
"object",
"from",
"the",
"language",
"code",
"."
] | d9460f8e741df52ab842d32e9b94651ad3cd6785 | https://github.com/calin-marian/google-supported-languages/blob/d9460f8e741df52ab842d32e9b94651ad3cd6785/src/LanguageFactory.php#L19-L27 |
6,471 | osflab/view | AbstractHelper.php | AbstractHelper.init | public function init(): void
{
if ($this->initialized) {
return;
}
if (!$this->view) {
$containerGetter = 'get' . ucfirst($this->viewName);
$this->setView(Container::$containerGetter());
}
if (method_exists($this, 'getAvailableHelpers')) {
$this->registerHelpers($this->getAvailableHelpers());
}
$this->initialized = true;
} | php | public function init(): void
{
if ($this->initialized) {
return;
}
if (!$this->view) {
$containerGetter = 'get' . ucfirst($this->viewName);
$this->setView(Container::$containerGetter());
}
if (method_exists($this, 'getAvailableHelpers')) {
$this->registerHelpers($this->getAvailableHelpers());
}
$this->initialized = true;
} | [
"public",
"function",
"init",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"view",
")",
"{",
"$",
"containerGetter",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"viewName",
")",
";",
"$",
"this",
"->",
"setView",
"(",
"Container",
"::",
"$",
"containerGetter",
"(",
")",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'getAvailableHelpers'",
")",
")",
"{",
"$",
"this",
"->",
"registerHelpers",
"(",
"$",
"this",
"->",
"getAvailableHelpers",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"initialized",
"=",
"true",
";",
"}"
] | Lazy loading process
@return void | [
"Lazy",
"loading",
"process"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/AbstractHelper.php#L183-L197 |
6,472 | osflab/view | AbstractHelper.php | AbstractHelper.get | public function get($key, $alternateContent = '')
{
$this->init();
return isset($this->view->getValues()[$key]) ? $this->view->getValues()[$key] : $alternateContent;
} | php | public function get($key, $alternateContent = '')
{
$this->init();
return isset($this->view->getValues()[$key]) ? $this->view->getValues()[$key] : $alternateContent;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"alternateContent",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"view",
"->",
"getValues",
"(",
")",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"view",
"->",
"getValues",
"(",
")",
"[",
"$",
"key",
"]",
":",
"$",
"alternateContent",
";",
"}"
] | Get a value from action controller
@param string $key
@param string $alternateContent displayd if $key not found
@return multitype: | [
"Get",
"a",
"value",
"from",
"action",
"controller"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/AbstractHelper.php#L225-L229 |
6,473 | simple-php-mvc/installer-module | src/InstallerModule/Command/AssetsInstallCommand.php | AssetsInstallCommand.recursiveRemoveDir | function recursiveRemoveDir($dir)
{
if (is_link($dir)) {
@unlink($dir);
} else if (is_dir($dir)) {
$files = array_diff(@scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->recursiveRemoveDir("$dir/$file") : @unlink("$dir/$file");
}
}
return @rmdir($dir);
} | php | function recursiveRemoveDir($dir)
{
if (is_link($dir)) {
@unlink($dir);
} else if (is_dir($dir)) {
$files = array_diff(@scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->recursiveRemoveDir("$dir/$file") : @unlink("$dir/$file");
}
}
return @rmdir($dir);
} | [
"function",
"recursiveRemoveDir",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"is_link",
"(",
"$",
"dir",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"dir",
")",
";",
"}",
"else",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"files",
"=",
"array_diff",
"(",
"@",
"scandir",
"(",
"$",
"dir",
")",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"(",
"is_dir",
"(",
"\"$dir/$file\"",
")",
")",
"?",
"$",
"this",
"->",
"recursiveRemoveDir",
"(",
"\"$dir/$file\"",
")",
":",
"@",
"unlink",
"(",
"\"$dir/$file\"",
")",
";",
"}",
"}",
"return",
"@",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}"
] | Recursive Remove Dir
@param string $dir
@return boolean | [
"Recursive",
"Remove",
"Dir"
] | 62bd5bac05418b5f712dfcead1edc75ef14d60e3 | https://github.com/simple-php-mvc/installer-module/blob/62bd5bac05418b5f712dfcead1edc75ef14d60e3/src/InstallerModule/Command/AssetsInstallCommand.php#L103-L114 |
6,474 | bestit/commercetools-async-pool | src/Pool.php | Pool.addPromise | public function addPromise(
ClientRequestInterface $request,
callable $startingSuccessCallback = null,
callable $startingFailCallback = null
): ApiResponseInterface {
$return = $this->promises[$request->getIdentifier()] = $this->createStartingPromise(
$request,
$startingSuccessCallback,
$startingFailCallback
);
return $return;
} | php | public function addPromise(
ClientRequestInterface $request,
callable $startingSuccessCallback = null,
callable $startingFailCallback = null
): ApiResponseInterface {
$return = $this->promises[$request->getIdentifier()] = $this->createStartingPromise(
$request,
$startingSuccessCallback,
$startingFailCallback
);
return $return;
} | [
"public",
"function",
"addPromise",
"(",
"ClientRequestInterface",
"$",
"request",
",",
"callable",
"$",
"startingSuccessCallback",
"=",
"null",
",",
"callable",
"$",
"startingFailCallback",
"=",
"null",
")",
":",
"ApiResponseInterface",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"promises",
"[",
"$",
"request",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"createStartingPromise",
"(",
"$",
"request",
",",
"$",
"startingSuccessCallback",
",",
"$",
"startingFailCallback",
")",
";",
"return",
"$",
"return",
";",
"}"
] | Adds a promise to this pool.
@param ClientRequestInterface $request
@param callable $startingSuccessCallback Overwrite the starting success callback.
@param callable $startingFailCallback Overwrite the failing success callback.
@return ApiResponseInterface | [
"Adds",
"a",
"promise",
"to",
"this",
"pool",
"."
] | 3b011cceb474c287351e4aa0893ab8ecddd1af21 | https://github.com/bestit/commercetools-async-pool/blob/3b011cceb474c287351e4aa0893ab8ecddd1af21/src/Pool.php#L59-L71 |
6,475 | bestit/commercetools-async-pool | src/Pool.php | Pool.createStartingPromise | private function createStartingPromise(
ClientRequestInterface $request,
callable $startingSuccessCallback = null,
callable $startingFailCallback = null
): ApiResponseInterface {
if (!$startingSuccessCallback) {
$startingSuccessCallback = function (ResponseInterface $response) use ($request) {
return $request->mapFromResponse($request->buildResponse($response));
};
}
if (!$startingFailCallback) {
$startingFailCallback = function (RequestException $exception) {
return ApiException::create($exception->getRequest(), $exception->getResponse(), $exception);
};
}
return $this->getClient()->executeAsync($request)->then($startingSuccessCallback, $startingFailCallback);
} | php | private function createStartingPromise(
ClientRequestInterface $request,
callable $startingSuccessCallback = null,
callable $startingFailCallback = null
): ApiResponseInterface {
if (!$startingSuccessCallback) {
$startingSuccessCallback = function (ResponseInterface $response) use ($request) {
return $request->mapFromResponse($request->buildResponse($response));
};
}
if (!$startingFailCallback) {
$startingFailCallback = function (RequestException $exception) {
return ApiException::create($exception->getRequest(), $exception->getResponse(), $exception);
};
}
return $this->getClient()->executeAsync($request)->then($startingSuccessCallback, $startingFailCallback);
} | [
"private",
"function",
"createStartingPromise",
"(",
"ClientRequestInterface",
"$",
"request",
",",
"callable",
"$",
"startingSuccessCallback",
"=",
"null",
",",
"callable",
"$",
"startingFailCallback",
"=",
"null",
")",
":",
"ApiResponseInterface",
"{",
"if",
"(",
"!",
"$",
"startingSuccessCallback",
")",
"{",
"$",
"startingSuccessCallback",
"=",
"function",
"(",
"ResponseInterface",
"$",
"response",
")",
"use",
"(",
"$",
"request",
")",
"{",
"return",
"$",
"request",
"->",
"mapFromResponse",
"(",
"$",
"request",
"->",
"buildResponse",
"(",
"$",
"response",
")",
")",
";",
"}",
";",
"}",
"if",
"(",
"!",
"$",
"startingFailCallback",
")",
"{",
"$",
"startingFailCallback",
"=",
"function",
"(",
"RequestException",
"$",
"exception",
")",
"{",
"return",
"ApiException",
"::",
"create",
"(",
"$",
"exception",
"->",
"getRequest",
"(",
")",
",",
"$",
"exception",
"->",
"getResponse",
"(",
")",
",",
"$",
"exception",
")",
";",
"}",
";",
"}",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"executeAsync",
"(",
"$",
"request",
")",
"->",
"then",
"(",
"$",
"startingSuccessCallback",
",",
"$",
"startingFailCallback",
")",
";",
"}"
] | Makes a ctp response out of the default async response and returns the promise for the next chaining level.
@param ClientRequestInterface $request
@param callable $startingSuccessCallback Overwrite the starting success callback.
@param callable $startingFailCallback Overwrite the failing success callback.
@return ApiResponseInterface | [
"Makes",
"a",
"ctp",
"response",
"out",
"of",
"the",
"default",
"async",
"response",
"and",
"returns",
"the",
"promise",
"for",
"the",
"next",
"chaining",
"level",
"."
] | 3b011cceb474c287351e4aa0893ab8ecddd1af21 | https://github.com/bestit/commercetools-async-pool/blob/3b011cceb474c287351e4aa0893ab8ecddd1af21/src/Pool.php#L80-L98 |
6,476 | bestit/commercetools-async-pool | src/Pool.php | Pool.flush | public function flush()
{
// Prevent an endless loop and work on a batch copy.
$promises = $this->getPromises();
$this->setPromises([]);
Promise\settle($promises)->wait();
} | php | public function flush()
{
// Prevent an endless loop and work on a batch copy.
$promises = $this->getPromises();
$this->setPromises([]);
Promise\settle($promises)->wait();
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"// Prevent an endless loop and work on a batch copy.",
"$",
"promises",
"=",
"$",
"this",
"->",
"getPromises",
"(",
")",
";",
"$",
"this",
"->",
"setPromises",
"(",
"[",
"]",
")",
";",
"Promise",
"\\",
"settle",
"(",
"$",
"promises",
")",
"->",
"wait",
"(",
")",
";",
"}"
] | Flushes the collected pull of promises.
@return void | [
"Flushes",
"the",
"collected",
"pull",
"of",
"promises",
"."
] | 3b011cceb474c287351e4aa0893ab8ecddd1af21 | https://github.com/bestit/commercetools-async-pool/blob/3b011cceb474c287351e4aa0893ab8ecddd1af21/src/Pool.php#L113-L119 |
6,477 | squire-assistant/dependency-injection | Dumper/GraphvizDumper.php | GraphvizDumper.findNodes | private function findNodes()
{
$nodes = array();
$container = $this->cloneContainer();
foreach ($container->getDefinitions() as $id => $definition) {
$class = $definition->getClass();
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
try {
$class = $this->container->getParameterBag()->resolveValue($class);
} catch (ParameterNotFoundException $e) {
}
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() ? 'filled' : 'dotted')));
$container->setDefinition($id, new Definition('stdClass'));
}
foreach ($container->getServiceIds() as $id) {
if (array_key_exists($id, $container->getAliases())) {
continue;
}
if (!$container->hasDefinition($id)) {
$class = get_class('service_container' === $id ? $this->container : $container->get($id));
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => $this->options['node.instance']);
}
}
return $nodes;
} | php | private function findNodes()
{
$nodes = array();
$container = $this->cloneContainer();
foreach ($container->getDefinitions() as $id => $definition) {
$class = $definition->getClass();
if ('\\' === substr($class, 0, 1)) {
$class = substr($class, 1);
}
try {
$class = $this->container->getParameterBag()->resolveValue($class);
} catch (ParameterNotFoundException $e) {
}
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() ? 'filled' : 'dotted')));
$container->setDefinition($id, new Definition('stdClass'));
}
foreach ($container->getServiceIds() as $id) {
if (array_key_exists($id, $container->getAliases())) {
continue;
}
if (!$container->hasDefinition($id)) {
$class = get_class('service_container' === $id ? $this->container : $container->get($id));
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => $this->options['node.instance']);
}
}
return $nodes;
} | [
"private",
"function",
"findNodes",
"(",
")",
"{",
"$",
"nodes",
"=",
"array",
"(",
")",
";",
"$",
"container",
"=",
"$",
"this",
"->",
"cloneContainer",
"(",
")",
";",
"foreach",
"(",
"$",
"container",
"->",
"getDefinitions",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"definition",
")",
"{",
"$",
"class",
"=",
"$",
"definition",
"->",
"getClass",
"(",
")",
";",
"if",
"(",
"'\\\\'",
"===",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"1",
")",
")",
"{",
"$",
"class",
"=",
"substr",
"(",
"$",
"class",
",",
"1",
")",
";",
"}",
"try",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameterBag",
"(",
")",
"->",
"resolveValue",
"(",
"$",
"class",
")",
";",
"}",
"catch",
"(",
"ParameterNotFoundException",
"$",
"e",
")",
"{",
"}",
"$",
"nodes",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"class",
")",
",",
"'attributes'",
"=>",
"array_merge",
"(",
"$",
"this",
"->",
"options",
"[",
"'node.definition'",
"]",
",",
"array",
"(",
"'style'",
"=>",
"$",
"definition",
"->",
"isShared",
"(",
")",
"?",
"'filled'",
":",
"'dotted'",
")",
")",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"id",
",",
"new",
"Definition",
"(",
"'stdClass'",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"container",
"->",
"getServiceIds",
"(",
")",
"as",
"$",
"id",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"container",
"->",
"getAliases",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"id",
")",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"'service_container'",
"===",
"$",
"id",
"?",
"$",
"this",
"->",
"container",
":",
"$",
"container",
"->",
"get",
"(",
"$",
"id",
")",
")",
";",
"$",
"nodes",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"class",
")",
",",
"'attributes'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'node.instance'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"nodes",
";",
"}"
] | Finds all nodes.
@return array An array of all nodes | [
"Finds",
"all",
"nodes",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Dumper/GraphvizDumper.php#L160-L194 |
6,478 | AnonymPHP/Anonym-Library | src/Anonym/Http/Redirect.php | Redirect.to | public function to($url = '', $time = 0, array $headers = [])
{
$this->redirector->setTarget($url)->setTime($time)->setHeaders($headers);
return $this;
} | php | public function to($url = '', $time = 0, array $headers = [])
{
$this->redirector->setTarget($url)->setTime($time)->setHeaders($headers);
return $this;
} | [
"public",
"function",
"to",
"(",
"$",
"url",
"=",
"''",
",",
"$",
"time",
"=",
"0",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"redirector",
"->",
"setTarget",
"(",
"$",
"url",
")",
"->",
"setTime",
"(",
"$",
"time",
")",
"->",
"setHeaders",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | redirect user to somewhere else
@param string $url
@param int $time
@param array $headers
@return $this | [
"redirect",
"user",
"to",
"somewhere",
"else"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Http/Redirect.php#L76-L81 |
6,479 | AnonymPHP/Anonym-Library | src/Anonym/Http/Redirect.php | Redirect.withError | public function withError($message)
{
if (is_array($message)) {
$this->errorBag->setErrors($message);
} else {
$this->errorBag->add($message);
}
return $this;
} | php | public function withError($message)
{
if (is_array($message)) {
$this->errorBag->setErrors($message);
} else {
$this->errorBag->add($message);
}
return $this;
} | [
"public",
"function",
"withError",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"$",
"this",
"->",
"errorBag",
"->",
"setErrors",
"(",
"$",
"message",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errorBag",
"->",
"add",
"(",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | add or set error messages
@param array|string $message
@return $this | [
"add",
"or",
"set",
"error",
"messages"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Http/Redirect.php#L89-L98 |
6,480 | AnonymPHP/Anonym-Library | src/Anonym/Http/Redirect.php | Redirect.withInput | public function withInput($name, $message = null)
{
if (!is_array($name)) {
$name = [$name, $message];
}
foreach ($name as $key => $message) {
Session::set($key, $message);
}
return $this;
} | php | public function withInput($name, $message = null)
{
if (!is_array($name)) {
$name = [$name, $message];
}
foreach ($name as $key => $message) {
Session::set($key, $message);
}
return $this;
} | [
"public",
"function",
"withInput",
"(",
"$",
"name",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"[",
"$",
"name",
",",
"$",
"message",
"]",
";",
"}",
"foreach",
"(",
"$",
"name",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"Session",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | redirect with input
@param array|string $name
@param mixed $message
@return $this | [
"redirect",
"with",
"input"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Http/Redirect.php#L108-L119 |
6,481 | AnonymPHP/Anonym-Library | src/Anonym/Http/Redirect.php | Redirect.withCookie | public function withCookie($name, $message = null, $time = 3600)
{
if (!is_array($name)) {
$name = [$name, $message];
}
foreach ($name as $key => $message) {
$this->redirector->getCookieBase()->set($key, $message, $time);
}
return $this;
} | php | public function withCookie($name, $message = null, $time = 3600)
{
if (!is_array($name)) {
$name = [$name, $message];
}
foreach ($name as $key => $message) {
$this->redirector->getCookieBase()->set($key, $message, $time);
}
return $this;
} | [
"public",
"function",
"withCookie",
"(",
"$",
"name",
",",
"$",
"message",
"=",
"null",
",",
"$",
"time",
"=",
"3600",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"[",
"$",
"name",
",",
"$",
"message",
"]",
";",
"}",
"foreach",
"(",
"$",
"name",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"redirector",
"->",
"getCookieBase",
"(",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"message",
",",
"$",
"time",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | redirect with single or multipile cookies
@param array|string $name
@param mixed $message
@param int $time
@return $this | [
"redirect",
"with",
"single",
"or",
"multipile",
"cookies"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Http/Redirect.php#L139-L150 |
6,482 | AnonymPHP/Anonym-Library | src/Anonym/Http/Redirect.php | Redirect.back | public function back($time = 0)
{
$this->redirector->setTarget(Request::back());
$this->redirector->setTime($time);
return $this;
} | php | public function back($time = 0)
{
$this->redirector->setTarget(Request::back());
$this->redirector->setTime($time);
return $this;
} | [
"public",
"function",
"back",
"(",
"$",
"time",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"redirector",
"->",
"setTarget",
"(",
"Request",
"::",
"back",
"(",
")",
")",
";",
"$",
"this",
"->",
"redirector",
"->",
"setTime",
"(",
"$",
"time",
")",
";",
"return",
"$",
"this",
";",
"}"
] | redirect user to it referer url
@param int $time
@return $this | [
"redirect",
"user",
"to",
"it",
"referer",
"url"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Http/Redirect.php#L158-L164 |
6,483 | infusephp/rest-api | src/ModelController.php | ModelController.getCreateRoute | protected function getCreateRoute(Request $req, Response $res)
{
$route = new CreateModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | php | protected function getCreateRoute(Request $req, Response $res)
{
$route = new CreateModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | [
"protected",
"function",
"getCreateRoute",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"route",
"=",
"new",
"CreateModelRoute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"$",
"route",
"->",
"setApp",
"(",
"$",
"this",
"->",
"app",
")",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"getSerializer",
"(",
"$",
"req",
")",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Builds a create route object.
@param Request $req
@param Response $res
@return CreateModelRoute | [
"Builds",
"a",
"create",
"route",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L54-L61 |
6,484 | infusephp/rest-api | src/ModelController.php | ModelController.getListRoute | protected function getListRoute(Request $req, Response $res)
{
$route = new ListModelsRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | php | protected function getListRoute(Request $req, Response $res)
{
$route = new ListModelsRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | [
"protected",
"function",
"getListRoute",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"route",
"=",
"new",
"ListModelsRoute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"$",
"route",
"->",
"setApp",
"(",
"$",
"this",
"->",
"app",
")",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"getSerializer",
"(",
"$",
"req",
")",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Builds a list route object.
@param Request $req
@param Response $res
@return ListModelsRoute | [
"Builds",
"a",
"list",
"route",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L71-L78 |
6,485 | infusephp/rest-api | src/ModelController.php | ModelController.getRetrieveRoute | protected function getRetrieveRoute(Request $req, Response $res)
{
$route = new RetrieveModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | php | protected function getRetrieveRoute(Request $req, Response $res)
{
$route = new RetrieveModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | [
"protected",
"function",
"getRetrieveRoute",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"route",
"=",
"new",
"RetrieveModelRoute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"$",
"route",
"->",
"setApp",
"(",
"$",
"this",
"->",
"app",
")",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"getSerializer",
"(",
"$",
"req",
")",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Builds a retrieve route object.
@param Request $req
@param Response $res
@return RetrieveModelRoute | [
"Builds",
"a",
"retrieve",
"route",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L88-L95 |
6,486 | infusephp/rest-api | src/ModelController.php | ModelController.getEditRoute | protected function getEditRoute(Request $req, Response $res)
{
$route = new EditModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | php | protected function getEditRoute(Request $req, Response $res)
{
$route = new EditModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | [
"protected",
"function",
"getEditRoute",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"route",
"=",
"new",
"EditModelRoute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"$",
"route",
"->",
"setApp",
"(",
"$",
"this",
"->",
"app",
")",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"getSerializer",
"(",
"$",
"req",
")",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Builds an edit route object.
@param Request $req
@param Response $res
@return EditModelRoute | [
"Builds",
"an",
"edit",
"route",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L105-L112 |
6,487 | infusephp/rest-api | src/ModelController.php | ModelController.getDeleteRoute | protected function getDeleteRoute(Request $req, Response $res)
{
$route = new DeleteModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | php | protected function getDeleteRoute(Request $req, Response $res)
{
$route = new DeleteModelRoute($req, $res);
$route->setApp($this->app)
->setSerializer($this->getSerializer($req));
return $route;
} | [
"protected",
"function",
"getDeleteRoute",
"(",
"Request",
"$",
"req",
",",
"Response",
"$",
"res",
")",
"{",
"$",
"route",
"=",
"new",
"DeleteModelRoute",
"(",
"$",
"req",
",",
"$",
"res",
")",
";",
"$",
"route",
"->",
"setApp",
"(",
"$",
"this",
"->",
"app",
")",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"getSerializer",
"(",
"$",
"req",
")",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Builds a delete route object.
@param Request $req
@param Response $res
@return DeleteModelRoute | [
"Builds",
"a",
"delete",
"route",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L122-L129 |
6,488 | infusephp/rest-api | src/ModelController.php | ModelController.getSerializer | public function getSerializer(Request $req)
{
$modelSerializer = new ModelSerializer($req);
$jsonSerializer = new JsonSerializer($req);
$serializer = new ChainedSerializer();
$serializer->add($modelSerializer)
->add($jsonSerializer);
return $serializer;
} | php | public function getSerializer(Request $req)
{
$modelSerializer = new ModelSerializer($req);
$jsonSerializer = new JsonSerializer($req);
$serializer = new ChainedSerializer();
$serializer->add($modelSerializer)
->add($jsonSerializer);
return $serializer;
} | [
"public",
"function",
"getSerializer",
"(",
"Request",
"$",
"req",
")",
"{",
"$",
"modelSerializer",
"=",
"new",
"ModelSerializer",
"(",
"$",
"req",
")",
";",
"$",
"jsonSerializer",
"=",
"new",
"JsonSerializer",
"(",
"$",
"req",
")",
";",
"$",
"serializer",
"=",
"new",
"ChainedSerializer",
"(",
")",
";",
"$",
"serializer",
"->",
"add",
"(",
"$",
"modelSerializer",
")",
"->",
"add",
"(",
"$",
"jsonSerializer",
")",
";",
"return",
"$",
"serializer",
";",
"}"
] | Builds a serializer object.
@param Request $req
@return ChainedSerializer | [
"Builds",
"a",
"serializer",
"object",
"."
] | 3a02152048ea38ec5f0adaed3f10a17730086ec7 | https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/ModelController.php#L138-L148 |
6,489 | ndj888/com_jjcbs_tool | src/com_jjcbs/fun/AnnotationFun.php | AnnotationFun.createClosure | public static function createClosure(string $methodStr , string $methodName , string $data = '') : string {
if ( empty($data)){
// no function body
return '$fun = ' . preg_replace('/public|static|protected|private|public static|protected static|private static/'
, '' , str_replace($methodName , '' , $methodStr )
. "\n\n//exec\n"
. '$fun' . self::getMethodParamStr($methodStr));
}else{
return '$fun = ' . preg_replace('/public|static|protected|private|public static|protected static|private static/'
, '' , str_replace($methodName , '' , $methodStr )
. "\n\n//exec\n"
. sprintf($data , '$fun' . self::getMethodParamStr($methodStr) ));
}
} | php | public static function createClosure(string $methodStr , string $methodName , string $data = '') : string {
if ( empty($data)){
// no function body
return '$fun = ' . preg_replace('/public|static|protected|private|public static|protected static|private static/'
, '' , str_replace($methodName , '' , $methodStr )
. "\n\n//exec\n"
. '$fun' . self::getMethodParamStr($methodStr));
}else{
return '$fun = ' . preg_replace('/public|static|protected|private|public static|protected static|private static/'
, '' , str_replace($methodName , '' , $methodStr )
. "\n\n//exec\n"
. sprintf($data , '$fun' . self::getMethodParamStr($methodStr) ));
}
} | [
"public",
"static",
"function",
"createClosure",
"(",
"string",
"$",
"methodStr",
",",
"string",
"$",
"methodName",
",",
"string",
"$",
"data",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"// no function body",
"return",
"'$fun = '",
".",
"preg_replace",
"(",
"'/public|static|protected|private|public static|protected static|private static/'",
",",
"''",
",",
"str_replace",
"(",
"$",
"methodName",
",",
"''",
",",
"$",
"methodStr",
")",
".",
"\"\\n\\n//exec\\n\"",
".",
"'$fun'",
".",
"self",
"::",
"getMethodParamStr",
"(",
"$",
"methodStr",
")",
")",
";",
"}",
"else",
"{",
"return",
"'$fun = '",
".",
"preg_replace",
"(",
"'/public|static|protected|private|public static|protected static|private static/'",
",",
"''",
",",
"str_replace",
"(",
"$",
"methodName",
",",
"''",
",",
"$",
"methodStr",
")",
".",
"\"\\n\\n//exec\\n\"",
".",
"sprintf",
"(",
"$",
"data",
",",
"'$fun'",
".",
"self",
"::",
"getMethodParamStr",
"(",
"$",
"methodStr",
")",
")",
")",
";",
"}",
"}"
] | create a closure by old method str
@param string $methodStr
@param string $methodName
@param string $data
@return string | [
"create",
"a",
"closure",
"by",
"old",
"method",
"str"
] | 6c86980182d93ce66df45768fa7864b5df32e63d | https://github.com/ndj888/com_jjcbs_tool/blob/6c86980182d93ce66df45768fa7864b5df32e63d/src/com_jjcbs/fun/AnnotationFun.php#L26-L39 |
6,490 | ndj888/com_jjcbs_tool | src/com_jjcbs/fun/AnnotationFun.php | AnnotationFun.replaceClassInfoStr | public static function replaceClassInfoStr(string $className , string $data , string $input){
return preg_replace(sprintf('/class\s*%s/' , $className) , $data , $input);
} | php | public static function replaceClassInfoStr(string $className , string $data , string $input){
return preg_replace(sprintf('/class\s*%s/' , $className) , $data , $input);
} | [
"public",
"static",
"function",
"replaceClassInfoStr",
"(",
"string",
"$",
"className",
",",
"string",
"$",
"data",
",",
"string",
"$",
"input",
")",
"{",
"return",
"preg_replace",
"(",
"sprintf",
"(",
"'/class\\s*%s/'",
",",
"$",
"className",
")",
",",
"$",
"data",
",",
"$",
"input",
")",
";",
"}"
] | replace class info
@param string $className
@param string $data
@param string $input
@return mixed | [
"replace",
"class",
"info"
] | 6c86980182d93ce66df45768fa7864b5df32e63d | https://github.com/ndj888/com_jjcbs_tool/blob/6c86980182d93ce66df45768fa7864b5df32e63d/src/com_jjcbs/fun/AnnotationFun.php#L61-L63 |
6,491 | railsphp/framework | src/Rails/ActiveRecord/Associations/CollectionProxy.php | CollectionProxy.add | public function add($records/*...$records*/)
{
if (!$this->owner->isPersisted()) {
throw new Exception\RuntimeException(
# TODO: terminar mensaje:
# ...adding children to its $type association
"Owner record must be persisted before adding children"
);
}
$this->load();
if (!is_array($records)) {
$records = func_get_args();
}
if (!$records) {
return true;
}
$className = get_class(reset($records));
return $className::transaction(function() use ($records, $className) {
$idsForUpdate = [];
foreach ($records as $record) {
if ($record->hasChanged()) {
if (!$record->updateAttribute($this->foreignKey, $this->owner->id())) {
# If a record won't save, cancel the whole process.
return false;
}
} else {
$idsForUpdate[] = $record->id();
}
}
if ($idsForUpdate) {
$className::connection()
->table($className::tableName())
->where([$className::primaryKey() => $idsForUpdate])
->update([$this->foreignKey => $this->owner->id()]);
}
$this->records->merge($records);
});
} | php | public function add($records/*...$records*/)
{
if (!$this->owner->isPersisted()) {
throw new Exception\RuntimeException(
# TODO: terminar mensaje:
# ...adding children to its $type association
"Owner record must be persisted before adding children"
);
}
$this->load();
if (!is_array($records)) {
$records = func_get_args();
}
if (!$records) {
return true;
}
$className = get_class(reset($records));
return $className::transaction(function() use ($records, $className) {
$idsForUpdate = [];
foreach ($records as $record) {
if ($record->hasChanged()) {
if (!$record->updateAttribute($this->foreignKey, $this->owner->id())) {
# If a record won't save, cancel the whole process.
return false;
}
} else {
$idsForUpdate[] = $record->id();
}
}
if ($idsForUpdate) {
$className::connection()
->table($className::tableName())
->where([$className::primaryKey() => $idsForUpdate])
->update([$this->foreignKey => $this->owner->id()]);
}
$this->records->merge($records);
});
} | [
"public",
"function",
"add",
"(",
"$",
"records",
"/*...$records*/",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"owner",
"->",
"isPersisted",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"# TODO: terminar mensaje:",
"# ...adding children to its $type association",
"\"Owner record must be persisted before adding children\"",
")",
";",
"}",
"$",
"this",
"->",
"load",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"records",
")",
")",
"{",
"$",
"records",
"=",
"func_get_args",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"records",
")",
"{",
"return",
"true",
";",
"}",
"$",
"className",
"=",
"get_class",
"(",
"reset",
"(",
"$",
"records",
")",
")",
";",
"return",
"$",
"className",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"records",
",",
"$",
"className",
")",
"{",
"$",
"idsForUpdate",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"record",
"->",
"hasChanged",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"record",
"->",
"updateAttribute",
"(",
"$",
"this",
"->",
"foreignKey",
",",
"$",
"this",
"->",
"owner",
"->",
"id",
"(",
")",
")",
")",
"{",
"# If a record won't save, cancel the whole process.",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"idsForUpdate",
"[",
"]",
"=",
"$",
"record",
"->",
"id",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"idsForUpdate",
")",
"{",
"$",
"className",
"::",
"connection",
"(",
")",
"->",
"table",
"(",
"$",
"className",
"::",
"tableName",
"(",
")",
")",
"->",
"where",
"(",
"[",
"$",
"className",
"::",
"primaryKey",
"(",
")",
"=>",
"$",
"idsForUpdate",
"]",
")",
"->",
"update",
"(",
"[",
"$",
"this",
"->",
"foreignKey",
"=>",
"$",
"this",
"->",
"owner",
"->",
"id",
"(",
")",
"]",
")",
";",
"}",
"$",
"this",
"->",
"records",
"->",
"merge",
"(",
"$",
"records",
")",
";",
"}",
")",
";",
"}"
] | Add records to the association. The owner record must be
persisted before adding records.
Pass an array or records or many records. | [
"Add",
"records",
"to",
"the",
"association",
".",
"The",
"owner",
"record",
"must",
"be",
"persisted",
"before",
"adding",
"records",
".",
"Pass",
"an",
"array",
"or",
"records",
"or",
"many",
"records",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Associations/CollectionProxy.php#L27-L73 |
6,492 | nano7/Database | src/Deploys/Deployer.php | Deployer.run | public function run($paths = [], array $options = [])
{
$this->notes = [];
$files = $this->getDeployFiles($paths);
$this->requireFiles($files);
$this->runDeployies($files, $options);
$this->runClearDatabaseCollections();
return $files;
} | php | public function run($paths = [], array $options = [])
{
$this->notes = [];
$files = $this->getDeployFiles($paths);
$this->requireFiles($files);
$this->runDeployies($files, $options);
$this->runClearDatabaseCollections();
return $files;
} | [
"public",
"function",
"run",
"(",
"$",
"paths",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"notes",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"getDeployFiles",
"(",
"$",
"paths",
")",
";",
"$",
"this",
"->",
"requireFiles",
"(",
"$",
"files",
")",
";",
"$",
"this",
"->",
"runDeployies",
"(",
"$",
"files",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"runClearDatabaseCollections",
"(",
")",
";",
"return",
"$",
"files",
";",
"}"
] | Run the pending deployies at a given path.
@param array|string $paths
@param array $options
@return array | [
"Run",
"the",
"pending",
"deployies",
"at",
"a",
"given",
"path",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L54-L67 |
6,493 | nano7/Database | src/Deploys/Deployer.php | Deployer.runDeployies | protected function runDeployies(array $deployies, array $options = [])
{
if (count($deployies) == 0) {
$this->note('<info>Nothing to deploy.</info>');
return;
}
foreach ($deployies as $file) {
$this->runDeploy($file);
}
} | php | protected function runDeployies(array $deployies, array $options = [])
{
if (count($deployies) == 0) {
$this->note('<info>Nothing to deploy.</info>');
return;
}
foreach ($deployies as $file) {
$this->runDeploy($file);
}
} | [
"protected",
"function",
"runDeployies",
"(",
"array",
"$",
"deployies",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"deployies",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"note",
"(",
"'<info>Nothing to deploy.</info>'",
")",
";",
"return",
";",
"}",
"foreach",
"(",
"$",
"deployies",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"runDeploy",
"(",
"$",
"file",
")",
";",
"}",
"}"
] | Run an array of deployies.
@param array $deployies
@param array $options
@return void | [
"Run",
"an",
"array",
"of",
"deployies",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L76-L87 |
6,494 | nano7/Database | src/Deploys/Deployer.php | Deployer.runDeploy | protected function runDeploy($file)
{
$deploy = $this->resolve($name = $this->getDeployName($file));
$this->note("<comment>Deploying:</comment> {$name}");
// Run deploy
$deploy->run();
$this->note("<info>Deployed:</info> {$name}");
} | php | protected function runDeploy($file)
{
$deploy = $this->resolve($name = $this->getDeployName($file));
$this->note("<comment>Deploying:</comment> {$name}");
// Run deploy
$deploy->run();
$this->note("<info>Deployed:</info> {$name}");
} | [
"protected",
"function",
"runDeploy",
"(",
"$",
"file",
")",
"{",
"$",
"deploy",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"getDeployName",
"(",
"$",
"file",
")",
")",
";",
"$",
"this",
"->",
"note",
"(",
"\"<comment>Deploying:</comment> {$name}\"",
")",
";",
"// Run deploy",
"$",
"deploy",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"note",
"(",
"\"<info>Deployed:</info> {$name}\"",
")",
";",
"}"
] | Run "run" a deploy instance.
@param string $file
@return void | [
"Run",
"run",
"a",
"deploy",
"instance",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L95-L105 |
6,495 | nano7/Database | src/Deploys/Deployer.php | Deployer.runClearDatabaseCollections | protected function runClearDatabaseCollections()
{
$collections = db()->getCollections();
$activated = array_keys($this->collections);
// Carregar lista de colecoes que sobraram no banco
$diff = Arr::where($collections, function($item) use ($activated) {
return ! in_array($item, $activated);
});
// Excluir colecoes que sobraram
foreach ($diff as $diffColl) {
$this->note("<comment>Collection droping:</comment> {$diffColl}");
db()->dropCollection($diffColl);
$this->note("<comment>Collection droped:</comment> {$diffColl}");
}
// Carregar lista de indices
$this->runClearDatabaseIndexs();
} | php | protected function runClearDatabaseCollections()
{
$collections = db()->getCollections();
$activated = array_keys($this->collections);
// Carregar lista de colecoes que sobraram no banco
$diff = Arr::where($collections, function($item) use ($activated) {
return ! in_array($item, $activated);
});
// Excluir colecoes que sobraram
foreach ($diff as $diffColl) {
$this->note("<comment>Collection droping:</comment> {$diffColl}");
db()->dropCollection($diffColl);
$this->note("<comment>Collection droped:</comment> {$diffColl}");
}
// Carregar lista de indices
$this->runClearDatabaseIndexs();
} | [
"protected",
"function",
"runClearDatabaseCollections",
"(",
")",
"{",
"$",
"collections",
"=",
"db",
"(",
")",
"->",
"getCollections",
"(",
")",
";",
"$",
"activated",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"collections",
")",
";",
"// Carregar lista de colecoes que sobraram no banco",
"$",
"diff",
"=",
"Arr",
"::",
"where",
"(",
"$",
"collections",
",",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"activated",
")",
"{",
"return",
"!",
"in_array",
"(",
"$",
"item",
",",
"$",
"activated",
")",
";",
"}",
")",
";",
"// Excluir colecoes que sobraram",
"foreach",
"(",
"$",
"diff",
"as",
"$",
"diffColl",
")",
"{",
"$",
"this",
"->",
"note",
"(",
"\"<comment>Collection droping:</comment> {$diffColl}\"",
")",
";",
"db",
"(",
")",
"->",
"dropCollection",
"(",
"$",
"diffColl",
")",
";",
"$",
"this",
"->",
"note",
"(",
"\"<comment>Collection droped:</comment> {$diffColl}\"",
")",
";",
"}",
"// Carregar lista de indices",
"$",
"this",
"->",
"runClearDatabaseIndexs",
"(",
")",
";",
"}"
] | Run clear database collections. | [
"Run",
"clear",
"database",
"collections",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L110-L129 |
6,496 | nano7/Database | src/Deploys/Deployer.php | Deployer.runClearDatabaseIndexs | protected function runClearDatabaseIndexs()
{
foreach ($this->collections as $coll => $activated) {
$indexs = db()->getIndexs($coll);
// Carregar lista de colecoes que sobraram no banco
$diff = Arr::where($indexs, function($item) use ($activated) {
return ((! in_array($item, $activated)) && ($item != '_id_'));
});
// Excluir indices que sobraram
foreach ($diff as $diffIndex) {
$this->note("<comment>Index droping:</comment> {$coll}.{$diffIndex}");
db()->dropIndex($coll, $diffIndex);
$this->note("<comment>Index droped:</comment> {$coll}.{$diffIndex}");
}
}
} | php | protected function runClearDatabaseIndexs()
{
foreach ($this->collections as $coll => $activated) {
$indexs = db()->getIndexs($coll);
// Carregar lista de colecoes que sobraram no banco
$diff = Arr::where($indexs, function($item) use ($activated) {
return ((! in_array($item, $activated)) && ($item != '_id_'));
});
// Excluir indices que sobraram
foreach ($diff as $diffIndex) {
$this->note("<comment>Index droping:</comment> {$coll}.{$diffIndex}");
db()->dropIndex($coll, $diffIndex);
$this->note("<comment>Index droped:</comment> {$coll}.{$diffIndex}");
}
}
} | [
"protected",
"function",
"runClearDatabaseIndexs",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collections",
"as",
"$",
"coll",
"=>",
"$",
"activated",
")",
"{",
"$",
"indexs",
"=",
"db",
"(",
")",
"->",
"getIndexs",
"(",
"$",
"coll",
")",
";",
"// Carregar lista de colecoes que sobraram no banco",
"$",
"diff",
"=",
"Arr",
"::",
"where",
"(",
"$",
"indexs",
",",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"activated",
")",
"{",
"return",
"(",
"(",
"!",
"in_array",
"(",
"$",
"item",
",",
"$",
"activated",
")",
")",
"&&",
"(",
"$",
"item",
"!=",
"'_id_'",
")",
")",
";",
"}",
")",
";",
"// Excluir indices que sobraram",
"foreach",
"(",
"$",
"diff",
"as",
"$",
"diffIndex",
")",
"{",
"$",
"this",
"->",
"note",
"(",
"\"<comment>Index droping:</comment> {$coll}.{$diffIndex}\"",
")",
";",
"db",
"(",
")",
"->",
"dropIndex",
"(",
"$",
"coll",
",",
"$",
"diffIndex",
")",
";",
"$",
"this",
"->",
"note",
"(",
"\"<comment>Index droped:</comment> {$coll}.{$diffIndex}\"",
")",
";",
"}",
"}",
"}"
] | Run clear database indexs. | [
"Run",
"clear",
"database",
"indexs",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L134-L151 |
6,497 | nano7/Database | src/Deploys/Deployer.php | Deployer.getDeployFiles | public function getDeployFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
return $this->files->glob($path.'/*.php');
})->filter()->sortBy(function ($file) {
return $this->getDeployName($file);
})->values()->keyBy(function ($file) {
return $this->getDeployName($file);
})->all();
} | php | public function getDeployFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
return $this->files->glob($path.'/*.php');
})->filter()->sortBy(function ($file) {
return $this->getDeployName($file);
})->values()->keyBy(function ($file) {
return $this->getDeployName($file);
})->all();
} | [
"public",
"function",
"getDeployFiles",
"(",
"$",
"paths",
")",
"{",
"return",
"Collection",
"::",
"make",
"(",
"$",
"paths",
")",
"->",
"flatMap",
"(",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"files",
"->",
"glob",
"(",
"$",
"path",
".",
"'/*.php'",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
"->",
"sortBy",
"(",
"function",
"(",
"$",
"file",
")",
"{",
"return",
"$",
"this",
"->",
"getDeployName",
"(",
"$",
"file",
")",
";",
"}",
")",
"->",
"values",
"(",
")",
"->",
"keyBy",
"(",
"function",
"(",
"$",
"file",
")",
"{",
"return",
"$",
"this",
"->",
"getDeployName",
"(",
"$",
"file",
")",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Get all of the deploy files in a given path.
@param string|array $paths
@return array | [
"Get",
"all",
"of",
"the",
"deploy",
"files",
"in",
"a",
"given",
"path",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L172-L181 |
6,498 | nano7/Database | src/Deploys/Deployer.php | Deployer.collection | public function collection($name)
{
// Verificar se deve adicionar a colecao na lista
if (! array_key_exists($name, $this->collections)) {
$this->collections[$name] = [];
}
// Verificar se jah foi criado
if (db()->hasCollection($name)) {
return true;
}
// Criar colecao
db()->createCollection($name);
return true;
} | php | public function collection($name)
{
// Verificar se deve adicionar a colecao na lista
if (! array_key_exists($name, $this->collections)) {
$this->collections[$name] = [];
}
// Verificar se jah foi criado
if (db()->hasCollection($name)) {
return true;
}
// Criar colecao
db()->createCollection($name);
return true;
} | [
"public",
"function",
"collection",
"(",
"$",
"name",
")",
"{",
"// Verificar se deve adicionar a colecao na lista",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"collections",
")",
")",
"{",
"$",
"this",
"->",
"collections",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"// Verificar se jah foi criado",
"if",
"(",
"db",
"(",
")",
"->",
"hasCollection",
"(",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Criar colecao",
"db",
"(",
")",
"->",
"createCollection",
"(",
"$",
"name",
")",
";",
"return",
"true",
";",
"}"
] | Create collection.
@param $name
@return bool | [
"Create",
"collection",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L264-L280 |
6,499 | nano7/Database | src/Deploys/Deployer.php | Deployer.index | public function index($collection, $columns, $unique)
{
// Montar nome do index
$name = strtolower(sprintf('ax_%s_%s', implode('_', array_keys($columns)), $unique ? 'unique' : "normal"));
// Verificar se deve adicionar a colecao na lista
if (! array_key_exists($collection, $this->collections)) {
$this->collections[$collection] = [];
}
// Verificar se deve adicionar a index na lista
if (! in_array($name, $this->collections[$collection])) {
$this->collections[$collection][] = $name;
}
// Verificar se ja foi criado o index
if (db()->hasIndex($collection, $name)) {
return true;
}
// Criar indice
db()->createIndex($collection, $columns, ['name' => $name, 'unique' => $unique]);
return true;
} | php | public function index($collection, $columns, $unique)
{
// Montar nome do index
$name = strtolower(sprintf('ax_%s_%s', implode('_', array_keys($columns)), $unique ? 'unique' : "normal"));
// Verificar se deve adicionar a colecao na lista
if (! array_key_exists($collection, $this->collections)) {
$this->collections[$collection] = [];
}
// Verificar se deve adicionar a index na lista
if (! in_array($name, $this->collections[$collection])) {
$this->collections[$collection][] = $name;
}
// Verificar se ja foi criado o index
if (db()->hasIndex($collection, $name)) {
return true;
}
// Criar indice
db()->createIndex($collection, $columns, ['name' => $name, 'unique' => $unique]);
return true;
} | [
"public",
"function",
"index",
"(",
"$",
"collection",
",",
"$",
"columns",
",",
"$",
"unique",
")",
"{",
"// Montar nome do index",
"$",
"name",
"=",
"strtolower",
"(",
"sprintf",
"(",
"'ax_%s_%s'",
",",
"implode",
"(",
"'_'",
",",
"array_keys",
"(",
"$",
"columns",
")",
")",
",",
"$",
"unique",
"?",
"'unique'",
":",
"\"normal\"",
")",
")",
";",
"// Verificar se deve adicionar a colecao na lista",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"collection",
",",
"$",
"this",
"->",
"collections",
")",
")",
"{",
"$",
"this",
"->",
"collections",
"[",
"$",
"collection",
"]",
"=",
"[",
"]",
";",
"}",
"// Verificar se deve adicionar a index na lista",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"collections",
"[",
"$",
"collection",
"]",
")",
")",
"{",
"$",
"this",
"->",
"collections",
"[",
"$",
"collection",
"]",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"// Verificar se ja foi criado o index",
"if",
"(",
"db",
"(",
")",
"->",
"hasIndex",
"(",
"$",
"collection",
",",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Criar indice",
"db",
"(",
")",
"->",
"createIndex",
"(",
"$",
"collection",
",",
"$",
"columns",
",",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'unique'",
"=>",
"$",
"unique",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Create index.
@param $name
@return bool | [
"Create",
"index",
"."
] | 7d8c10af415c469a317f40471f657104e4d5b52a | https://github.com/nano7/Database/blob/7d8c10af415c469a317f40471f657104e4d5b52a/src/Deploys/Deployer.php#L287-L311 |
Subsets and Splits