repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.color | protected function color(&$out) {
if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) {
if (strlen($m[1]) > 7) {
$out = array("string", "", array($m[1]));
} else {
$out = array("raw_color", $m[1]);
}
return true;
}
return false;
} | php | protected function color(&$out) {
if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) {
if (strlen($m[1]) > 7) {
$out = array("string", "", array($m[1]));
} else {
$out = array("raw_color", $m[1]);
}
return true;
}
return false;
} | [
"protected",
"function",
"color",
"(",
"&",
"$",
"out",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"match",
"(",
"'(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))'",
",",
"$",
"m",
")",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"m",
"[",
"1",
"]",
")",
">",
... | a # color | [
"a",
"#",
"color"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3001-L3012 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.argumentDef | protected function argumentDef(&$args, &$isVararg) {
$s = $this->seek();
if (!$this->literal('(')) return false;
$values = array();
$delim = ",";
$method = "expressionList";
$isVararg = false;
while (true) {
if ($this->literal("...")) {
$isVararg = true;
break;
}
if ($this->$method($value)) {
if ($value[0] == "variable") {
$arg = array("arg", $value[1]);
$ss = $this->seek();
if ($this->assign() && $this->$method($rhs)) {
$arg[] = $rhs;
} else {
$this->seek($ss);
if ($this->literal("...")) {
$arg[0] = "rest";
$isVararg = true;
}
}
$values[] = $arg;
if ($isVararg) break;
continue;
} else {
$values[] = array("lit", $value);
}
}
if (!$this->literal($delim)) {
if ($delim == "," && $this->literal(";")) {
// found new delim, convert existing args
$delim = ";";
$method = "propertyValue";
// transform arg list
if (isset($values[1])) { // 2 items
$newList = array();
foreach ($values as $i => $arg) {
switch($arg[0]) {
case "arg":
if ($i) {
$this->throwError("Cannot mix ; and , as delimiter types");
}
$newList[] = $arg[2];
break;
case "lit":
$newList[] = $arg[1];
break;
case "rest":
$this->throwError("Unexpected rest before semicolon");
}
}
$newList = array("list", ", ", $newList);
switch ($values[0][0]) {
case "arg":
$newArg = array("arg", $values[0][1], $newList);
break;
case "lit":
$newArg = array("lit", $newList);
break;
}
} elseif ($values) { // 1 item
$newArg = $values[0];
}
if ($newArg) {
$values = array($newArg);
}
} else {
break;
}
}
}
if (!$this->literal(')')) {
$this->seek($s);
return false;
}
$args = $values;
return true;
} | php | protected function argumentDef(&$args, &$isVararg) {
$s = $this->seek();
if (!$this->literal('(')) return false;
$values = array();
$delim = ",";
$method = "expressionList";
$isVararg = false;
while (true) {
if ($this->literal("...")) {
$isVararg = true;
break;
}
if ($this->$method($value)) {
if ($value[0] == "variable") {
$arg = array("arg", $value[1]);
$ss = $this->seek();
if ($this->assign() && $this->$method($rhs)) {
$arg[] = $rhs;
} else {
$this->seek($ss);
if ($this->literal("...")) {
$arg[0] = "rest";
$isVararg = true;
}
}
$values[] = $arg;
if ($isVararg) break;
continue;
} else {
$values[] = array("lit", $value);
}
}
if (!$this->literal($delim)) {
if ($delim == "," && $this->literal(";")) {
// found new delim, convert existing args
$delim = ";";
$method = "propertyValue";
// transform arg list
if (isset($values[1])) { // 2 items
$newList = array();
foreach ($values as $i => $arg) {
switch($arg[0]) {
case "arg":
if ($i) {
$this->throwError("Cannot mix ; and , as delimiter types");
}
$newList[] = $arg[2];
break;
case "lit":
$newList[] = $arg[1];
break;
case "rest":
$this->throwError("Unexpected rest before semicolon");
}
}
$newList = array("list", ", ", $newList);
switch ($values[0][0]) {
case "arg":
$newArg = array("arg", $values[0][1], $newList);
break;
case "lit":
$newArg = array("lit", $newList);
break;
}
} elseif ($values) { // 1 item
$newArg = $values[0];
}
if ($newArg) {
$values = array($newArg);
}
} else {
break;
}
}
}
if (!$this->literal(')')) {
$this->seek($s);
return false;
}
$args = $values;
return true;
} | [
"protected",
"function",
"argumentDef",
"(",
"&",
"$",
"args",
",",
"&",
"$",
"isVararg",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"literal",
"(",
"'('",
")",
")",
"return",
"false",
... | delimiter. | [
"delimiter",
"."
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3019-L3115 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.mixinTags | protected function mixinTags(&$tags) {
$tags = array();
while ($this->tag($tt, true)) {
$tags[] = $tt;
$this->literal(">");
}
if (count($tags) == 0) return false;
return true;
} | php | protected function mixinTags(&$tags) {
$tags = array();
while ($this->tag($tt, true)) {
$tags[] = $tt;
$this->literal(">");
}
if (count($tags) == 0) return false;
return true;
} | [
"protected",
"function",
"mixinTags",
"(",
"&",
"$",
"tags",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"tag",
"(",
"$",
"tt",
",",
"true",
")",
")",
"{",
"$",
"tags",
"[",
"]",
"=",
"$",
"tt",
";",
... | optionally separated by > (lazy, accepts extra >) | [
"optionally",
"separated",
"by",
">",
"(",
"lazy",
"accepts",
"extra",
">",
")"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3132-L3142 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.tagBracket | protected function tagBracket(&$parts, &$hasExpression) {
// speed shortcut
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "[") {
return false;
}
$s = $this->seek();
$hasInterpolation = false;
if ($this->literal("[", false)) {
$attrParts = array("[");
// keyword, string, operator
while (true) {
if ($this->literal("]", false)) {
$this->count--;
break; // get out early
}
if ($this->match('\s+', $m)) {
$attrParts[] = " ";
continue;
}
if ($this->string($str)) {
// escape parent selector, (yuck)
foreach ($str[2] as &$chunk) {
$chunk = str_replace($this->lessc->parentSelector, "$&$", $chunk);
}
$attrParts[] = $str;
$hasInterpolation = true;
continue;
}
if ($this->keyword($word)) {
$attrParts[] = $word;
continue;
}
if ($this->interpolation($inter, false)) {
$attrParts[] = $inter;
$hasInterpolation = true;
continue;
}
// operator, handles attr namespace too
if ($this->match('[|-~\$\*\^=]+', $m)) {
$attrParts[] = $m[0];
continue;
}
break;
}
if ($this->literal("]", false)) {
$attrParts[] = "]";
foreach ($attrParts as $part) {
$parts[] = $part;
}
$hasExpression = $hasExpression || $hasInterpolation;
return true;
}
$this->seek($s);
}
$this->seek($s);
return false;
} | php | protected function tagBracket(&$parts, &$hasExpression) {
// speed shortcut
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "[") {
return false;
}
$s = $this->seek();
$hasInterpolation = false;
if ($this->literal("[", false)) {
$attrParts = array("[");
// keyword, string, operator
while (true) {
if ($this->literal("]", false)) {
$this->count--;
break; // get out early
}
if ($this->match('\s+', $m)) {
$attrParts[] = " ";
continue;
}
if ($this->string($str)) {
// escape parent selector, (yuck)
foreach ($str[2] as &$chunk) {
$chunk = str_replace($this->lessc->parentSelector, "$&$", $chunk);
}
$attrParts[] = $str;
$hasInterpolation = true;
continue;
}
if ($this->keyword($word)) {
$attrParts[] = $word;
continue;
}
if ($this->interpolation($inter, false)) {
$attrParts[] = $inter;
$hasInterpolation = true;
continue;
}
// operator, handles attr namespace too
if ($this->match('[|-~\$\*\^=]+', $m)) {
$attrParts[] = $m[0];
continue;
}
break;
}
if ($this->literal("]", false)) {
$attrParts[] = "]";
foreach ($attrParts as $part) {
$parts[] = $part;
}
$hasExpression = $hasExpression || $hasInterpolation;
return true;
}
$this->seek($s);
}
$this->seek($s);
return false;
} | [
"protected",
"function",
"tagBracket",
"(",
"&",
"$",
"parts",
",",
"&",
"$",
"hasExpression",
")",
"{",
"// speed shortcut\r",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"buffer",
"[",
"$",
"this",
"->",
"count",
"]",
")",
"&&",
"$",
"this",
"->",
... | a bracketed value (contained within in a tag definition) | [
"a",
"bracketed",
"value",
"(",
"contained",
"within",
"in",
"a",
"tag",
"definition",
")"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3145-L3212 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.tag | protected function tag(&$tag, $simple = false) {
if ($simple)
$chars = '^@,:;{}\][>\(\) "\'';
else
$chars = '^@,;{}["\'';
$s = $this->seek();
$hasExpression = false;
$parts = array();
while ($this->tagBracket($parts, $hasExpression));
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
while (true) {
if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
$parts[] = $m[1];
if ($simple) break;
while ($this->tagBracket($parts, $hasExpression));
continue;
}
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
if ($this->interpolation($interp)) {
$hasExpression = true;
$interp[2] = true; // don't unescape
$parts[] = $interp;
continue;
}
if ($this->literal("@")) {
$parts[] = "@";
continue;
}
}
if ($this->unit($unit)) { // for keyframes
$parts[] = $unit[1];
$parts[] = $unit[2];
continue;
}
break;
}
$this->eatWhiteDefault = $oldWhite;
if (!$parts) {
$this->seek($s);
return false;
}
if ($hasExpression) {
$tag = array("exp", array("string", "", $parts));
} else {
$tag = trim(implode($parts));
}
$this->whitespace();
return true;
} | php | protected function tag(&$tag, $simple = false) {
if ($simple)
$chars = '^@,:;{}\][>\(\) "\'';
else
$chars = '^@,;{}["\'';
$s = $this->seek();
$hasExpression = false;
$parts = array();
while ($this->tagBracket($parts, $hasExpression));
$oldWhite = $this->eatWhiteDefault;
$this->eatWhiteDefault = false;
while (true) {
if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
$parts[] = $m[1];
if ($simple) break;
while ($this->tagBracket($parts, $hasExpression));
continue;
}
if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
if ($this->interpolation($interp)) {
$hasExpression = true;
$interp[2] = true; // don't unescape
$parts[] = $interp;
continue;
}
if ($this->literal("@")) {
$parts[] = "@";
continue;
}
}
if ($this->unit($unit)) { // for keyframes
$parts[] = $unit[1];
$parts[] = $unit[2];
continue;
}
break;
}
$this->eatWhiteDefault = $oldWhite;
if (!$parts) {
$this->seek($s);
return false;
}
if ($hasExpression) {
$tag = array("exp", array("string", "", $parts));
} else {
$tag = trim(implode($parts));
}
$this->whitespace();
return true;
} | [
"protected",
"function",
"tag",
"(",
"&",
"$",
"tag",
",",
"$",
"simple",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"simple",
")",
"$",
"chars",
"=",
"'^@,:;{}\\][>\\(\\) \"\\''",
";",
"else",
"$",
"chars",
"=",
"'^@,;{}[\"\\''",
";",
"$",
"s",
"=",
"$... | a space separated list of selectors | [
"a",
"space",
"separated",
"list",
"of",
"selectors"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3215-L3276 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.func | protected function func(&$func) {
$s = $this->seek();
if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
$fname = $m[1];
$sPreArgs = $this->seek();
$args = array();
while (true) {
$ss = $this->seek();
// this ugly nonsense is for ie filter properties
if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
$args[] = array("string", "", array($name, "=", $value));
} else {
$this->seek($ss);
if ($this->expressionList($value)) {
$args[] = $value;
}
}
if (!$this->literal(',')) break;
}
$args = array('list', ',', $args);
if ($this->literal(')')) {
$func = array('function', $fname, $args);
return true;
} elseif ($fname == 'url') {
// couldn't parse and in url? treat as string
$this->seek($sPreArgs);
if ($this->openString(")", $string) && $this->literal(")")) {
$func = array('function', $fname, $string);
return true;
}
}
}
$this->seek($s);
return false;
} | php | protected function func(&$func) {
$s = $this->seek();
if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
$fname = $m[1];
$sPreArgs = $this->seek();
$args = array();
while (true) {
$ss = $this->seek();
// this ugly nonsense is for ie filter properties
if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
$args[] = array("string", "", array($name, "=", $value));
} else {
$this->seek($ss);
if ($this->expressionList($value)) {
$args[] = $value;
}
}
if (!$this->literal(',')) break;
}
$args = array('list', ',', $args);
if ($this->literal(')')) {
$func = array('function', $fname, $args);
return true;
} elseif ($fname == 'url') {
// couldn't parse and in url? treat as string
$this->seek($sPreArgs);
if ($this->openString(")", $string) && $this->literal(")")) {
$func = array('function', $fname, $string);
return true;
}
}
}
$this->seek($s);
return false;
} | [
"protected",
"function",
"func",
"(",
"&",
"$",
"func",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"seek",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"match",
"(",
"'(%|[\\w\\-_][\\w\\-_:\\.]+|[\\w_])'",
",",
"$",
"m",
")",
"&&",
"$",
"this",
"-... | a css function | [
"a",
"css",
"function"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3279-L3319 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.assign | protected function assign($name = null) {
if ($name) $this->currentProperty = $name;
return $this->literal(':') || $this->literal('=');
} | php | protected function assign($name = null) {
if ($name) $this->currentProperty = $name;
return $this->literal(':') || $this->literal('=');
} | [
"protected",
"function",
"assign",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"$",
"this",
"->",
"currentProperty",
"=",
"$",
"name",
";",
"return",
"$",
"this",
"->",
"literal",
"(",
"':'",
")",
"||",
"$",
"this",
"->",
... | Consume an assignment operator
Can optionally take a name that will be set to the current property name | [
"Consume",
"an",
"assignment",
"operator",
"Can",
"optionally",
"take",
"a",
"name",
"that",
"will",
"be",
"set",
"to",
"the",
"current",
"property",
"name"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3344-L3347 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.literal | protected function literal($what, $eatWhitespace = null) {
if ($eatWhitespace === null) $eatWhitespace = $this->eatWhiteDefault;
// shortcut on single letter
if (!isset($what[1]) && isset($this->buffer[$this->count])) {
if ($this->buffer[$this->count] == $what) {
if (!$eatWhitespace) {
$this->count++;
return true;
}
// goes below...
} else {
return false;
}
}
if (!isset(self::$literalCache[$what])) {
self::$literalCache[$what] = \ATPCore\Lessc::preg_quote($what);
}
return $this->match(self::$literalCache[$what], $m, $eatWhitespace);
} | php | protected function literal($what, $eatWhitespace = null) {
if ($eatWhitespace === null) $eatWhitespace = $this->eatWhiteDefault;
// shortcut on single letter
if (!isset($what[1]) && isset($this->buffer[$this->count])) {
if ($this->buffer[$this->count] == $what) {
if (!$eatWhitespace) {
$this->count++;
return true;
}
// goes below...
} else {
return false;
}
}
if (!isset(self::$literalCache[$what])) {
self::$literalCache[$what] = \ATPCore\Lessc::preg_quote($what);
}
return $this->match(self::$literalCache[$what], $m, $eatWhitespace);
} | [
"protected",
"function",
"literal",
"(",
"$",
"what",
",",
"$",
"eatWhitespace",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"eatWhitespace",
"===",
"null",
")",
"$",
"eatWhitespace",
"=",
"$",
"this",
"->",
"eatWhiteDefault",
";",
"// shortcut on single letter\r",... | /* raw parsing functions | [
"/",
"*",
"raw",
"parsing",
"functions"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3428-L3449 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.to | protected function to($what, &$out, $until = false, $allowNewline = false) {
if (is_string($allowNewline)) {
$validChars = $allowNewline;
} else {
$validChars = $allowNewline ? "." : "[^\n]";
}
if (!$this->match('('.$validChars.'*?)'.\ATPCore\Lessc::preg_quote($what), $m, !$until)) return false;
if ($until) $this->count -= strlen($what); // give back $what
$out = $m[1];
return true;
} | php | protected function to($what, &$out, $until = false, $allowNewline = false) {
if (is_string($allowNewline)) {
$validChars = $allowNewline;
} else {
$validChars = $allowNewline ? "." : "[^\n]";
}
if (!$this->match('('.$validChars.'*?)'.\ATPCore\Lessc::preg_quote($what), $m, !$until)) return false;
if ($until) $this->count -= strlen($what); // give back $what
$out = $m[1];
return true;
} | [
"protected",
"function",
"to",
"(",
"$",
"what",
",",
"&",
"$",
"out",
",",
"$",
"until",
"=",
"false",
",",
"$",
"allowNewline",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"allowNewline",
")",
")",
"{",
"$",
"validChars",
"=",
"$",
... | $allowNewline, if string, will be used as valid char set | [
"$allowNewline",
"if",
"string",
"will",
"be",
"used",
"as",
"valid",
"char",
"set"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3479-L3489 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.append | protected function append($prop, $pos = null) {
if ($pos !== null) $prop[-1] = $pos;
$this->env->props[] = $prop;
} | php | protected function append($prop, $pos = null) {
if ($pos !== null) $prop[-1] = $pos;
$this->env->props[] = $prop;
} | [
"protected",
"function",
"append",
"(",
"$",
"prop",
",",
"$",
"pos",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pos",
"!==",
"null",
")",
"$",
"prop",
"[",
"-",
"1",
"]",
"=",
"$",
"pos",
";",
"$",
"this",
"->",
"env",
"->",
"props",
"[",
"]",
... | append a property to the current block | [
"append",
"a",
"property",
"to",
"the",
"current",
"block"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3584-L3587 |
DaemonAlchemist/atp-core | src/ATPCore/Lessc.php | lessc_parser.removeComments | protected function removeComments($text) {
$look = array(
'url(', '//', '/*', '"', "'"
);
$out = '';
$min = null;
while (true) {
// find the next item
foreach ($look as $token) {
$pos = strpos($text, $token);
if ($pos !== false) {
if (!isset($min) || $pos < $min[1]) $min = array($token, $pos);
}
}
if (is_null($min)) break;
$count = $min[1];
$skip = 0;
$newlines = 0;
switch ($min[0]) {
case 'url(':
if (preg_match('/url\(.*?\)/', $text, $m, 0, $count))
$count += strlen($m[0]) - strlen($min[0]);
break;
case '"':
case "'":
if (preg_match('/'.$min[0].'.*?(?<!\\\\)'.$min[0].'/', $text, $m, 0, $count))
$count += strlen($m[0]) - 1;
break;
case '//':
$skip = strpos($text, "\n", $count);
if ($skip === false) $skip = strlen($text) - $count;
else $skip -= $count;
break;
case '/*':
if (preg_match('/\/\*.*?\*\//s', $text, $m, 0, $count)) {
$skip = strlen($m[0]);
$newlines = substr_count($m[0], "\n");
}
break;
}
if ($skip == 0) $count += strlen($min[0]);
$out .= substr($text, 0, $count).str_repeat("\n", $newlines);
$text = substr($text, $count + $skip);
$min = null;
}
return $out.$text;
} | php | protected function removeComments($text) {
$look = array(
'url(', '//', '/*', '"', "'"
);
$out = '';
$min = null;
while (true) {
// find the next item
foreach ($look as $token) {
$pos = strpos($text, $token);
if ($pos !== false) {
if (!isset($min) || $pos < $min[1]) $min = array($token, $pos);
}
}
if (is_null($min)) break;
$count = $min[1];
$skip = 0;
$newlines = 0;
switch ($min[0]) {
case 'url(':
if (preg_match('/url\(.*?\)/', $text, $m, 0, $count))
$count += strlen($m[0]) - strlen($min[0]);
break;
case '"':
case "'":
if (preg_match('/'.$min[0].'.*?(?<!\\\\)'.$min[0].'/', $text, $m, 0, $count))
$count += strlen($m[0]) - 1;
break;
case '//':
$skip = strpos($text, "\n", $count);
if ($skip === false) $skip = strlen($text) - $count;
else $skip -= $count;
break;
case '/*':
if (preg_match('/\/\*.*?\*\//s', $text, $m, 0, $count)) {
$skip = strlen($m[0]);
$newlines = substr_count($m[0], "\n");
}
break;
}
if ($skip == 0) $count += strlen($min[0]);
$out .= substr($text, 0, $count).str_repeat("\n", $newlines);
$text = substr($text, $count + $skip);
$min = null;
}
return $out.$text;
} | [
"protected",
"function",
"removeComments",
"(",
"$",
"text",
")",
"{",
"$",
"look",
"=",
"array",
"(",
"'url('",
",",
"'//'",
",",
"'/*'",
",",
"'\"'",
",",
"\"'\"",
")",
";",
"$",
"out",
"=",
"''",
";",
"$",
"min",
"=",
"null",
";",
"while",
"("... | todo: make it work for all functions, not just url | [
"todo",
":",
"make",
"it",
"work",
"for",
"all",
"functions",
"not",
"just",
"url"
] | train | https://github.com/DaemonAlchemist/atp-core/blob/47efa734b882c27aa2a59fbcba34653b4d2125c7/src/ATPCore/Lessc.php#L3598-L3651 |
Codifico/phpspec-rest-view-extension | src/Matcher/RestViewMatcher.php | RestViewMatcher.matches | protected function matches($subject, array $arguments)
{
if (!$this->isRestViewObject($subject)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be an instance of FOS\RestBundle\View\View',
$this->presenter->presentValue($subject)
));
return false;
}
/** @var View $subject */
$argument = isset($arguments[0]) ? $arguments[0] : [];
if (!$this->dataMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be a data of the View, but it is not. Instead got: %s',
$this->presenter->presentValue($argument['data']),
$this->presenter->presentValue($subject->getData())
));
return false;
}
if (!$this->statusCodeMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be a status code of the View, but it is not. Instead got: %s',
$this->presenter->presentValue($argument['statusCode']),
$this->presenter->presentValue($subject->getStatusCode())
));
return false;
}
if (!$this->headersMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected headers to be %s, but it is not. Instead got: %s. Details: %s',
$this->presenter->presentValue($argument['headers']),
$this->presenter->presentValue($subject->getHeaders()),
$this->matcher->getError()
));
return false;
}
if (!$this->serializationGroupsMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected serialization group to be %s, but they are not',
empty($argument['serializationGroups']) ? 'empty (it\'s impossible!)' : implode(', ', $argument['serializationGroups'])
));
return false;
}
} | php | protected function matches($subject, array $arguments)
{
if (!$this->isRestViewObject($subject)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be an instance of FOS\RestBundle\View\View',
$this->presenter->presentValue($subject)
));
return false;
}
/** @var View $subject */
$argument = isset($arguments[0]) ? $arguments[0] : [];
if (!$this->dataMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be a data of the View, but it is not. Instead got: %s',
$this->presenter->presentValue($argument['data']),
$this->presenter->presentValue($subject->getData())
));
return false;
}
if (!$this->statusCodeMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected %s to be a status code of the View, but it is not. Instead got: %s',
$this->presenter->presentValue($argument['statusCode']),
$this->presenter->presentValue($subject->getStatusCode())
));
return false;
}
if (!$this->headersMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected headers to be %s, but it is not. Instead got: %s. Details: %s',
$this->presenter->presentValue($argument['headers']),
$this->presenter->presentValue($subject->getHeaders()),
$this->matcher->getError()
));
return false;
}
if (!$this->serializationGroupsMatches($subject, $argument)) {
$this->exception = new FailureException(sprintf(
'Expected serialization group to be %s, but they are not',
empty($argument['serializationGroups']) ? 'empty (it\'s impossible!)' : implode(', ', $argument['serializationGroups'])
));
return false;
}
} | [
"protected",
"function",
"matches",
"(",
"$",
"subject",
",",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRestViewObject",
"(",
"$",
"subject",
")",
")",
"{",
"$",
"this",
"->",
"exception",
"=",
"new",
"FailureException",
... | @param mixed $subject
@param array $arguments
@return boolean | [
"@param",
"mixed",
"$subject",
"@param",
"array",
"$arguments"
] | train | https://github.com/Codifico/phpspec-rest-view-extension/blob/2528f20e648f887a14ec94bafe486246d7deefb8/src/Matcher/RestViewMatcher.php#L45-L98 |
foxslider/cmg-plugin | admin/controllers/apix/SlideController.php | SlideController.actionGet | public function actionGet( $id, $cid, $fid ) {
// Find Model
$model = $this->modelService->getById( $cid );
// Update/Render if exist
if( isset( $model ) ) {
$file = $model->image;
$data = [
'mid' => $model->id, 'fid' => $file->id,
'name' => $file->name, 'extension' => $file->extension,
'title' => $file->title, 'caption' => $file->caption,
'altText' => $file->altText, 'link' => $file->link, 'url' => $file->getFileUrl(),
'description' => $file->description, 'content' => $model->content
];
if( $file->type == 'image' ) {
$data[ 'mediumUrl' ] = $file->getMediumUrl();
$data[ 'thumbUrl' ] = $file->getThumbUrl();
}
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ), $errors );
} | php | public function actionGet( $id, $cid, $fid ) {
// Find Model
$model = $this->modelService->getById( $cid );
// Update/Render if exist
if( isset( $model ) ) {
$file = $model->image;
$data = [
'mid' => $model->id, 'fid' => $file->id,
'name' => $file->name, 'extension' => $file->extension,
'title' => $file->title, 'caption' => $file->caption,
'altText' => $file->altText, 'link' => $file->link, 'url' => $file->getFileUrl(),
'description' => $file->description, 'content' => $model->content
];
if( $file->type == 'image' ) {
$data[ 'mediumUrl' ] = $file->getMediumUrl();
$data[ 'thumbUrl' ] = $file->getThumbUrl();
}
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ), $errors );
} | [
"public",
"function",
"actionGet",
"(",
"$",
"id",
",",
"$",
"cid",
",",
"$",
"fid",
")",
"{",
"// Find Model",
"$",
"model",
"=",
"$",
"this",
"->",
"modelService",
"->",
"getById",
"(",
"$",
"cid",
")",
";",
"// Update/Render if exist",
"if",
"(",
"i... | SlideController ----------------------- | [
"SlideController",
"-----------------------"
] | train | https://github.com/foxslider/cmg-plugin/blob/843f723ebb512ab833feff581beb9714df4e41bd/admin/controllers/apix/SlideController.php#L98-L128 |
shgysk8zer0/core_api | traits/xmlappend.php | XMLAppend.XMLAppend | protected function XMLAppend(\DOMNode &$parent = null, $content = null)
{
if (is_null($parent)) {
$parent = $this->root;
}
if (
is_string($content)
or is_numeric($content)
or (is_object($content) and method_exists($content, '__toString'))
) {
$parent->appendChild($this->createTextNode("$content"));
} elseif (
is_object($content)
and is_subclass_of($content, '\DOMNode')
) {
$parent->appendChild($content);
} elseif (
is_array($content)
or (is_object($content) and $content = get_object_vars($content))
) {
array_map(
function($node, $value) use (&$parent){
if (is_string($node)) {
if (substr($node, 0, 1) === '@') {
$parent->setAttribute(substr($node, 1), $value);
} else {
$node = $parent->appendChild($this->createElement($node));
if (is_string($value)) {
$this->XMLAppend(
$node,
$this->createTextNode($value)
);
} else {
$this->XMLAppend($node, $value);
}
}
} else {
$this->XMLAppend($parent, $value);
}
},
array_keys($content),
array_values($content)
);
} elseif (is_bool($content)) {
$parent->appendChild(
$this->createTextNode($content ? 'true' : 'false')
);
} else {
throw new \InvalidArgumentException(
sprintf(
'Unable to append unknown content [%s] to %s',
get_class($content),
get_class($this)
)
);
}
return $this;
} | php | protected function XMLAppend(\DOMNode &$parent = null, $content = null)
{
if (is_null($parent)) {
$parent = $this->root;
}
if (
is_string($content)
or is_numeric($content)
or (is_object($content) and method_exists($content, '__toString'))
) {
$parent->appendChild($this->createTextNode("$content"));
} elseif (
is_object($content)
and is_subclass_of($content, '\DOMNode')
) {
$parent->appendChild($content);
} elseif (
is_array($content)
or (is_object($content) and $content = get_object_vars($content))
) {
array_map(
function($node, $value) use (&$parent){
if (is_string($node)) {
if (substr($node, 0, 1) === '@') {
$parent->setAttribute(substr($node, 1), $value);
} else {
$node = $parent->appendChild($this->createElement($node));
if (is_string($value)) {
$this->XMLAppend(
$node,
$this->createTextNode($value)
);
} else {
$this->XMLAppend($node, $value);
}
}
} else {
$this->XMLAppend($parent, $value);
}
},
array_keys($content),
array_values($content)
);
} elseif (is_bool($content)) {
$parent->appendChild(
$this->createTextNode($content ? 'true' : 'false')
);
} else {
throw new \InvalidArgumentException(
sprintf(
'Unable to append unknown content [%s] to %s',
get_class($content),
get_class($this)
)
);
}
return $this;
} | [
"protected",
"function",
"XMLAppend",
"(",
"\\",
"DOMNode",
"&",
"$",
"parent",
"=",
"null",
",",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"root",
";",
... | Append any supported $content to $parent
@param DOMNode $parent Node to append to
@param mixed $content Content to append
@return self | [
"Append",
"any",
"supported",
"$content",
"to",
"$parent"
] | train | https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/xmlappend.php#L36-L94 |
nguyenanhung/image | src/ImageCache.php | ImageCache.setTmpPath | public function setTmpPath($tmpPath = '')
{
if (empty($tmpPath)) {
$tmpPath = __DIR__ . '/../storage/tmp/';
}
$this->tmpPath = $tmpPath;
return $this;
} | php | public function setTmpPath($tmpPath = '')
{
if (empty($tmpPath)) {
$tmpPath = __DIR__ . '/../storage/tmp/';
}
$this->tmpPath = $tmpPath;
return $this;
} | [
"public",
"function",
"setTmpPath",
"(",
"$",
"tmpPath",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tmpPath",
")",
")",
"{",
"$",
"tmpPath",
"=",
"__DIR__",
".",
"'/../storage/tmp/'",
";",
"}",
"$",
"this",
"->",
"tmpPath",
"=",
"$",
"tmpPat... | Cấu hình thư mục lưu trữ file Cache Image
@author: 713uk13m <dev@nguyenanhung.com>
@time : 11/1/18 14:21
@param string $tmpPath Thư mục cần lưu trữ
@return $this | [
"Cấu",
"hình",
"thư",
"mục",
"lưu",
"trữ",
"file",
"Cache",
"Image"
] | train | https://github.com/nguyenanhung/image/blob/5d30dfa203c0411209b8985ab4a86a6be9a7b2d1/src/ImageCache.php#L64-L72 |
nguyenanhung/image | src/ImageCache.php | ImageCache.setDefaultImage | public function setDefaultImage($defaultImage = '')
{
if (empty($defaultImage)) {
$image = DataRepository::getData('config_image');
$defaultImage = $image['default_image'];
}
$this->defaultImage = $defaultImage;
return $this;
} | php | public function setDefaultImage($defaultImage = '')
{
if (empty($defaultImage)) {
$image = DataRepository::getData('config_image');
$defaultImage = $image['default_image'];
}
$this->defaultImage = $defaultImage;
return $this;
} | [
"public",
"function",
"setDefaultImage",
"(",
"$",
"defaultImage",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"defaultImage",
")",
")",
"{",
"$",
"image",
"=",
"DataRepository",
"::",
"getData",
"(",
"'config_image'",
")",
";",
"$",
"defaultImage",... | Cấu hình đường dẫn link ảnh mặc định
@author: 713uk13m <dev@nguyenanhung.com>
@time : 11/1/18 15:40
@param string $defaultImage Đường dẫn link ảnh mặc định
@return $this | [
"Cấu",
"hình",
"đường",
"dẫn",
"link",
"ảnh",
"mặc",
"định"
] | train | https://github.com/nguyenanhung/image/blob/5d30dfa203c0411209b8985ab4a86a6be9a7b2d1/src/ImageCache.php#L101-L110 |
nguyenanhung/image | src/ImageCache.php | ImageCache.saveImage | public function saveImage($url = '', $format = 'png')
{
$image = DataRepository::getData('config_image');
$defaultImage = $image['default_image'];
try {
Utils::debug('URL: ' . $url);
Utils::debug('Format: ' . $format);
try {
// Xác định extention của file ảnh
$info = new \SplFileInfo($url);
$fileExtension = $info->getExtension();
$outputFormat = !empty($fileExtension) ? $fileExtension : $format;
Utils::debug('Output Format: ' . $outputFormat);
// Quy định tên file ảnh sẽ lưu
$fileName = md5($url) . '.' . $outputFormat;
$imageFile = $this->tmpPath . $fileName;
$imageUrl = $this->urlPath . $fileName;
if (!file_exists($imageFile)) {
Utils::debug('Khong ton tai file: ' . $imageFile);
// Nếu như không tồn tại file ảnh -> sẽ tiến hành phân tích và cache file
// Xác định size ảnh
$imagine = new Imagine();
if (is_file($url)) {
Utils::debug('URL is File => ' . $url);
$image = $imagine->open($url);
$image->save($imageFile);
} else {
Utils::debug('URL is URL => ' . $url);
$getContent = Utils::getImageFromUrl($url);
Utils::debug('Data Content: ' . json_encode($getContent));
if (isset($getContent['content'])) {
$image = $imagine->load($getContent['content']);
Utils::debug('Load Content with CURL');
} else {
$image = $imagine->load($getContent);
Utils::debug('Load Content with file_get_content');
}
$result = $image->save($imageFile);
Utils::debug('Save Image Result: ' . json_encode($result));
}
}
$resultImage = trim($imageUrl);
return $resultImage;
}
catch (RuntimeException $runtimeException) {
if (function_exists('log_message')) {
$message = 'Runtime Error Code: ' . $runtimeException->getCode() . ' - File: ' . $runtimeException->getFile() . ' - Line: ' . $runtimeException->getLine() . ' - Message: ' . $runtimeException->getMessage();
log_message('error', $message);
}
return NULL;
}
}
catch (\Exception $e) {
if (function_exists('log_message')) {
$message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
log_message('error', $message);
}
return $defaultImage;
}
} | php | public function saveImage($url = '', $format = 'png')
{
$image = DataRepository::getData('config_image');
$defaultImage = $image['default_image'];
try {
Utils::debug('URL: ' . $url);
Utils::debug('Format: ' . $format);
try {
// Xác định extention của file ảnh
$info = new \SplFileInfo($url);
$fileExtension = $info->getExtension();
$outputFormat = !empty($fileExtension) ? $fileExtension : $format;
Utils::debug('Output Format: ' . $outputFormat);
// Quy định tên file ảnh sẽ lưu
$fileName = md5($url) . '.' . $outputFormat;
$imageFile = $this->tmpPath . $fileName;
$imageUrl = $this->urlPath . $fileName;
if (!file_exists($imageFile)) {
Utils::debug('Khong ton tai file: ' . $imageFile);
// Nếu như không tồn tại file ảnh -> sẽ tiến hành phân tích và cache file
// Xác định size ảnh
$imagine = new Imagine();
if (is_file($url)) {
Utils::debug('URL is File => ' . $url);
$image = $imagine->open($url);
$image->save($imageFile);
} else {
Utils::debug('URL is URL => ' . $url);
$getContent = Utils::getImageFromUrl($url);
Utils::debug('Data Content: ' . json_encode($getContent));
if (isset($getContent['content'])) {
$image = $imagine->load($getContent['content']);
Utils::debug('Load Content with CURL');
} else {
$image = $imagine->load($getContent);
Utils::debug('Load Content with file_get_content');
}
$result = $image->save($imageFile);
Utils::debug('Save Image Result: ' . json_encode($result));
}
}
$resultImage = trim($imageUrl);
return $resultImage;
}
catch (RuntimeException $runtimeException) {
if (function_exists('log_message')) {
$message = 'Runtime Error Code: ' . $runtimeException->getCode() . ' - File: ' . $runtimeException->getFile() . ' - Line: ' . $runtimeException->getLine() . ' - Message: ' . $runtimeException->getMessage();
log_message('error', $message);
}
return NULL;
}
}
catch (\Exception $e) {
if (function_exists('log_message')) {
$message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
log_message('error', $message);
}
return $defaultImage;
}
} | [
"public",
"function",
"saveImage",
"(",
"$",
"url",
"=",
"''",
",",
"$",
"format",
"=",
"'png'",
")",
"{",
"$",
"image",
"=",
"DataRepository",
"::",
"getData",
"(",
"'config_image'",
")",
";",
"$",
"defaultImage",
"=",
"$",
"image",
"[",
"'default_image... | Hàm cache Image và save về server
@author: 713uk13m <dev@nguyenanhung.com>
@time : 11/7/18 09:10
@param string $url Đường dẫn hoặc URL hình ảnh
@param string $format Format đầu ra
@return null|string Đường dẫn link tới hình ảnh được cache | [
"Hàm",
"cache",
"Image",
"và",
"save",
"về",
"server"
] | train | https://github.com/nguyenanhung/image/blob/5d30dfa203c0411209b8985ab4a86a6be9a7b2d1/src/ImageCache.php#L203-L265 |
pdyn/httpclient | HttpClientResponse.php | HttpClientResponse.instance_from_curl | public static function instance_from_curl($ch, $body) {
$transfer_info = curl_getinfo($ch);
$statuscode = (!empty($transfer_info['http_code'])) ? (int)$transfer_info['http_code'] : 404;
$errors = [];
$err = static::decode_error_code(curl_errno($ch));
if ($err !== 'SUCCESS') {
$errors[] = $err;
}
$mime = (!empty($transfer_info['content_type'])) ? $transfer_info['content_type'] : 'text/plain';
return new HttpClientResponse($statuscode, $mime, $body, $errors);
} | php | public static function instance_from_curl($ch, $body) {
$transfer_info = curl_getinfo($ch);
$statuscode = (!empty($transfer_info['http_code'])) ? (int)$transfer_info['http_code'] : 404;
$errors = [];
$err = static::decode_error_code(curl_errno($ch));
if ($err !== 'SUCCESS') {
$errors[] = $err;
}
$mime = (!empty($transfer_info['content_type'])) ? $transfer_info['content_type'] : 'text/plain';
return new HttpClientResponse($statuscode, $mime, $body, $errors);
} | [
"public",
"static",
"function",
"instance_from_curl",
"(",
"$",
"ch",
",",
"$",
"body",
")",
"{",
"$",
"transfer_info",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"$",
"statuscode",
"=",
"(",
"!",
"empty",
"(",
"$",
"transfer_info",
"[",
"'http_code'... | Create an instance from a curl handle and body.
@param resource $ch An active curl handle.
@param string $body The returned body.
@return HttpClientResponse A response object. | [
"Create",
"an",
"instance",
"from",
"a",
"curl",
"handle",
"and",
"body",
"."
] | train | https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L77-L90 |
pdyn/httpclient | HttpClientResponse.php | HttpClientResponse.get_debug_string | public function get_debug_string() {
return 'status: '.$this->statuscode.' body:'.htmlentities($this->body).' errors: '.print_r($this->errors, true);
} | php | public function get_debug_string() {
return 'status: '.$this->statuscode.' body:'.htmlentities($this->body).' errors: '.print_r($this->errors, true);
} | [
"public",
"function",
"get_debug_string",
"(",
")",
"{",
"return",
"'status: '",
".",
"$",
"this",
"->",
"statuscode",
".",
"' body:'",
".",
"htmlentities",
"(",
"$",
"this",
"->",
"body",
")",
".",
"' errors: '",
".",
"print_r",
"(",
"$",
"this",
"->",
... | Get a string with some basic information about the request. Usually put into the logs.
@return string A string containing debug information. | [
"Get",
"a",
"string",
"with",
"some",
"basic",
"information",
"about",
"the",
"request",
".",
"Usually",
"put",
"into",
"the",
"logs",
"."
] | train | https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L106-L108 |
pdyn/httpclient | HttpClientResponse.php | HttpClientResponse.status_type | public function status_type() {
$status_code_type = (!empty($this->statuscode))
? (int)mb_substr($this->statuscode, 0, 1)
: 0;
if ($status_code_type === 1) {
$status_type = 'informational';
} elseif ($status_code_type === 2) {
$status_type = 'success';
} elseif ($status_code_type === 3) {
$status_type = 'redirect';
} elseif ($status_code_type === 4) {
$status_type = 'client_err';
} elseif ($status_code_type === 5) {
$status_type = 'server_err';
} else {
$status_type = 'bad';
}
return $status_type;
} | php | public function status_type() {
$status_code_type = (!empty($this->statuscode))
? (int)mb_substr($this->statuscode, 0, 1)
: 0;
if ($status_code_type === 1) {
$status_type = 'informational';
} elseif ($status_code_type === 2) {
$status_type = 'success';
} elseif ($status_code_type === 3) {
$status_type = 'redirect';
} elseif ($status_code_type === 4) {
$status_type = 'client_err';
} elseif ($status_code_type === 5) {
$status_type = 'server_err';
} else {
$status_type = 'bad';
}
return $status_type;
} | [
"public",
"function",
"status_type",
"(",
")",
"{",
"$",
"status_code_type",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"statuscode",
")",
")",
"?",
"(",
"int",
")",
"mb_substr",
"(",
"$",
"this",
"->",
"statuscode",
",",
"0",
",",
"1",
")",
"... | Get the status type.
@return string The status type. | [
"Get",
"the",
"status",
"type",
"."
] | train | https://github.com/pdyn/httpclient/blob/9714796945db4908605be6f19c31ded1ee813c70/HttpClientResponse.php#L115-L134 |
DavidePastore/paris-model-generator | src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php | ParisGeneratorCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$this->force = $input->getOption('force');
$helper = $this->getHelper('question');
$userQuestion = new Question('User (root): ', 'root');
$passwordQuestion = new Question('Password (): ', '');
$passwordQuestion->setHidden(true);
$passwordQuestion->setHiddenFallback(false);
$hostQuestion = new Question('Host (localhost): ', 'localhost');
$driverQuestion = new Question('Driver (pdo_mysql): ', 'pdo_mysql');
$user = $helper->ask($input, $output, $userQuestion);
$password = $helper->ask($input, $output, $passwordQuestion);
$host = $helper->ask($input, $output, $hostQuestion);
$driver = $helper->ask($input, $output, $driverQuestion);
$connectionParams = array(
'user' => $user,
'password' => $password,
'host' => $host,
'driver' => $driver
);
try {
$conn = $this->createConnection($connectionParams);
$sm = $conn->getSchemaManager();
$databases = $sm->listDatabases();
$question = new ChoiceQuestion(
'Database',
$databases,
0
);
$question->setErrorMessage('Selected database is not valid');
$dbName = $helper->ask($input, $output, $question);
$output->writeln('Chosen database: ' . $dbName);
//Add the dbname property
$connectionParams['dbname'] = $dbName;
$conn = $this->createConnection($connectionParams);
$sm = $conn->getSchemaManager();
$tables = $sm->listTables();
$this->loadConfiguration();
$progress = new ProgressBar($output, count($tables));
$progress->start();
foreach ($tables as $table) {
//$output->writeln($table->getName() . " columns:\n\n");
//Columns
/*
foreach ($table->getColumns() as $column) {
//$output->writeln(' - ' . $column->getName() . ': ' . $column->getType() . "\n");
}
*/
//Foreign keys
$name = $table->getName();
$table = $sm->listTableDetails($name);
//$foreignKeys = $table->getForeignKeys();
//$output->writeln("Foreign keys (" . count($foreignKeys) . ")");
/*
foreach ($foreignKeys as $foreignKey) {
//$output->writeln("\n");
$foreignColumns = $foreignKey->getForeignColumns();
$localColumns = $foreignKey->getLocalColumns();
foreach($foreignColumns as $key => $foreignColumn){
//$output->writeln($foreignKey->getLocalTableName() . "." . $localColumns[$key] . " <=> " . $foreignKey->getForeignTableName() . "." . $foreignColumn . "\n");
}
}
*/
$primaryKeys = $table->getPrimaryKeyColumns();
//$output->writeln("Primary keys (" . count($primaryKeys) . ")");
/*
foreach ($primaryKeys as $primaryKey) {
//$output->writeln("\n" . $primaryKey);
}
*/
//$output->writeln("\n\n");
$this->generateCode($name, reset($primaryKeys));
$progress->advance();
}
$progress->finish();
} catch(\Exception $ex){
$output->writeln('Generator has found the current exception: ');
$output->writeln($ex->getMessage());
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$this->force = $input->getOption('force');
$helper = $this->getHelper('question');
$userQuestion = new Question('User (root): ', 'root');
$passwordQuestion = new Question('Password (): ', '');
$passwordQuestion->setHidden(true);
$passwordQuestion->setHiddenFallback(false);
$hostQuestion = new Question('Host (localhost): ', 'localhost');
$driverQuestion = new Question('Driver (pdo_mysql): ', 'pdo_mysql');
$user = $helper->ask($input, $output, $userQuestion);
$password = $helper->ask($input, $output, $passwordQuestion);
$host = $helper->ask($input, $output, $hostQuestion);
$driver = $helper->ask($input, $output, $driverQuestion);
$connectionParams = array(
'user' => $user,
'password' => $password,
'host' => $host,
'driver' => $driver
);
try {
$conn = $this->createConnection($connectionParams);
$sm = $conn->getSchemaManager();
$databases = $sm->listDatabases();
$question = new ChoiceQuestion(
'Database',
$databases,
0
);
$question->setErrorMessage('Selected database is not valid');
$dbName = $helper->ask($input, $output, $question);
$output->writeln('Chosen database: ' . $dbName);
//Add the dbname property
$connectionParams['dbname'] = $dbName;
$conn = $this->createConnection($connectionParams);
$sm = $conn->getSchemaManager();
$tables = $sm->listTables();
$this->loadConfiguration();
$progress = new ProgressBar($output, count($tables));
$progress->start();
foreach ($tables as $table) {
//$output->writeln($table->getName() . " columns:\n\n");
//Columns
/*
foreach ($table->getColumns() as $column) {
//$output->writeln(' - ' . $column->getName() . ': ' . $column->getType() . "\n");
}
*/
//Foreign keys
$name = $table->getName();
$table = $sm->listTableDetails($name);
//$foreignKeys = $table->getForeignKeys();
//$output->writeln("Foreign keys (" . count($foreignKeys) . ")");
/*
foreach ($foreignKeys as $foreignKey) {
//$output->writeln("\n");
$foreignColumns = $foreignKey->getForeignColumns();
$localColumns = $foreignKey->getLocalColumns();
foreach($foreignColumns as $key => $foreignColumn){
//$output->writeln($foreignKey->getLocalTableName() . "." . $localColumns[$key] . " <=> " . $foreignKey->getForeignTableName() . "." . $foreignColumn . "\n");
}
}
*/
$primaryKeys = $table->getPrimaryKeyColumns();
//$output->writeln("Primary keys (" . count($primaryKeys) . ")");
/*
foreach ($primaryKeys as $primaryKey) {
//$output->writeln("\n" . $primaryKey);
}
*/
//$output->writeln("\n\n");
$this->generateCode($name, reset($primaryKeys));
$progress->advance();
}
$progress->finish();
} catch(\Exception $ex){
$output->writeln('Generator has found the current exception: ');
$output->writeln($ex->getMessage());
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"$",
"this",
"->",
"forc... | (non-PHPdoc)
@see \Symfony\Component\Console\Command\Command::execute() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/DavidePastore/paris-model-generator/blob/cd056dd7a2218b1c56fa17dcc6311e01a2570030/src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php#L74-L179 |
DavidePastore/paris-model-generator | src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php | ParisGeneratorCommand.generateCode | private function generateCode($className, $primaryKey){
$tags = $this->config->getTags();
$class = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) .' model class',
'longDescription' => 'This is a model class generated with DavidePastore\ParisModelGenerator.',
'tags' => $tags
));
$idColumn = new PropertyGenerator('_id_column');
$idColumn
->setStatic(true)
->setDefaultValue($primaryKey);
$table = new PropertyGenerator('_table');
$table
->setStatic(true)
->setDefaultValue($className);
$tableUseShortName = new PropertyGenerator('_table_use_short_name');
$tableUseShortName
->setStatic(true)
->setDefaultValue(true);
$namespace = $this->config->getNamespace();
$extendedClass = '\Model';
if(isset($namespace) && !empty($namespace)){
$class->setNamespaceName($this->config->getNamespace());
}
$class
->setName(ucfirst($className))
->setDocblock($docblock)
->setExtendedClass($extendedClass)
->addProperties(array(
$idColumn,
$table,
$tableUseShortName
));
$file = FileGenerator::fromArray(array(
'classes' => array($class),
'docblock' => DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) . ' class file',
'longDescription' => null,
'tags' => $tags
))
));
$generatedCode = $file->generate();
$directory = $this->config->getDestinationFolder() . $namespace;
if(!file_exists($directory)){
mkdir($directory, 0777, true);
}
$filePath = $directory . "/" . $class->getName() . ".php";
if(file_exists($filePath) && !$this->force){
$helper = $this->getHelper('question');
$realPath = realpath($filePath);
$this->output->writeln("\n");
$question = new ConfirmationQuestion('Do you want to overwrite the file "' . $realPath . '"?', false);
if ($helper->ask($this->input, $this->output, $question)) {
$this->writeInFile($filePath, $generatedCode);
}
}
else {
$this->writeInFile($filePath, $generatedCode);
}
} | php | private function generateCode($className, $primaryKey){
$tags = $this->config->getTags();
$class = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) .' model class',
'longDescription' => 'This is a model class generated with DavidePastore\ParisModelGenerator.',
'tags' => $tags
));
$idColumn = new PropertyGenerator('_id_column');
$idColumn
->setStatic(true)
->setDefaultValue($primaryKey);
$table = new PropertyGenerator('_table');
$table
->setStatic(true)
->setDefaultValue($className);
$tableUseShortName = new PropertyGenerator('_table_use_short_name');
$tableUseShortName
->setStatic(true)
->setDefaultValue(true);
$namespace = $this->config->getNamespace();
$extendedClass = '\Model';
if(isset($namespace) && !empty($namespace)){
$class->setNamespaceName($this->config->getNamespace());
}
$class
->setName(ucfirst($className))
->setDocblock($docblock)
->setExtendedClass($extendedClass)
->addProperties(array(
$idColumn,
$table,
$tableUseShortName
));
$file = FileGenerator::fromArray(array(
'classes' => array($class),
'docblock' => DocBlockGenerator::fromArray(array(
'shortDescription' => ucfirst($className) . ' class file',
'longDescription' => null,
'tags' => $tags
))
));
$generatedCode = $file->generate();
$directory = $this->config->getDestinationFolder() . $namespace;
if(!file_exists($directory)){
mkdir($directory, 0777, true);
}
$filePath = $directory . "/" . $class->getName() . ".php";
if(file_exists($filePath) && !$this->force){
$helper = $this->getHelper('question');
$realPath = realpath($filePath);
$this->output->writeln("\n");
$question = new ConfirmationQuestion('Do you want to overwrite the file "' . $realPath . '"?', false);
if ($helper->ask($this->input, $this->output, $question)) {
$this->writeInFile($filePath, $generatedCode);
}
}
else {
$this->writeInFile($filePath, $generatedCode);
}
} | [
"private",
"function",
"generateCode",
"(",
"$",
"className",
",",
"$",
"primaryKey",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"config",
"->",
"getTags",
"(",
")",
";",
"$",
"class",
"=",
"new",
"ClassGenerator",
"(",
")",
";",
"$",
"docblock",
... | Generate the code for the given className and primaryKey and write it in a file.
@param string $className The class name.
@param string $primaryKey The primary key. | [
"Generate",
"the",
"code",
"for",
"the",
"given",
"className",
"and",
"primaryKey",
"and",
"write",
"it",
"in",
"a",
"file",
"."
] | train | https://github.com/DavidePastore/paris-model-generator/blob/cd056dd7a2218b1c56fa17dcc6311e01a2570030/src/DavidePastore/ParisModelGenerator/ParisGeneratorCommand.php#L204-L282 |
canis-io/yii2-canis-composer | src/templates/advanced/app/models/User.php | User.systemUser | public static function systemUser()
{
$user = self::findOne([self::tableName().'.'.'email' => self::SYSTEM_EMAIL], false);
if (empty($user)) {
$superGroup = Group::find()->disableAccessCheck()->where(['system' => 'super_administrators'])->one();
if (!$superGroup) {
return false;
}
$userClass = self::className();
$user = new $userClass();
$user->scenario = 'creation';
$user->first_name = 'System';
$user->last_name = 'User';
$user->email = self::SYSTEM_EMAIL;
$user->status = static::STATUS_INACTIVE;
$user->password = Yii::$app->security->generateRandomKey();
$user->relationModels = [['parent_object_id' => $superGroup->primaryKey]];
if (!$user->save()) {
\d($user->email);
\d($user->errors);
throw new Exception("Unable to save system user!");
}
}
return $user;
} | php | public static function systemUser()
{
$user = self::findOne([self::tableName().'.'.'email' => self::SYSTEM_EMAIL], false);
if (empty($user)) {
$superGroup = Group::find()->disableAccessCheck()->where(['system' => 'super_administrators'])->one();
if (!$superGroup) {
return false;
}
$userClass = self::className();
$user = new $userClass();
$user->scenario = 'creation';
$user->first_name = 'System';
$user->last_name = 'User';
$user->email = self::SYSTEM_EMAIL;
$user->status = static::STATUS_INACTIVE;
$user->password = Yii::$app->security->generateRandomKey();
$user->relationModels = [['parent_object_id' => $superGroup->primaryKey]];
if (!$user->save()) {
\d($user->email);
\d($user->errors);
throw new Exception("Unable to save system user!");
}
}
return $user;
} | [
"public",
"static",
"function",
"systemUser",
"(",
")",
"{",
"$",
"user",
"=",
"self",
"::",
"findOne",
"(",
"[",
"self",
"::",
"tableName",
"(",
")",
".",
"'.'",
".",
"'email'",
"=>",
"self",
"::",
"SYSTEM_EMAIL",
"]",
",",
"false",
")",
";",
"if",
... | __method_systemUser_description__
@return __return_systemUser_type__ __return_systemUser_description__
@throws Exception __exception_Exception_description__ | [
"__method_systemUser_description__"
] | train | https://github.com/canis-io/yii2-canis-composer/blob/18f19859249c4905fbee8a7ba873025fb35a7c28/src/templates/advanced/app/models/User.php#L32-L57 |
ScaraMVC/Framework | src/Scara/Session/Cookie.php | Cookie.set | public function set($key, $value, $expire = 3600, $path = '/')
{
if ($expire == false) {
setcookie($key, serialize($value), false, $path);
} else {
setcookie($key, serialize($value), time() + $expire, $path);
}
} | php | public function set($key, $value, $expire = 3600, $path = '/')
{
if ($expire == false) {
setcookie($key, serialize($value), false, $path);
} else {
setcookie($key, serialize($value), time() + $expire, $path);
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"3600",
",",
"$",
"path",
"=",
"'/'",
")",
"{",
"if",
"(",
"$",
"expire",
"==",
"false",
")",
"{",
"setcookie",
"(",
"$",
"key",
",",
"serialize",
"(",
"$... | Adds to the session.
@param string $key - Key given to session
@param string $value - Value given to session's $key
@param mixed $expire - Sets expiration of cookie
@param stirng $path - The path the cookie should be set to
@return mixed | [
"Adds",
"to",
"the",
"session",
"."
] | train | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Session/Cookie.php#L32-L39 |
ScaraMVC/Framework | src/Scara/Session/Cookie.php | Cookie.delete | public function delete($key)
{
if ($this->has($key)) {
unset($_COOKIE[$key]);
setcookie($key, '', time() - 3600, '/');
}
} | php | public function delete($key)
{
if ($this->has($key)) {
unset($_COOKIE[$key]);
setcookie($key, '', time() - 3600, '/');
}
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"_COOKIE",
"[",
"$",
"key",
"]",
")",
";",
"setcookie",
"(",
"$",
"key",
",",
"''",
",",
"time"... | {@inheritdoc} | [
"{"
] | train | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Session/Cookie.php#L52-L58 |
ScaraMVC/Framework | src/Scara/Session/Cookie.php | Cookie.flash | public function flash($key, $value = '')
{
if (!empty($value)) {
$this->set($key, $value, false);
} else {
if ($this->has($key)) {
$s = $this->get($key);
$this->delete($key);
return $s;
}
}
} | php | public function flash($key, $value = '')
{
if (!empty($value)) {
$this->set($key, $value, false);
} else {
if ($this->has($key)) {
$s = $this->get($key);
$this->delete($key);
return $s;
}
}
} | [
"public",
"function",
"flash",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"false",
")",
";",
"}",
"e... | {@inheritdoc} | [
"{"
] | train | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Session/Cookie.php#L63-L75 |
wb-crowdfusion/crowdfusion | system/core/classes/nodedb/daos/NodeMetaDAO.php | NodeMetaDAO.incrementMeta | public function incrementMeta(NodeRef $nodeRef, $metaID, $value = 1)
{
$metaID = ltrim($metaID, '#');
$this->NodeEvents->fireNodeEvents(__FUNCTION__, '', $nodeRef, $metaID);
$db = $this->getConnectionForWrite($nodeRef);
$id = $this->getRecordIDFromNodeRef($nodeRef);
// determine the meta storage
$metaDef = $nodeRef->getElement()->getSchema()->getMetaDef($metaID);
$datatype = $metaDef->getDatatype();
$table = $db->quoteIdentifier($this->NodeDBMeta->getMetaTable($nodeRef, $datatype));
$tableid = $this->NodeDBMeta->getPrimaryKey($nodeRef);
$datatypeCol = $this->NodeDBMeta->getMetaDatatypeColumn($datatype);
$value = intval($value);
$newValue = false;
$oldValue = false;
$originalMeta = null;
$maxValue = $this->getMaxIntForDatatype($datatype);
$minValue = $this->getMinIntForDatatype($datatype);
try {
$affectedRows = $db->write("UPDATE {$table} SET {$datatypeCol}Value = LAST_INSERT_ID({$datatypeCol}Value+{$value}) WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}", DatabaseInterface::AFFECTED_ROWS);
if ($affectedRows == 1) {
$newValue = intval($db->readField("SELECT LAST_INSERT_ID()"));
$oldValue = $newValue - $value;
}
} catch (SQLException $e) {
if ($e->getCode() != 22003 || strpos($e->getMessage(), 'Numeric value out of range') === false) {
throw $e;
}
// must ask the DB for its current value
$oldValue = intval($db->readField("SELECT {$datatypeCol}Value FROM {$table} WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}"));
$newValue = $oldValue + $value;
// ensure the new values don't overflow (note that $value can be positive or negative and isn't necessarily 1)
if ($newValue > $maxValue) {
$newValue = $maxValue;
} elseif ($newValue < $minValue) {
$newValue = $minValue;
}
if ($newValue === $oldValue) {
$affectedRows = 1;
} else {
$affectedRows = $db->write("UPDATE {$table} SET {$datatypeCol}Value = {$newValue} WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}", DatabaseInterface::AFFECTED_ROWS);
}
} catch (Exception $e) {
throw $e;
}
// new value didn't get set because the meta record hasn't been created yet.
if ($newValue === false) {
$newValue = $value;
// ensure the new values don't overflow (note that $value can be positive or negative and isn't necessarily 1)
if ($newValue > $maxValue) {
$newValue = $maxValue;
} elseif ($newValue < $minValue) {
$newValue = $minValue;
}
}
if ($affectedRows == 0) {
$affectedRows = $db->write("INSERT INTO {$table} ({$tableid}, Name, {$datatypeCol}Value) Values ({$db->quote($id)}, {$db->quote($metaID)}, {$newValue}) ON DUPLICATE KEY UPDATE {$datatypeCol}Value = LAST_INSERT_ID({$datatypeCol}Value+{$value})", DatabaseInterface::AFFECTED_ROWS);
// new record inserted
if ($affectedRows == 1) {
$metaEvent = 'add';
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = null;
// duplicate key update encountered
} else if ($affectedRows == 2) {
$metaEvent = 'update';
$newValue = intval($db->readField("SELECT LAST_INSERT_ID()"));
$oldValue = $newValue - $value;
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = new Meta($metaID, $oldValue);
$originalMeta->setMetaStorageDatatype($metaDef->Datatype);
} else {
throw new NodeException('Unable to increment meta ID ['.$metaID.'] on record ['.$nodeRef.']');
}
} else {
$metaEvent = 'update';
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = new Meta($metaID, $oldValue);
$originalMeta->setMetaStorageDatatype($metaDef->Datatype);
}
$this->NodeEvents->fireMetaEvents('meta', $metaEvent, $nodeRef, $newMeta, $originalMeta);
} | php | public function incrementMeta(NodeRef $nodeRef, $metaID, $value = 1)
{
$metaID = ltrim($metaID, '#');
$this->NodeEvents->fireNodeEvents(__FUNCTION__, '', $nodeRef, $metaID);
$db = $this->getConnectionForWrite($nodeRef);
$id = $this->getRecordIDFromNodeRef($nodeRef);
// determine the meta storage
$metaDef = $nodeRef->getElement()->getSchema()->getMetaDef($metaID);
$datatype = $metaDef->getDatatype();
$table = $db->quoteIdentifier($this->NodeDBMeta->getMetaTable($nodeRef, $datatype));
$tableid = $this->NodeDBMeta->getPrimaryKey($nodeRef);
$datatypeCol = $this->NodeDBMeta->getMetaDatatypeColumn($datatype);
$value = intval($value);
$newValue = false;
$oldValue = false;
$originalMeta = null;
$maxValue = $this->getMaxIntForDatatype($datatype);
$minValue = $this->getMinIntForDatatype($datatype);
try {
$affectedRows = $db->write("UPDATE {$table} SET {$datatypeCol}Value = LAST_INSERT_ID({$datatypeCol}Value+{$value}) WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}", DatabaseInterface::AFFECTED_ROWS);
if ($affectedRows == 1) {
$newValue = intval($db->readField("SELECT LAST_INSERT_ID()"));
$oldValue = $newValue - $value;
}
} catch (SQLException $e) {
if ($e->getCode() != 22003 || strpos($e->getMessage(), 'Numeric value out of range') === false) {
throw $e;
}
// must ask the DB for its current value
$oldValue = intval($db->readField("SELECT {$datatypeCol}Value FROM {$table} WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}"));
$newValue = $oldValue + $value;
// ensure the new values don't overflow (note that $value can be positive or negative and isn't necessarily 1)
if ($newValue > $maxValue) {
$newValue = $maxValue;
} elseif ($newValue < $minValue) {
$newValue = $minValue;
}
if ($newValue === $oldValue) {
$affectedRows = 1;
} else {
$affectedRows = $db->write("UPDATE {$table} SET {$datatypeCol}Value = {$newValue} WHERE {$tableid} = {$db->quote($id)} AND Name = {$db->quote($metaID)}", DatabaseInterface::AFFECTED_ROWS);
}
} catch (Exception $e) {
throw $e;
}
// new value didn't get set because the meta record hasn't been created yet.
if ($newValue === false) {
$newValue = $value;
// ensure the new values don't overflow (note that $value can be positive or negative and isn't necessarily 1)
if ($newValue > $maxValue) {
$newValue = $maxValue;
} elseif ($newValue < $minValue) {
$newValue = $minValue;
}
}
if ($affectedRows == 0) {
$affectedRows = $db->write("INSERT INTO {$table} ({$tableid}, Name, {$datatypeCol}Value) Values ({$db->quote($id)}, {$db->quote($metaID)}, {$newValue}) ON DUPLICATE KEY UPDATE {$datatypeCol}Value = LAST_INSERT_ID({$datatypeCol}Value+{$value})", DatabaseInterface::AFFECTED_ROWS);
// new record inserted
if ($affectedRows == 1) {
$metaEvent = 'add';
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = null;
// duplicate key update encountered
} else if ($affectedRows == 2) {
$metaEvent = 'update';
$newValue = intval($db->readField("SELECT LAST_INSERT_ID()"));
$oldValue = $newValue - $value;
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = new Meta($metaID, $oldValue);
$originalMeta->setMetaStorageDatatype($metaDef->Datatype);
} else {
throw new NodeException('Unable to increment meta ID ['.$metaID.'] on record ['.$nodeRef.']');
}
} else {
$metaEvent = 'update';
$newMeta = new Meta($metaID, $newValue);
$newMeta->setMetaStorageDatatype($metaDef->Datatype);
$originalMeta = new Meta($metaID, $oldValue);
$originalMeta->setMetaStorageDatatype($metaDef->Datatype);
}
$this->NodeEvents->fireMetaEvents('meta', $metaEvent, $nodeRef, $newMeta, $originalMeta);
} | [
"public",
"function",
"incrementMeta",
"(",
"NodeRef",
"$",
"nodeRef",
",",
"$",
"metaID",
",",
"$",
"value",
"=",
"1",
")",
"{",
"$",
"metaID",
"=",
"ltrim",
"(",
"$",
"metaID",
",",
"'#'",
")",
";",
"$",
"this",
"->",
"NodeEvents",
"->",
"fireNodeE... | @param NodeRef $nodeRef
@param $metaID
@param int $value
@throws NodeException
@throws SQLException
@throws Exception | [
"@param",
"NodeRef",
"$nodeRef",
"@param",
"$metaID",
"@param",
"int",
"$value"
] | train | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/daos/NodeMetaDAO.php#L526-L629 |
spryker/shopping-list-data-import | src/Spryker/Zed/ShoppingListDataImport/Business/ShoppingListDataImportStep/CompanyUserKeyToIdCompanyUserStep.php | CompanyUserKeyToIdCompanyUserStep.execute | public function execute(DataSetInterface $dataSet): void
{
$companyUserKey = $dataSet[ShoppingListCompanyUserDataSetInterface::COLUMN_COMPANY_USER_KEY];
if (!isset($this->idCompanyUserCache[$companyUserKey])) {
$companyUserQuery = new SpyCompanyUserQuery();
$idCompanyUser = $companyUserQuery
->select([SpyCompanyUserTableMap::COL_ID_COMPANY_USER])
->findOneByKey($companyUserKey);
if (!$idCompanyUser) {
throw new EntityNotFoundException(sprintf('Could not find company user by key "%s"', $companyUserKey));
}
$this->idCompanyUserCache[$companyUserKey] = $idCompanyUser;
}
$dataSet[ShoppingListCompanyUserDataSetInterface::ID_COMPANY_USER] = $this->idCompanyUserCache[$companyUserKey];
} | php | public function execute(DataSetInterface $dataSet): void
{
$companyUserKey = $dataSet[ShoppingListCompanyUserDataSetInterface::COLUMN_COMPANY_USER_KEY];
if (!isset($this->idCompanyUserCache[$companyUserKey])) {
$companyUserQuery = new SpyCompanyUserQuery();
$idCompanyUser = $companyUserQuery
->select([SpyCompanyUserTableMap::COL_ID_COMPANY_USER])
->findOneByKey($companyUserKey);
if (!$idCompanyUser) {
throw new EntityNotFoundException(sprintf('Could not find company user by key "%s"', $companyUserKey));
}
$this->idCompanyUserCache[$companyUserKey] = $idCompanyUser;
}
$dataSet[ShoppingListCompanyUserDataSetInterface::ID_COMPANY_USER] = $this->idCompanyUserCache[$companyUserKey];
} | [
"public",
"function",
"execute",
"(",
"DataSetInterface",
"$",
"dataSet",
")",
":",
"void",
"{",
"$",
"companyUserKey",
"=",
"$",
"dataSet",
"[",
"ShoppingListCompanyUserDataSetInterface",
"::",
"COLUMN_COMPANY_USER_KEY",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
... | @param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet
@throws \Spryker\Zed\DataImport\Business\Exception\EntityNotFoundException
@return void | [
"@param",
"\\",
"Spryker",
"\\",
"Zed",
"\\",
"DataImport",
"\\",
"Business",
"\\",
"Model",
"\\",
"DataSet",
"\\",
"DataSetInterface",
"$dataSet"
] | train | https://github.com/spryker/shopping-list-data-import/blob/6313fc39e8ee79a08f7b97d81da7f4056c066674/src/Spryker/Zed/ShoppingListDataImport/Business/ShoppingListDataImportStep/CompanyUserKeyToIdCompanyUserStep.php#L31-L48 |
graze/data-node | src/NodeCollection.php | NodeCollection.apply | public function apply(callable $fn)
{
foreach ($this->items as &$item) {
$out = call_user_func($fn, $item);
if (isset($out) && ($out instanceof NodeInterface)) {
$item = $out;
}
}
return $this;
} | php | public function apply(callable $fn)
{
foreach ($this->items as &$item) {
$out = call_user_func($fn, $item);
if (isset($out) && ($out instanceof NodeInterface)) {
$item = $out;
}
}
return $this;
} | [
"public",
"function",
"apply",
"(",
"callable",
"$",
"fn",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"&",
"$",
"item",
")",
"{",
"$",
"out",
"=",
"call_user_func",
"(",
"$",
"fn",
",",
"$",
"item",
")",
";",
"if",
"(",
"isset",
... | @param callable $fn
@return $this | [
"@param",
"callable",
"$fn"
] | train | https://github.com/graze/data-node/blob/e604d8062b1e18046f23c6dc20341b368e88697e/src/NodeCollection.php#L46-L56 |
graze/data-node | src/NodeCollection.php | NodeCollection.first | public function first(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? reset($this->items) : $default;
}
foreach ($this->getIterator() as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
} | php | public function first(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? reset($this->items) : $default;
}
foreach ($this->getIterator() as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
} | [
"public",
"function",
"first",
"(",
"callable",
"$",
"fn",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
"?",
"re... | Retrieve the first element that matches the optional callback
@param callable|null $fn
@param mixed|null $default
@return mixed|null | [
"Retrieve",
"the",
"first",
"element",
"that",
"matches",
"the",
"optional",
"callback"
] | train | https://github.com/graze/data-node/blob/e604d8062b1e18046f23c6dc20341b368e88697e/src/NodeCollection.php#L92-L105 |
graze/data-node | src/NodeCollection.php | NodeCollection.last | public function last(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? end($this->items) : $default;
}
foreach (array_reverse($this->items) as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
} | php | public function last(callable $fn = null, $default = null)
{
if (is_null($fn)) {
return count($this->items) > 0 ? end($this->items) : $default;
}
foreach (array_reverse($this->items) as $value) {
if (call_user_func($fn, $value)) {
return $value;
}
}
return $default;
} | [
"public",
"function",
"last",
"(",
"callable",
"$",
"fn",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"items",
")",
">",
"0",
"?",
"end... | Receive the last element that matches the optional callback
@param callable|null $fn
@param mixed|null $default
@return mixed|null | [
"Receive",
"the",
"last",
"element",
"that",
"matches",
"the",
"optional",
"callback"
] | train | https://github.com/graze/data-node/blob/e604d8062b1e18046f23c6dc20341b368e88697e/src/NodeCollection.php#L115-L128 |
Kris-Kuiper/sFire-Framework | src/Validator/File/Rules/Minwidth.php | Minwidth.isValid | public function isValid() {
$params = $this -> getParameters();
$file = $this -> getFile();
if(false === isset($params[0])) {
return trigger_error(sprintf('Missing argument 1 for %s', __METHOD__), E_USER_ERROR);
}
if(false === ('-' . intval($params[0]) == '-' . $params[0])) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($params[0])), E_USER_ERROR);
}
$dimensions = @getimagesize($file['tmp_name']);
if(true === is_array($dimensions)) {
if($dimensions[0] >= $params[0]) {
return true;
}
}
return false;
} | php | public function isValid() {
$params = $this -> getParameters();
$file = $this -> getFile();
if(false === isset($params[0])) {
return trigger_error(sprintf('Missing argument 1 for %s', __METHOD__), E_USER_ERROR);
}
if(false === ('-' . intval($params[0]) == '-' . $params[0])) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($params[0])), E_USER_ERROR);
}
$dimensions = @getimagesize($file['tmp_name']);
if(true === is_array($dimensions)) {
if($dimensions[0] >= $params[0]) {
return true;
}
}
return false;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParameters",
"(",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
")",
";",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"params",
"[",
"0"... | Check if rule passes
@return boolean | [
"Check",
"if",
"rule",
"passes"
] | train | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/File/Rules/Minwidth.php#L33-L56 |
tdebatty/php-noorm | src/noorm/Persistent.php | Persistent.One | public static function One($id) {
$class = get_called_class();
if (! isset(self::$refs[$class][$id])) {
$file = self::File($id);
$obj = unserialize(file_get_contents($file));
self::$refs[$class][$id] = $obj;
}
return self::$refs[$class][$id];
} | php | public static function One($id) {
$class = get_called_class();
if (! isset(self::$refs[$class][$id])) {
$file = self::File($id);
$obj = unserialize(file_get_contents($file));
self::$refs[$class][$id] = $obj;
}
return self::$refs[$class][$id];
} | [
"public",
"static",
"function",
"One",
"(",
"$",
"id",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"refs",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"... | Fetch one saved object by id
@param int $id
@return Persistent | [
"Fetch",
"one",
"saved",
"object",
"by",
"id"
] | train | https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L59-L69 |
tdebatty/php-noorm | src/noorm/Persistent.php | Persistent.SetDirectory | public static function SetDirectory($dir) {
if (!is_dir($dir)) {
if (!@\mkdir($dir, 0700, TRUE)) {
throw new \InvalidArgumentException("dir $dir does not exist and could not be created");
}
}
self::$DIR = realpath($dir);
} | php | public static function SetDirectory($dir) {
if (!is_dir($dir)) {
if (!@\mkdir($dir, 0700, TRUE)) {
throw new \InvalidArgumentException("dir $dir does not exist and could not be created");
}
}
self::$DIR = realpath($dir);
} | [
"public",
"static",
"function",
"SetDirectory",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"!",
"@",
"\\",
"mkdir",
"(",
"$",
"dir",
",",
"0700",
",",
"TRUE",
")",
")",
"{",
"throw",
"new",
... | Set directory where all persistent objects and relations will be saved.
@param String $dir
@throws \InvalidArgumentException | [
"Set",
"directory",
"where",
"all",
"persistent",
"objects",
"and",
"relations",
"will",
"be",
"saved",
"."
] | train | https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L95-L103 |
tdebatty/php-noorm | src/noorm/Persistent.php | Persistent.Save | public function Save() {
if (!$this->Validate()) {
throw new \Exception("Validation failed");
}
$file = self::File($this->id);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
file_put_contents($file, serialize($this), LOCK_EX);
return $this;
} | php | public function Save() {
if (!$this->Validate()) {
throw new \Exception("Validation failed");
}
$file = self::File($this->id);
if (!is_dir(dirname($file))) {
mkdir(dirname($file), 0755, true);
}
file_put_contents($file, serialize($this), LOCK_EX);
return $this;
} | [
"public",
"function",
"Save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Validate",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Validation failed\"",
")",
";",
"}",
"$",
"file",
"=",
"self",
"::",
"File",
"(",
"$",
"this"... | Save this object.
@return boolean true on success | [
"Save",
"this",
"object",
"."
] | train | https://github.com/tdebatty/php-noorm/blob/ba33e2f0efaed71693c3013e73315d3c019d7f05/src/noorm/Persistent.php#L187-L199 |
Topolis/Filter | src/Types/StripFilter.php | StripFilter.filter | public function filter($value) {
if($value === null && $this->options["preserve_null"] )
return null;
return strip_tags($value, $this->options["allowable_tags"]);
} | php | public function filter($value) {
if($value === null && $this->options["preserve_null"] )
return null;
return strip_tags($value, $this->options["allowable_tags"]);
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
"&&",
"$",
"this",
"->",
"options",
"[",
"\"preserve_null\"",
"]",
")",
"return",
"null",
";",
"return",
"strip_tags",
"(",
"$",
"value",
",",
"$",
"... | execute the filter on a value
@param mixed $value
@return mixed | [
"execute",
"the",
"filter",
"on",
"a",
"value"
] | train | https://github.com/Topolis/Filter/blob/6208a6270490c39f028248dc99f21b3e816e388b/src/Types/StripFilter.php#L44-L50 |
Innmind/Compose | src/Definition/Service/Argument/Primitive.php | Primitive.resolve | public function resolve(
StreamInterface $built,
Services $services
): StreamInterface {
return $built->add($this->value);
} | php | public function resolve(
StreamInterface $built,
Services $services
): StreamInterface {
return $built->add($this->value);
} | [
"public",
"function",
"resolve",
"(",
"StreamInterface",
"$",
"built",
",",
"Services",
"$",
"services",
")",
":",
"StreamInterface",
"{",
"return",
"$",
"built",
"->",
"add",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/Innmind/Compose/blob/1a833d7ba2f6248e9c472c00cd7aca041c1a2ba9/src/Definition/Service/Argument/Primitive.php#L35-L40 |
NukaCode/core | src/NukaCode/Core/View/Path.php | Path.getPrefixName | protected function getPrefixName($method)
{
$prefix = $this->route->getCurrentRoute()->getPrefix();
$prefix = str_replace('/', '.', $prefix);
$prefix = preg_replace('/\b\.' . $method . '\b/', '', $prefix);
$prefix = preg_replace('/\b' . $method . '\.\b/', '', $prefix);
return $prefix;
} | php | protected function getPrefixName($method)
{
$prefix = $this->route->getCurrentRoute()->getPrefix();
$prefix = str_replace('/', '.', $prefix);
$prefix = preg_replace('/\b\.' . $method . '\b/', '', $prefix);
$prefix = preg_replace('/\b' . $method . '\.\b/', '', $prefix);
return $prefix;
} | [
"protected",
"function",
"getPrefixName",
"(",
"$",
"method",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"route",
"->",
"getCurrentRoute",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"prefix",
"=",
"str_replace",
"(",
"'/'",
",",
"'.'",
",",... | @param string $method
@return string | [
"@param",
"string",
"$method"
] | train | https://github.com/NukaCode/core/blob/75b20903fb068a7df22cdec34ae729279fbaab3c/src/NukaCode/Core/View/Path.php#L111-L119 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.extensionIdentifier | public static function extensionIdentifier(string $extensionKey): string {
$extensionIdentifier = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
$extensionIdentifier = mb_strtolower($extensionIdentifier);
return $extensionIdentifier;
} | php | public static function extensionIdentifier(string $extensionKey): string {
$extensionIdentifier = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
$extensionIdentifier = mb_strtolower($extensionIdentifier);
return $extensionIdentifier;
} | [
"public",
"static",
"function",
"extensionIdentifier",
"(",
"string",
"$",
"extensionKey",
")",
":",
"string",
"{",
"$",
"extensionIdentifier",
"=",
"GeneralUtility",
"::",
"underscoredToUpperCamelCase",
"(",
"$",
"extensionKey",
")",
";",
"$",
"extensionIdentifier",
... | Gets an extension identifier from an extension key.
@param string $extensionKey The extension key
@return string The extension identifier | [
"Gets",
"an",
"extension",
"identifier",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L18-L23 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.extensionSignature | public static function extensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
$namespace = GeneralUtility::underscoredToUpperCamelCase($namespace);
$extensionKey = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
return "${namespace}${separator}${extensionKey}";
} | php | public static function extensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
$namespace = GeneralUtility::underscoredToUpperCamelCase($namespace);
$extensionKey = GeneralUtility::underscoredToUpperCamelCase($extensionKey);
return "${namespace}${separator}${extensionKey}";
} | [
"public",
"static",
"function",
"extensionSignature",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"separator",
"=",
"'.'",
")",
":",
"string",
"{",
"$",
"namespace",
"=",
"GeneralUtility",
"::",
"underscoredToUpperCam... | Gets an extension signature from a namespace and extension key.
@param string $namespace The namespace
@param string $extensionKey The extension key
@param string $separator The optional separator, defaults to `.`
@return string The extension signature | [
"Gets",
"an",
"extension",
"signature",
"from",
"a",
"namespace",
"and",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L43-L48 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getExtensionSignature | public static function getExtensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
return self::extensionSignature($namespace, $extensionKey, $separator);
} | php | public static function getExtensionSignature(string $namespace, string $extensionKey, string $separator = '.'): string {
return self::extensionSignature($namespace, $extensionKey, $separator);
} | [
"public",
"static",
"function",
"getExtensionSignature",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"separator",
"=",
"'.'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"extensionSignature",
"(",
"$",
"namespa... | Alias for the `extensionSignature` function.
@param string $namespace The namespace
@param string $extensionKey The extension key
@param string $separator The optional separator, defaults to `.`
@return string The extension signature | [
"Alias",
"for",
"the",
"extensionSignature",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L58-L60 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.locallang | public static function locallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
$languageFolder = self::languageFolder($extensionKey, $prefix);
return "${languageFolder}/${fileName}${separator}";
} | php | public static function locallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
$languageFolder = self::languageFolder($extensionKey, $prefix);
return "${languageFolder}/${fileName}${separator}";
} | [
"public",
"static",
"function",
"locallang",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"fileName",
"=",
"'locallang.xlf'",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
",",
"string",
"$",
"separator",
"=",
"':'",
")",
":",
"string",
"{",
... | Gets the locallang file from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional file name of the locallang file, defaults to `locallang.xlf`
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@param string $separator The optional separator, defaults to `:`
@return string The locallang file | [
"Gets",
"the",
"locallang",
"file",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L71-L75 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getLocallang | public static function getLocallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
return self::locallang($extensionKey, $fileName, $prefix, $separator);
} | php | public static function getLocallang(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
return self::locallang($extensionKey, $fileName, $prefix, $separator);
} | [
"public",
"static",
"function",
"getLocallang",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"fileName",
"=",
"'locallang.xlf'",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
",",
"string",
"$",
"separator",
"=",
"':'",
")",
":",
"string",
"{",... | Alias for the `locallang` function.
@param string $extensionKey The extension key
@param string $prefix The optional file name of the locallang file, defaults to `locallang.xlf`
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@param string $separator The optional separator, defaults to `:`
@return string The locallang file | [
"Alias",
"for",
"the",
"locallang",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L86-L88 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.lll | public static function lll(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
return self::locallang($extensionKey, $fileName, $prefix, $separator);
} | php | public static function lll(string $extensionKey, string $fileName = 'locallang.xlf', string $prefix = 'LLL:EXT:', string $separator = ':'): string {
return self::locallang($extensionKey, $fileName, $prefix, $separator);
} | [
"public",
"static",
"function",
"lll",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"fileName",
"=",
"'locallang.xlf'",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
",",
"string",
"$",
"separator",
"=",
"':'",
")",
":",
"string",
"{",
"retur... | Alias for the `locallang` function.
@param string $extensionKey The extension key
@param string $prefix The optional file name of the locallang file, defaults to `locallang.xlf`
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@param string $separator The optional separator, defaults to `:`
@return string The locallang file | [
"Alias",
"for",
"the",
"locallang",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L99-L101 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getConfigurationFolder | public static function getConfigurationFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::configurationFolder($extensionKey, $prefix);
} | php | public static function getConfigurationFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::configurationFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getConfigurationFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"configurationFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
... | Alias for the `configurationFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The configuration folder | [
"Alias",
"for",
"the",
"configurationFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L121-L123 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.flexFormsFolder | public static function flexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
$configurationFolder = self::configurationFolder($extensionKey, $prefix);
return "${configurationFolder}/FlexForms";
} | php | public static function flexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
$configurationFolder = self::configurationFolder($extensionKey, $prefix);
return "${configurationFolder}/FlexForms";
} | [
"public",
"static",
"function",
"flexFormsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"$",
"configurationFolder",
"=",
"self",
"::",
"configurationFolder",
"(",
"$",
"extensionKey",
",",... | Gets the FlexForms folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The FlexForms folder | [
"Gets",
"the",
"FlexForms",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L132-L136 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getFlexFormsFolder | public static function getFlexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::flexFormsFolder($extensionKey, $prefix);
} | php | public static function getFlexFormsFolder(string $extensionKey, string $prefix = 'FILE:EXT:'): string {
return self::flexFormsFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getFlexFormsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'FILE:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"flexFormsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
... | Alias for the `flexFormsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `FILE:EXT:`
@return string The FlexForms folder | [
"Alias",
"for",
"the",
"flexFormsFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L145-L147 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getResourcesFolder | public static function getResourcesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::resourcesFolder($extensionKey, $prefix);
} | php | public static function getResourcesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::resourcesFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getResourcesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",... | Alias for the `resourcesFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The resources folder | [
"Alias",
"for",
"the",
"resourcesFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L167-L169 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.privateFolder | public static function privateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Private";
} | php | public static function privateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Private";
} | [
"public",
"static",
"function",
"privateFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"resourcesFolder",
"=",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"pref... | Gets the private folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The private folder | [
"Gets",
"the",
"private",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L178-L182 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getPrivateFolder | public static function getPrivateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::privateFolder($extensionKey, $prefix);
} | php | public static function getPrivateFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::privateFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getPrivateFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"privateFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"... | Alias for the `privateFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The private folder | [
"Alias",
"for",
"the",
"privateFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L191-L193 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.languageFolder | public static function languageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$privateFolder = self::privateFolder($extensionKey, $prefix);
return "${privateFolder}/Language";
} | php | public static function languageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$privateFolder = self::privateFolder($extensionKey, $prefix);
return "${privateFolder}/Language";
} | [
"public",
"static",
"function",
"languageFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"privateFolder",
"=",
"self",
"::",
"privateFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix"... | Gets the language folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The language folder | [
"Gets",
"the",
"language",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L202-L206 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getLanguageFolder | public static function getLanguageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
} | php | public static function getLanguageFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getLanguageFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"languageFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
... | Alias for the `languageFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The language folder | [
"Alias",
"for",
"the",
"languageFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L215-L217 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.locallangFolder | public static function locallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
} | php | public static function locallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::languageFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"locallangFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"languageFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",... | Gets the locallang folder from an extension key.
Alias for the `languageFolder` function with `LLL:EXT:` as prefix.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@return string The locallang folder | [
"Gets",
"the",
"locallang",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L228-L230 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getLocallangFolder | public static function getLocallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::locallangFolder($extensionKey, $prefix);
} | php | public static function getLocallangFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::locallangFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getLocallangFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"locallangFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
... | Alias for the `locallangFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@return string The locallang folder | [
"Alias",
"for",
"the",
"locallangFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L239-L241 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.lllFolder | public static function lllFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::locallangFolder($extensionKey, $prefix);
} | php | public static function lllFolder(string $extensionKey, string $prefix = 'LLL:EXT:'): string {
return self::locallangFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"lllFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'LLL:EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"locallangFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}... | Alias for the `locallangFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `LLL:EXT:`
@return string The locallang folder | [
"Alias",
"for",
"the",
"locallangFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L250-L252 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.publicFolder | public static function publicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Public";
} | php | public static function publicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$resourcesFolder = self::resourcesFolder($extensionKey, $prefix);
return "${resourcesFolder}/Public";
} | [
"public",
"static",
"function",
"publicFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"resourcesFolder",
"=",
"self",
"::",
"resourcesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefi... | Gets the public folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The public folder | [
"Gets",
"the",
"public",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L261-L265 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getPublicFolder | public static function getPublicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::publicFolder($extensionKey, $prefix);
} | php | public static function getPublicFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::publicFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getPublicFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"... | Alias for the `publicFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The public folder | [
"Alias",
"for",
"the",
"publicFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L274-L276 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.assetsFolder | public static function assetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Assets";
} | php | public static function assetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Assets";
} | [
"public",
"static",
"function",
"assetsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
... | Gets the assets folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The assets folder | [
"Gets",
"the",
"assets",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L285-L289 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getAssetsFolder | public static function getAssetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::assetsFolder($extensionKey, $prefix);
} | php | public static function getAssetsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::assetsFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getAssetsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"assetsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"... | Alias for the `assetsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The assets folder | [
"Alias",
"for",
"the",
"assetsFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L298-L300 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.iconsFolder | public static function iconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Icons";
} | php | public static function iconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Icons";
} | [
"public",
"static",
"function",
"iconsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
"... | Gets the icons folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The icons folder | [
"Gets",
"the",
"icons",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L309-L313 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getIconsFolder | public static function getIconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::iconsFolder($extensionKey, $prefix);
} | php | public static function getIconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::iconsFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getIconsFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"iconsFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"}"
] | Alias for the `iconsFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The icons folder | [
"Alias",
"for",
"the",
"iconsFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L322-L324 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.placeholdersFolder | public static function placeholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Placeholders";
} | php | public static function placeholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Placeholders";
} | [
"public",
"static",
"function",
"placeholdersFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefi... | Gets the placeholders folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The placeholders folder | [
"Gets",
"the",
"placeholders",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L333-L337 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getPlaceholdersFolder | public static function getPlaceholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::placeholdersFolder($extensionKey, $prefix);
} | php | public static function getPlaceholdersFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::placeholdersFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getPlaceholdersFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"placeholdersFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
... | Alias for the `placeholdersFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The placeholders folder | [
"Alias",
"for",
"the",
"placeholdersFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L346-L348 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.samplesFolder | public static function samplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Samples";
} | php | public static function samplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
$publicFolder = self::publicFolder($extensionKey, $prefix);
return "${publicFolder}/Samples";
} | [
"public",
"static",
"function",
"samplesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"$",
"publicFolder",
"=",
"self",
"::",
"publicFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
... | Gets the samples folder from an extension key.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The samples folder | [
"Gets",
"the",
"samples",
"folder",
"from",
"an",
"extension",
"key",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L357-L361 |
t3v/t3v_core | Classes/Utility/ExtensionUtility.php | ExtensionUtility.getSamplesFolder | public static function getSamplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::samplesFolder($extensionKey, $prefix);
} | php | public static function getSamplesFolder(string $extensionKey, string $prefix = 'EXT:'): string {
return self::samplesFolder($extensionKey, $prefix);
} | [
"public",
"static",
"function",
"getSamplesFolder",
"(",
"string",
"$",
"extensionKey",
",",
"string",
"$",
"prefix",
"=",
"'EXT:'",
")",
":",
"string",
"{",
"return",
"self",
"::",
"samplesFolder",
"(",
"$",
"extensionKey",
",",
"$",
"prefix",
")",
";",
"... | Alias for the `samplesFolder` function.
@param string $extensionKey The extension key
@param string $prefix The optional prefix, defaults to `EXT:`
@return string The samples folder | [
"Alias",
"for",
"the",
"samplesFolder",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Utility/ExtensionUtility.php#L370-L372 |
sil-project/StockBundle | src/Domain/Entity/Location.php | Location.addChild | public function addChild(Location $location): void
{
if ($this->hasChild($location)) {
throw new InvalidArgumentException(
'The same Location cannot be added twice');
}
$location->setWarehouse(null);
$location->setParent($this);
$this->addTreeChild($location);
} | php | public function addChild(Location $location): void
{
if ($this->hasChild($location)) {
throw new InvalidArgumentException(
'The same Location cannot be added twice');
}
$location->setWarehouse(null);
$location->setParent($this);
$this->addTreeChild($location);
} | [
"public",
"function",
"addChild",
"(",
"Location",
"$",
"location",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"hasChild",
"(",
"$",
"location",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The same Location cannot be added twice'"... | @param Location $location
@throws InvalidArgumentException | [
"@param",
"Location",
"$location"
] | train | https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Domain/Entity/Location.php#L244-L255 |
sil-project/StockBundle | src/Domain/Entity/Location.php | Location.removeChild | public function removeChild(Location $location): void
{
if (!$this->hasChild($location)) {
throw new InvalidArgumentException(
'The Location is not a child and cannot be removed from there');
}
$location->setParent(null);
$this->getChildren()->removeElement($location);
} | php | public function removeChild(Location $location): void
{
if (!$this->hasChild($location)) {
throw new InvalidArgumentException(
'The Location is not a child and cannot be removed from there');
}
$location->setParent(null);
$this->getChildren()->removeElement($location);
} | [
"public",
"function",
"removeChild",
"(",
"Location",
"$",
"location",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasChild",
"(",
"$",
"location",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The Location is not a child and... | @param Location $location
@throws InvalidArgumentException | [
"@param",
"Location",
"$location"
] | train | https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Domain/Entity/Location.php#L262-L270 |
sil-project/StockBundle | src/Domain/Entity/Location.php | Location.hasStockUnit | public function hasStockUnit(StockUnit $unit): bool
{
if ($this->hasOwnedStockUnit($unit)) {
return true;
}
foreach ($this->getChildren() as $child) {
if ($child->hasStockUnit($unit)) {
return true;
}
}
return false;
} | php | public function hasStockUnit(StockUnit $unit): bool
{
if ($this->hasOwnedStockUnit($unit)) {
return true;
}
foreach ($this->getChildren() as $child) {
if ($child->hasStockUnit($unit)) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasStockUnit",
"(",
"StockUnit",
"$",
"unit",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOwnedStockUnit",
"(",
"$",
"unit",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getChildren"... | @param StockUnit $unit
@return bool | [
"@param",
"StockUnit",
"$unit"
] | train | https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Domain/Entity/Location.php#L285-L298 |
sil-project/StockBundle | src/Domain/Entity/Location.php | Location.addStockUnit | public function addStockUnit(StockUnit $unit): void
{
if ($this->hasStockUnit($unit)) {
throw new InvalidArgumentException(
'The same StockUnit cannot be added twice');
}
$this->stockUnits->add($unit);
} | php | public function addStockUnit(StockUnit $unit): void
{
if ($this->hasStockUnit($unit)) {
throw new InvalidArgumentException(
'The same StockUnit cannot be added twice');
}
$this->stockUnits->add($unit);
} | [
"public",
"function",
"addStockUnit",
"(",
"StockUnit",
"$",
"unit",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"hasStockUnit",
"(",
"$",
"unit",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The same StockUnit cannot be added twice... | @param StockUnit $unit
@throws InvalidArgumentException | [
"@param",
"StockUnit",
"$unit"
] | train | https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Domain/Entity/Location.php#L315-L323 |
ciims/ciims-modules-dashboard | components/CiiDashboardController.php | CiiDashboardController.getAsset | public function getAsset($dist=false)
{
return Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('application.modules.dashboard.assets'), true, -1, YII_DEBUG);
} | php | public function getAsset($dist=false)
{
return Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('application.modules.dashboard.assets'), true, -1, YII_DEBUG);
} | [
"public",
"function",
"getAsset",
"(",
"$",
"dist",
"=",
"false",
")",
"{",
"return",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
"->",
"publish",
"(",
"YiiBase",
"::",
"getPathOfAlias",
"(",
"'application.modules.dashboard.assets'",
")",
",",
"true",
... | Retrieve assetManager from anywhere without having to instatiate this code
@return CAssetManager | [
"Retrieve",
"assetManager",
"from",
"anywhere",
"without",
"having",
"to",
"instatiate",
"this",
"code"
] | train | https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/components/CiiDashboardController.php#L12-L15 |
ciims/ciims-modules-dashboard | components/CiiDashboardController.php | CiiDashboardController.beforeAction | public function beforeAction($action)
{
// Redirect to SSL if this is set in the dashboard
if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false))
$this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri);
Yii::app()->setTheme(NULL);
return parent::beforeAction($action);
} | php | public function beforeAction($action)
{
// Redirect to SSL if this is set in the dashboard
if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false))
$this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri);
Yii::app()->setTheme(NULL);
return parent::beforeAction($action);
} | [
"public",
"function",
"beforeAction",
"(",
"$",
"action",
")",
"{",
"// Redirect to SSL if this is set in the dashboard",
"if",
"(",
"!",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"isSecureConnection",
"&&",
"Cii",
"::",
"getConfig",
"(",... | Before action method
@param CAction $action The aciton
@return boolean | [
"Before",
"action",
"method"
] | train | https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/components/CiiDashboardController.php#L22-L30 |
ciims/ciims-modules-dashboard | components/CiiDashboardController.php | CiiDashboardController.actionError | public function actionError()
{
if (Yii::app()->user->isGuest)
return $this->redirect($this->createUrl('/login?next=' . Yii::app()->request->requestUri));
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', array('error' => $error));
}
else
$this->redirect($this->createUrl('/error/403'));
} | php | public function actionError()
{
if (Yii::app()->user->isGuest)
return $this->redirect($this->createUrl('/login?next=' . Yii::app()->request->requestUri));
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', array('error' => $error));
}
else
$this->redirect($this->createUrl('/error/403'));
} | [
"public",
"function",
"actionError",
"(",
")",
"{",
"if",
"(",
"Yii",
"::",
"app",
"(",
")",
"->",
"user",
"->",
"isGuest",
")",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"createUrl",
"(",
"'/login?next='",
".",
"Yii",
"::",
"a... | Handles errors | [
"Handles",
"errors"
] | train | https://github.com/ciims/ciims-modules-dashboard/blob/94b89239e9ee34ac3b9c398e8d1ba67a08c68c11/components/CiiDashboardController.php#L55-L69 |
pluf/discount | src/Discount/Engine/SpecialPercent.php | Discount_Engine_SpecialPercent.getPrice | public function getPrice($price, $discount, $request)
{
if(!$this->isValid($discount, $request))
throw new Discount_Exception_InvalidDiscount();
$newPrice = $price - ($price * $discount->off_value / 100);
return $newPrice;
} | php | public function getPrice($price, $discount, $request)
{
if(!$this->isValid($discount, $request))
throw new Discount_Exception_InvalidDiscount();
$newPrice = $price - ($price * $discount->off_value / 100);
return $newPrice;
} | [
"public",
"function",
"getPrice",
"(",
"$",
"price",
",",
"$",
"discount",
",",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
"$",
"discount",
",",
"$",
"request",
")",
")",
"throw",
"new",
"Discount_Exception_InvalidDiscou... | Compute new price after use given discount.
@param int $price
@param Discount_Discount $discount
@param Pluf_HTTP_Request $request | [
"Compute",
"new",
"price",
"after",
"use",
"given",
"discount",
"."
] | train | https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Engine/SpecialPercent.php#L13-L19 |
pluf/discount | src/Discount/Engine/SpecialPercent.php | Discount_Engine_SpecialPercent.validate | public function validate($discount, $request)
{
// Check user
$currentUser = $request->user;
if ($currentUser->id !== $discount->get_user()->id) {
return Discount_Engine::VALIDATION_CODE_NOT_OWNED;
}
// Check expiration date
if ($discount->valid_day != NULL) {
$now = strtotime(date("Y-m-d H:i:s"));
$start = strtotime($discount->creation_dtime);
$validDay = ' +' . $discount->valid_day . ' day';
$validDateTime = strtotime($validDay, $start);
if ($validDateTime < $now)
return Discount_Engine::VALIDATION_CODE_EXPIRED;
}
// Check remain count
if ($discount->remain_count <= 0) {
return Discount_Engine::VALIDATION_CODE_USED;
}
return Discount_Engine::VALIDATION_CODE_VALID;
} | php | public function validate($discount, $request)
{
// Check user
$currentUser = $request->user;
if ($currentUser->id !== $discount->get_user()->id) {
return Discount_Engine::VALIDATION_CODE_NOT_OWNED;
}
// Check expiration date
if ($discount->valid_day != NULL) {
$now = strtotime(date("Y-m-d H:i:s"));
$start = strtotime($discount->creation_dtime);
$validDay = ' +' . $discount->valid_day . ' day';
$validDateTime = strtotime($validDay, $start);
if ($validDateTime < $now)
return Discount_Engine::VALIDATION_CODE_EXPIRED;
}
// Check remain count
if ($discount->remain_count <= 0) {
return Discount_Engine::VALIDATION_CODE_USED;
}
return Discount_Engine::VALIDATION_CODE_VALID;
} | [
"public",
"function",
"validate",
"(",
"$",
"discount",
",",
"$",
"request",
")",
"{",
"// Check user",
"$",
"currentUser",
"=",
"$",
"request",
"->",
"user",
";",
"if",
"(",
"$",
"currentUser",
"->",
"id",
"!==",
"$",
"discount",
"->",
"get_user",
"(",
... | Validate given discount and returns a code as result. Returned code should be as following:
<ul>
<li> 0: discount is valid. </li>
<li> 1: discount is used before.</li>
<li> 2: discount is expired.</li>
<li> 3: discount is not owned by current user.</li>
</ul>
@param Discount_Discount $discount
@param Pluf_Http_Request $request | [
"Validate",
"given",
"discount",
"and",
"returns",
"a",
"code",
"as",
"result",
".",
"Returned",
"code",
"should",
"be",
"as",
"following",
":"
] | train | https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Engine/SpecialPercent.php#L50-L71 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Tool/Console/Command/Command.php | Command.initialize | protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->dm = $this->getHelper('documentManager')->getDocumentManager();
$this->cmf = $this->dm->getMetadataFactory();
$this->sm = $this->dm->getSchemaManager();
} | php | protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->dm = $this->getHelper('documentManager')->getDocumentManager();
$this->cmf = $this->dm->getMetadataFactory();
$this->sm = $this->dm->getSchemaManager();
} | [
"protected",
"function",
"initialize",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"dm",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'documentManager'",
")",
"->",
"getDocumentManager",
"(",
")",
";... | {@inheritdoc} | [
"{"
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Tool/Console/Command/Command.php#L32-L37 |
qingbing/php-database | src/supports/Builder/FindBuilder.php | FindBuilder.count | public function count($params = [])
{
$this->setSelect('COUNT(*) AS ' . $this->quoteColumnName('total'))
->setLimit(-1);
$record = $this->getDb()
->createCommand()
->setText($this->buildSql())
->queryRow(array_merge($this->getParams(), $params));
return $record['total'];
} | php | public function count($params = [])
{
$this->setSelect('COUNT(*) AS ' . $this->quoteColumnName('total'))
->setLimit(-1);
$record = $this->getDb()
->createCommand()
->setText($this->buildSql())
->queryRow(array_merge($this->getParams(), $params));
return $record['total'];
} | [
"public",
"function",
"count",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setSelect",
"(",
"'COUNT(*) AS '",
".",
"$",
"this",
"->",
"quoteColumnName",
"(",
"'total'",
")",
")",
"->",
"setLimit",
"(",
"-",
"1",
")",
";",
"$",
... | 查询影响的结果集行数,对于 select ,rowCount() 返回有可能为部分结果,这里用统计更好
@param array $params
@return int
@throws \Exception | [
"查询影响的结果集行数,对于",
"select",
",rowCount",
"()",
"返回有可能为部分结果,这里用统计更好"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/FindBuilder.php#L31-L40 |
qingbing/php-database | src/supports/Builder/FindBuilder.php | FindBuilder.queryRow | public function queryRow($params = [])
{
$this->setLimit(1);
return $this->getDb()
->createCommand()
->setText($this->buildSql())
->queryRow(array_merge($this->getParams(), $params));
} | php | public function queryRow($params = [])
{
$this->setLimit(1);
return $this->getDb()
->createCommand()
->setText($this->buildSql())
->queryRow(array_merge($this->getParams(), $params));
} | [
"public",
"function",
"queryRow",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setLimit",
"(",
"1",
")",
";",
"return",
"$",
"this",
"->",
"getDb",
"(",
")",
"->",
"createCommand",
"(",
")",
"->",
"setText",
"(",
"$",
"this",
... | 查询第一条结果集
@param array $params
@return array
@throws \Exception | [
"查询第一条结果集"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/FindBuilder.php#L48-L55 |
qingbing/php-database | src/supports/Builder/FindBuilder.php | FindBuilder.buildSql | protected function buildSql()
{
$query = $this->getQuery();
// DISTINCT
if (isset($query['distinct']) && !empty($query['distinct'])) {
$sql = 'SELECT DISTINCT';
} else {
$sql = 'SELECT';
}
// SELECT
if (isset($query['select']) && !empty($query['select'])) {
$sql .= " {$query['select']}";
} else {
$sql .= ' *';
}
// FROM
if (!isset($query['table']) || empty($query['table'])) {
throw new Exception('Find查询必须带有"table"参数', 101300501);
}
$sql .= " FROM " . $this->quoteTableName($query['table']);
// ALIAS
$sql .= " AS " . $this->quoteColumnName((isset($query['alias']) && !empty($query['alias'])) ? $query['alias'] : 't');
// JOIN
if (isset($query['join']) && !empty($query['join']))
$sql .= ' ' . (is_array($query['join']) ? implode(" ", $query['join']) : $query['join']);
// WHERE
if (isset($query['where']) && !empty($query['where']))
$sql .= " WHERE {$query['where']}";
// GROUP
if (isset($query['group']) && !empty($query['group']))
$sql .= " GROUP BY {$query['group']}";
// HAVING
if (isset($query['having']) && !empty($query['having']))
$sql .= " HAVING {$query['having']}";
// UNION
if (isset($query['union']) && !empty($query['union']))
$sql .= " UNION (" . (is_array($query['union']) ? implode(") UNION (", $query['union']) : $query['union']) . ')';
// ORDER
if (isset($query['order']) && !empty($query['order']))
$sql .= " ORDER BY {$query['order']}";
if (isset($query['limit']) && $query['limit'] >= 0) {
$sql .= " LIMIT {$query['limit']}";
if (isset($query['offset']) && $query['offset'] > 0) {
$sql .= ", {$query['offset']}";
}
} elseif (isset($query['offset']) && $query['offset'] > 0) {
throw new Exception('"offset"必须和"limit"配对出现', 101300502);
}
return $sql;
} | php | protected function buildSql()
{
$query = $this->getQuery();
// DISTINCT
if (isset($query['distinct']) && !empty($query['distinct'])) {
$sql = 'SELECT DISTINCT';
} else {
$sql = 'SELECT';
}
// SELECT
if (isset($query['select']) && !empty($query['select'])) {
$sql .= " {$query['select']}";
} else {
$sql .= ' *';
}
// FROM
if (!isset($query['table']) || empty($query['table'])) {
throw new Exception('Find查询必须带有"table"参数', 101300501);
}
$sql .= " FROM " . $this->quoteTableName($query['table']);
// ALIAS
$sql .= " AS " . $this->quoteColumnName((isset($query['alias']) && !empty($query['alias'])) ? $query['alias'] : 't');
// JOIN
if (isset($query['join']) && !empty($query['join']))
$sql .= ' ' . (is_array($query['join']) ? implode(" ", $query['join']) : $query['join']);
// WHERE
if (isset($query['where']) && !empty($query['where']))
$sql .= " WHERE {$query['where']}";
// GROUP
if (isset($query['group']) && !empty($query['group']))
$sql .= " GROUP BY {$query['group']}";
// HAVING
if (isset($query['having']) && !empty($query['having']))
$sql .= " HAVING {$query['having']}";
// UNION
if (isset($query['union']) && !empty($query['union']))
$sql .= " UNION (" . (is_array($query['union']) ? implode(") UNION (", $query['union']) : $query['union']) . ')';
// ORDER
if (isset($query['order']) && !empty($query['order']))
$sql .= " ORDER BY {$query['order']}";
if (isset($query['limit']) && $query['limit'] >= 0) {
$sql .= " LIMIT {$query['limit']}";
if (isset($query['offset']) && $query['offset'] > 0) {
$sql .= ", {$query['offset']}";
}
} elseif (isset($query['offset']) && $query['offset'] > 0) {
throw new Exception('"offset"必须和"limit"配对出现', 101300502);
}
return $sql;
} | [
"protected",
"function",
"buildSql",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
";",
"// DISTINCT\r",
"if",
"(",
"isset",
"(",
"$",
"query",
"[",
"'distinct'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"query",
"[",
"'... | 根据 query 选项创建SQL
@return string
@throws Exception | [
"根据",
"query",
"选项创建SQL"
] | train | https://github.com/qingbing/php-database/blob/cfd915c9d25dbe5d5cdd9b4c93eca5fd63cb7015/src/supports/Builder/FindBuilder.php#L76-L125 |
irfantoor/engine | src/Http/Headers.php | Headers.createFromEnvironment | public static function createFromEnvironment($env = [])
{
if (!($env instanceof Environment)) {
$env = new Environment($env);
}
// Headers from environment
$data = [];
foreach($env as $k=>$v) {
$k = strtoupper($k);
if (strpos($k, 'HTTP_') === 0) {
$k = substr($k, 5);
} else {
if (!isset(static::$special[$k]))
continue;
}
// normalize key
$k = str_replace(
' ',
'-',
ucwords(strtolower(str_replace('_', ' ', $k)))
);
$data[$k] = $v;
}
return new static($data);
} | php | public static function createFromEnvironment($env = [])
{
if (!($env instanceof Environment)) {
$env = new Environment($env);
}
// Headers from environment
$data = [];
foreach($env as $k=>$v) {
$k = strtoupper($k);
if (strpos($k, 'HTTP_') === 0) {
$k = substr($k, 5);
} else {
if (!isset(static::$special[$k]))
continue;
}
// normalize key
$k = str_replace(
' ',
'-',
ucwords(strtolower(str_replace('_', ' ', $k)))
);
$data[$k] = $v;
}
return new static($data);
} | [
"public",
"static",
"function",
"createFromEnvironment",
"(",
"$",
"env",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"env",
"instanceof",
"Environment",
")",
")",
"{",
"$",
"env",
"=",
"new",
"Environment",
"(",
"$",
"env",
")",
";",
"}",
"... | Create Headers from Enviroment class or an array of $_SERVER
@param Environment|array $env
@return Headers Collection | [
"Create",
"Headers",
"from",
"Enviroment",
"class",
"or",
"an",
"array",
"of",
"$_SERVER"
] | train | https://github.com/irfantoor/engine/blob/4d2d221add749f75100d0b4ffe1488cdbf7af5d3/src/Http/Headers.php#L31-L59 |
irfantoor/engine | src/Http/Headers.php | Headers.setItem | public function setItem($id, $value = null)
{
if (!is_array($value)) {
$value = [$value];
}
parent::setItem(strtolower($id), ['id' => $id, 'value' => $value]);
} | php | public function setItem($id, $value = null)
{
if (!is_array($value)) {
$value = [$value];
}
parent::setItem(strtolower($id), ['id' => $id, 'value' => $value]);
} | [
"public",
"function",
"setItem",
"(",
"$",
"id",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"parent",
"::",
"setItem",
"(",
"strto... | # used by set($id, $value) | [
"#",
"used",
"by",
"set",
"(",
"$id",
"$value",
")"
] | train | https://github.com/irfantoor/engine/blob/4d2d221add749f75100d0b4ffe1488cdbf7af5d3/src/Http/Headers.php#L67-L74 |
SysControllers/Admin | src/app/Http/Controllers/Admin/FormularioContactoController.php | FormularioContactoController.index | public function index(Request $request)
{
$mensajes = $this->contactoMensajeRepo->findMessageAndPaginate($request);
return view('admin.formularios.contacto.list', compact('mensajes'));
} | php | public function index(Request $request)
{
$mensajes = $this->contactoMensajeRepo->findMessageAndPaginate($request);
return view('admin.formularios.contacto.list', compact('mensajes'));
} | [
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"mensajes",
"=",
"$",
"this",
"->",
"contactoMensajeRepo",
"->",
"findMessageAndPaginate",
"(",
"$",
"request",
")",
";",
"return",
"view",
"(",
"'admin.formularios.contacto.list'",
",... | Show the form for editing the specified adminconfig.
@param Request $request
@return Response
@internal param int $id | [
"Show",
"the",
"form",
"for",
"editing",
"the",
"specified",
"adminconfig",
"."
] | train | https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Http/Controllers/Admin/FormularioContactoController.php#L26-L31 |
itkg/core | src/Itkg/Core/KernelAbstract.php | KernelAbstract.loadConfig | protected function loadConfig()
{
$this->container['app']->getConfig()->load($this->getConfigFiles());
$this->dispatchEvent(KernelEvents::CONFIG_LOADED, new KernelEvent($this->container));
} | php | protected function loadConfig()
{
$this->container['app']->getConfig()->load($this->getConfigFiles());
$this->dispatchEvent(KernelEvents::CONFIG_LOADED, new KernelEvent($this->container));
} | [
"protected",
"function",
"loadConfig",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'app'",
"]",
"->",
"getConfig",
"(",
")",
"->",
"load",
"(",
"$",
"this",
"->",
"getConfigFiles",
"(",
")",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
... | Load Config from config files
@return $this | [
"Load",
"Config",
"from",
"config",
"files"
] | train | https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/KernelAbstract.php#L75-L80 |
itkg/core | src/Itkg/Core/KernelAbstract.php | KernelAbstract.handle | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if ($type == HttpKernelInterface::SUB_REQUEST) {
$request->query->add(
array_merge(
$_POST,
$_GET,
$request->query->all()
)
);
} else {
$this->container['request'] = $request;
}
return parent::handle($request, $type, $catch);
} | php | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if ($type == HttpKernelInterface::SUB_REQUEST) {
$request->query->add(
array_merge(
$_POST,
$_GET,
$request->query->all()
)
);
} else {
$this->container['request'] = $request;
}
return parent::handle($request, $type, $catch);
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"$",
"type",
"=",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
",",
"$",
"catch",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"HttpKernelInterface",
"::",
"SUB_REQUEST",
")",
"... | {@inheritdoc}
@api | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/KernelAbstract.php#L122-L137 |
rollerworks/search-doctrine-orm | DoctrineOrmFactory.php | DoctrineOrmFactory.createConditionGenerator | public function createConditionGenerator($query, SearchCondition $searchCondition)
{
if ($query instanceof NativeQuery) {
return new NativeQueryConditionGenerator($query, $searchCondition);
}
if ($query instanceof Query || $query instanceof QueryBuilder) {
return new DqlConditionGenerator($query, $searchCondition);
}
throw new \InvalidArgumentException(
sprintf('Query "%s" is not supported by the DoctrineOrmFactory.', \get_class($query))
);
} | php | public function createConditionGenerator($query, SearchCondition $searchCondition)
{
if ($query instanceof NativeQuery) {
return new NativeQueryConditionGenerator($query, $searchCondition);
}
if ($query instanceof Query || $query instanceof QueryBuilder) {
return new DqlConditionGenerator($query, $searchCondition);
}
throw new \InvalidArgumentException(
sprintf('Query "%s" is not supported by the DoctrineOrmFactory.', \get_class($query))
);
} | [
"public",
"function",
"createConditionGenerator",
"(",
"$",
"query",
",",
"SearchCondition",
"$",
"searchCondition",
")",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"NativeQuery",
")",
"{",
"return",
"new",
"NativeQueryConditionGenerator",
"(",
"$",
"query",
",",... | Creates a new ConditionGenerator for the SearchCondition.
Conversions are applied using the 'doctrine_dbal_conversion' option (when present).
@param NativeQuery|Query|QueryBuilder $query Doctrine ORM (Native)Query object
@param SearchCondition $searchCondition SearchCondition object
@return NativeQueryConditionGenerator|DqlConditionGenerator | [
"Creates",
"a",
"new",
"ConditionGenerator",
"for",
"the",
"SearchCondition",
"."
] | train | https://github.com/rollerworks/search-doctrine-orm/blob/d4d7e9cfc6591d34e9d00f084c35f109f971ac4f/DoctrineOrmFactory.php#L52-L65 |
rollerworks/search-doctrine-orm | DoctrineOrmFactory.php | DoctrineOrmFactory.createCachedConditionGenerator | public function createCachedConditionGenerator($conditionGenerator, $ttl = null): ConditionGenerator
{
if (null === $this->cacheDriver) {
return $conditionGenerator;
}
if ($conditionGenerator instanceof DqlConditionGenerator) {
return new CachedDqlConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
} elseif ($conditionGenerator instanceof NativeQueryConditionGenerator) {
return new CachedNativeQueryConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
}
throw new \InvalidArgumentException(
sprintf('ConditionGenerator "%s" is not supported by the DoctrineOrmFactory.', \get_class($conditionGenerator))
);
} | php | public function createCachedConditionGenerator($conditionGenerator, $ttl = null): ConditionGenerator
{
if (null === $this->cacheDriver) {
return $conditionGenerator;
}
if ($conditionGenerator instanceof DqlConditionGenerator) {
return new CachedDqlConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
} elseif ($conditionGenerator instanceof NativeQueryConditionGenerator) {
return new CachedNativeQueryConditionGenerator($conditionGenerator, $this->cacheDriver, $ttl);
}
throw new \InvalidArgumentException(
sprintf('ConditionGenerator "%s" is not supported by the DoctrineOrmFactory.', \get_class($conditionGenerator))
);
} | [
"public",
"function",
"createCachedConditionGenerator",
"(",
"$",
"conditionGenerator",
",",
"$",
"ttl",
"=",
"null",
")",
":",
"ConditionGenerator",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cacheDriver",
")",
"{",
"return",
"$",
"conditionGenerator",
... | Creates a new CachedConditionGenerator instance for the ConditionGenerator.
@param DqlConditionGenerator|NativeQueryConditionGenerator $conditionGenerator
@param int|\DateInterval|null $ttl Optional. The TTL value of this item. If no value is sent and
the driver supports TTL then the library may set a default value
for it or let the driver take care of that. | [
"Creates",
"a",
"new",
"CachedConditionGenerator",
"instance",
"for",
"the",
"ConditionGenerator",
"."
] | train | https://github.com/rollerworks/search-doctrine-orm/blob/d4d7e9cfc6591d34e9d00f084c35f109f971ac4f/DoctrineOrmFactory.php#L75-L90 |
dmj/PicaRecord | src/HAB/Pica/Record/Helper.php | Helper.mapMethod | public static function mapMethod (array $sequence, $method, array $arguments = array())
{
if (empty($arguments)) {
$f = function ($element) use ($method) {
return $element->$method();
};
} else {
$f = function ($element) use ($method, $arguments) {
return call_user_func_array(array($element, $method), $arguments);
};
}
return array_map($f, $sequence);
} | php | public static function mapMethod (array $sequence, $method, array $arguments = array())
{
if (empty($arguments)) {
$f = function ($element) use ($method) {
return $element->$method();
};
} else {
$f = function ($element) use ($method, $arguments) {
return call_user_func_array(array($element, $method), $arguments);
};
}
return array_map($f, $sequence);
} | [
"public",
"static",
"function",
"mapMethod",
"(",
"array",
"$",
"sequence",
",",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"arguments",
")",
")",
"{",
"$",
"f",
"=",
"function",
"... | Return an array of the results of calling a method for each element of a
sequence.
@param array $sequence Sequence of objects
@param string $method Name of the method
@param array $arguments Optional array of method arguments
@return array Result of calling method on each element of sequence | [
"Return",
"an",
"array",
"of",
"the",
"results",
"of",
"calling",
"a",
"method",
"for",
"each",
"element",
"of",
"a",
"sequence",
"."
] | train | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L56-L68 |
dmj/PicaRecord | src/HAB/Pica/Record/Helper.php | Helper.some | public static function some (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (call_user_func($predicate, $element)) {
return true;
}
}
return false;
} | php | public static function some (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (call_user_func($predicate, $element)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"some",
"(",
"array",
"$",
"sequence",
",",
"$",
"predicate",
")",
"{",
"foreach",
"(",
"$",
"sequence",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"predicate",
",",
"$",
"element",
")",
")",
... | Return TRUE if at leat one element of sequence matches predicate.
@todo Make FALSE and TRUE self-evaluating, maybe
@param array $sequence Sequence
@param callback $predicate Predicate
@return boolean TRUE if at least one element matches predicate | [
"Return",
"TRUE",
"if",
"at",
"leat",
"one",
"element",
"of",
"sequence",
"matches",
"predicate",
"."
] | train | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L90-L98 |
dmj/PicaRecord | src/HAB/Pica/Record/Helper.php | Helper.every | public static function every (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (!call_user_func($predicate, $element)) {
return false;
}
}
return true;
} | php | public static function every (array $sequence, $predicate)
{
foreach ($sequence as $element) {
if (!call_user_func($predicate, $element)) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"every",
"(",
"array",
"$",
"sequence",
",",
"$",
"predicate",
")",
"{",
"foreach",
"(",
"$",
"sequence",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"call_user_func",
"(",
"$",
"predicate",
",",
"$",
"element",
")",... | Return TRUE if every element of sequence fullfills predicate.
@todo Make FALSE and TRUE self-evaluating, maybe
@param array $sequence Sequence
@param callback $predicate Predicate
@return boolean TRUE if every element fullfills predicate | [
"Return",
"TRUE",
"if",
"every",
"element",
"of",
"sequence",
"fullfills",
"predicate",
"."
] | train | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L109-L117 |
dmj/PicaRecord | src/HAB/Pica/Record/Helper.php | Helper.flatten | public static function flatten (array $sequence)
{
$flat = array();
array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
return $flat;
} | php | public static function flatten (array $sequence)
{
$flat = array();
array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
return $flat;
} | [
"public",
"static",
"function",
"flatten",
"(",
"array",
"$",
"sequence",
")",
"{",
"$",
"flat",
"=",
"array",
"(",
")",
";",
"array_walk_recursive",
"(",
"$",
"sequence",
",",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"&",
"$",
"flat",
")",
... | Flatten sequence.
@param array $sequence Sequence
@return array Flattend sequence | [
"Flatten",
"sequence",
"."
] | train | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Helper.php#L125-L130 |
g4code/di | src/Container.php | Container.reg | private static function reg($callable)
{
$id = debug_backtrace()[2]['function'];
if (! self::getInstance()->offsetExists($id)) {
self::getInstance()->offsetSet($id, $callable);
}
return self::getInstance()->offsetGet($id);
} | php | private static function reg($callable)
{
$id = debug_backtrace()[2]['function'];
if (! self::getInstance()->offsetExists($id)) {
self::getInstance()->offsetSet($id, $callable);
}
return self::getInstance()->offsetGet($id);
} | [
"private",
"static",
"function",
"reg",
"(",
"$",
"callable",
")",
"{",
"$",
"id",
"=",
"debug_backtrace",
"(",
")",
"[",
"2",
"]",
"[",
"'function'",
"]",
";",
"if",
"(",
"!",
"self",
"::",
"getInstance",
"(",
")",
"->",
"offsetExists",
"(",
"$",
... | Pimple facade
@param Callable $callable
@return mixed | [
"Pimple",
"facade"
] | train | https://github.com/g4code/di/blob/85e34d37178c8d4726f4a9620d3e975bb9bb9f54/src/Container.php#L66-L73 |
zodream/database | src/Command.php | Command.addPrefix | public function addPrefix($table) {
if (strpos($table, '`') !== false) {
return $table;
}
preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
$table = count($match) == 2 ? $table : $match[1];
$alias = '';
if (count($match) > 2) {
$alias = $match[2];
}
if (strpos($table, '.') !== false) {
list($schema, $table) = explode('.', $table);
return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
}
if (strpos($table, '!') === 0) {
return sprintf('`%s`%s', substr($table, 1), $alias);
}
$prefix = $this->getEngine()->getConfig('prefix');
if (empty($prefix)) {
return sprintf('`%s`%s', $table, $alias);
}
return sprintf('`%s`%s', $prefix.
Str::firstReplace($table, $prefix), $alias);
} | php | public function addPrefix($table) {
if (strpos($table, '`') !== false) {
return $table;
}
preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
$table = count($match) == 2 ? $table : $match[1];
$alias = '';
if (count($match) > 2) {
$alias = $match[2];
}
if (strpos($table, '.') !== false) {
list($schema, $table) = explode('.', $table);
return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
}
if (strpos($table, '!') === 0) {
return sprintf('`%s`%s', substr($table, 1), $alias);
}
$prefix = $this->getEngine()->getConfig('prefix');
if (empty($prefix)) {
return sprintf('`%s`%s', $table, $alias);
}
return sprintf('`%s`%s', $prefix.
Str::firstReplace($table, $prefix), $alias);
} | [
"public",
"function",
"addPrefix",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"table",
",",
"'`'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"table",
";",
"}",
"preg_match",
"(",
"'/([\\w_\\.]+)( (as )?[\\w_]+)?/i'",
",",
"$",
"table... | ADD TABLE PREFIX
@param string $table
@return string
@throws \Exception | [
"ADD",
"TABLE",
"PREFIX"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L63-L86 |
zodream/database | src/Command.php | Command.openCache | public function openCache($expire = 3600) {
$this->allowCache = $expire !== false;
$this->cacheLife = $expire;
return $this;
} | php | public function openCache($expire = 3600) {
$this->allowCache = $expire !== false;
$this->cacheLife = $expire;
return $this;
} | [
"public",
"function",
"openCache",
"(",
"$",
"expire",
"=",
"3600",
")",
"{",
"$",
"this",
"->",
"allowCache",
"=",
"$",
"expire",
"!==",
"false",
";",
"$",
"this",
"->",
"cacheLife",
"=",
"$",
"expire",
";",
"return",
"$",
"this",
";",
"}"
] | 开启缓存
@param int $expire
@return $this | [
"开启缓存"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L138-L142 |
zodream/database | src/Command.php | Command.select | public function select($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getArray($sql, $parameters);
} | php | public function select($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getArray($sql, $parameters);
} | [
"public",
"function",
"select",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"DB",
"::",
"addQueryLog",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"getArray",
"(",
"$",
"sql",
",",
... | 查询
@param string $sql
@param array $parameters
@return mixed
@throws \Exception | [
"查询"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L174-L177 |
zodream/database | src/Command.php | Command.insert | public function insert($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->insert($sql, $parameters);
} | php | public function insert($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->insert($sql, $parameters);
} | [
"public",
"function",
"insert",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"DB",
"::",
"addQueryLog",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"getEngine",
"(",
")",
"->",
"inse... | 插入
@param $sql
@param array $parameters
@return int
@throws \Exception | [
"插入"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L206-L209 |
zodream/database | src/Command.php | Command.insertOrReplace | public function insertOrReplace($columns, $tags, $parameters = array()) {
if (!empty($columns) && strpos($columns, '(') === false) {
$columns = '('.$columns.')';
}
$tags = trim($tags);
if (strpos($tags, '(') !== 0) {
$tags = '('.$tags.')';
}
return $this->update("REPLACE INTO {$this->table} {$columns} VALUES {$tags}", $parameters);
} | php | public function insertOrReplace($columns, $tags, $parameters = array()) {
if (!empty($columns) && strpos($columns, '(') === false) {
$columns = '('.$columns.')';
}
$tags = trim($tags);
if (strpos($tags, '(') !== 0) {
$tags = '('.$tags.')';
}
return $this->update("REPLACE INTO {$this->table} {$columns} VALUES {$tags}", $parameters);
} | [
"public",
"function",
"insertOrReplace",
"(",
"$",
"columns",
",",
"$",
"tags",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"columns",
")",
"&&",
"strpos",
"(",
"$",
"columns",
",",
"'('",
")",
"==="... | 在执行REPLACE后,系统返回了所影响的行数,如果返回1,说明在表中并没有重复的记录,如果返回2,说明有一条重复记录,系统自动先调用了 DELETE删除这条记录,然后再记录用INSERT来insert这条记录。如果返回的值大于2,那说明有多个唯一索引,有多条记录被删除和insert。
@param string $columns
@param string $tags
@param array $parameters
@return int
@throws \Exception | [
"在执行REPLACE后,系统返回了所影响的行数,如果返回1,说明在表中并没有重复的记录,如果返回2,说明有一条重复记录,系统自动先调用了",
"DELETE删除这条记录,然后再记录用INSERT来insert这条记录。如果返回的值大于2,那说明有多个唯一索引,有多条记录被删除和insert。"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L239-L248 |
zodream/database | src/Command.php | Command.update | public function update($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->update($sql, $parameters);
} | php | public function update($sql, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->update($sql, $parameters);
} | [
"public",
"function",
"update",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"DB",
"::",
"addQueryLog",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"getEngine",
"(",
")",
"->",
"upda... | 更新, 如果数据相同会返回0
@param $sql
@param array $parameters
@return int
@throws \Exception | [
"更新",
"如果数据相同会返回0"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L257-L260 |
zodream/database | src/Command.php | Command.delete | public function delete($sql = null, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->delete($sql, $parameters);
} | php | public function delete($sql = null, $parameters = array()) {
DB::addQueryLog($sql, $parameters);
return $this->getEngine()->delete($sql, $parameters);
} | [
"public",
"function",
"delete",
"(",
"$",
"sql",
"=",
"null",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"DB",
"::",
"addQueryLog",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"getEngine",
"(",
")"... | 删除
@param null $sql
@param array $parameters
@return int
@throws \Exception | [
"删除"
] | train | https://github.com/zodream/database/blob/03712219c057799d07350a3a2650c55bcc92c28e/src/Command.php#L269-L272 |
t3v/t3v_core | Classes/ViewHelpers/ArrayViewHelper.php | ArrayViewHelper.render | public function render(array $array, string $key) {
$result = null;
if (is_array($array) && $key) {
if (array_key_exists($key, $array)) {
$result = $array[$key];
}
}
return $result;
} | php | public function render(array $array, string $key) {
$result = null;
if (is_array($array) && $key) {
if (array_key_exists($key, $array)) {
$result = $array[$key];
}
}
return $result;
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
"&&",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
... | The view helper render function.
@param array $array The array
@param string $key The key
@return object|null The value for the key or null if the key does not exist | [
"The",
"view",
"helper",
"render",
"function",
"."
] | train | https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/ViewHelpers/ArrayViewHelper.php#L19-L29 |
SteeinRu/steein-sdk-php | src/Steein/SDK/Core/Http/Clients/SteeinCurlHttpClient.php | SteeinCurlHttpClient.openConnection | public function openConnection($url, $method, $body, array $headers, $timeOut)
{
$options = [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $this->compileRequestHeaders($headers),
CURLOPT_URL => $url,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => $timeOut,
CURLOPT_RETURNTRANSFER => true, // Follow 301 redirects
CURLOPT_HEADER => true, // Enable header processing
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => __DIR__.'/certs/DigiCertHighAssuranceEVRootCA.pem',
];
if(SteeinConstants::DEBUG == true) {
$options[CURLOPT_SSL_VERIFYHOST] = 0;
$options[CURLOPT_SSL_VERIFYPEER] = false;
}
if ($method !== "GET") {
$options[CURLOPT_POSTFIELDS] = $body;
}
$this->curl->init();
$this->curl->setoptArray($options);
} | php | public function openConnection($url, $method, $body, array $headers, $timeOut)
{
$options = [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $this->compileRequestHeaders($headers),
CURLOPT_URL => $url,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => $timeOut,
CURLOPT_RETURNTRANSFER => true, // Follow 301 redirects
CURLOPT_HEADER => true, // Enable header processing
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => __DIR__.'/certs/DigiCertHighAssuranceEVRootCA.pem',
];
if(SteeinConstants::DEBUG == true) {
$options[CURLOPT_SSL_VERIFYHOST] = 0;
$options[CURLOPT_SSL_VERIFYPEER] = false;
}
if ($method !== "GET") {
$options[CURLOPT_POSTFIELDS] = $body;
}
$this->curl->init();
$this->curl->setoptArray($options);
} | [
"public",
"function",
"openConnection",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"body",
",",
"array",
"$",
"headers",
",",
"$",
"timeOut",
")",
"{",
"$",
"options",
"=",
"[",
"CURLOPT_CUSTOMREQUEST",
"=>",
"$",
"method",
",",
"CURLOPT_HTTPHEADER",
... | Opens a new curl connection.
@param string $url The endpoint to send the request to.
@param string $method The request method.
@param string $body The body of the request.
@param array $headers The request headers.
@param int $timeOut The timeout in seconds for the request. | [
"Opens",
"a",
"new",
"curl",
"connection",
"."
] | train | https://github.com/SteeinRu/steein-sdk-php/blob/27113624a6582d27bb55d7c9724e8306739ef167/src/Steein/SDK/Core/Http/Clients/SteeinCurlHttpClient.php#L96-L122 |
SteeinRu/steein-sdk-php | src/Steein/SDK/Core/Http/Clients/SteeinCurlHttpClient.php | SteeinCurlHttpClient.extractResponseHeadersAndBody | public function extractResponseHeadersAndBody()
{
$parts = explode("\r\n\r\n", $this->rawResponse);
$rawBody = array_pop($parts);
$rawHeaders = implode("\r\n\r\n", $parts);
return [trim($rawHeaders), trim($rawBody)];
} | php | public function extractResponseHeadersAndBody()
{
$parts = explode("\r\n\r\n", $this->rawResponse);
$rawBody = array_pop($parts);
$rawHeaders = implode("\r\n\r\n", $parts);
return [trim($rawHeaders), trim($rawBody)];
} | [
"public",
"function",
"extractResponseHeadersAndBody",
"(",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"this",
"->",
"rawResponse",
")",
";",
"$",
"rawBody",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"rawHeaders",
... | Extracts the headers and the body into a two-part array
@return array | [
"Extracts",
"the",
"headers",
"and",
"the",
"body",
"into",
"a",
"two",
"-",
"part",
"array"
] | train | https://github.com/SteeinRu/steein-sdk-php/blob/27113624a6582d27bb55d7c9724e8306739ef167/src/Steein/SDK/Core/Http/Clients/SteeinCurlHttpClient.php#L163-L170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.