id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
21,100 |
phootwork/lang
|
src/Text.php
|
Text.insert
|
public function insert($substring, $index) {
if ($index <= 0) {
return $this->prepend($substring);
}
if ($index > $this->length()) {
return $this->append($substring);
}
$start = mb_substr($this->string, 0, $index, $this->encoding);
$end = mb_substr($this->string, $index, $this->length(), $this->encoding);
return new Text($start . $substring . $end);
}
|
php
|
public function insert($substring, $index) {
if ($index <= 0) {
return $this->prepend($substring);
}
if ($index > $this->length()) {
return $this->append($substring);
}
$start = mb_substr($this->string, 0, $index, $this->encoding);
$end = mb_substr($this->string, $index, $this->length(), $this->encoding);
return new Text($start . $substring . $end);
}
|
[
"public",
"function",
"insert",
"(",
"$",
"substring",
",",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
"<=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"prepend",
"(",
"$",
"substring",
")",
";",
"}",
"if",
"(",
"$",
"index",
">",
"$",
"this",
"->",
"length",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"append",
"(",
"$",
"substring",
")",
";",
"}",
"$",
"start",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"0",
",",
"$",
"index",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"end",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"index",
",",
"$",
"this",
"->",
"length",
"(",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"return",
"new",
"Text",
"(",
"$",
"start",
".",
"$",
"substring",
".",
"$",
"end",
")",
";",
"}"
] |
Inserts a substring at the given index
<code>
$str = new Text('Hello World!');<br>
$str->insert('to this ', 5); // Hello to this World!
</code>
@param string|Text $substring
@param int $index
@return Text
|
[
"Inserts",
"a",
"substring",
"at",
"the",
"given",
"index"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L115-L127
|
21,101 |
phootwork/lang
|
src/Text.php
|
Text.compare
|
public function compare($compare, callable $callback = null) {
if ($callback === null) {
$callback = 'strcmp';
}
return $callback($this->string, (string) $compare);
}
|
php
|
public function compare($compare, callable $callback = null) {
if ($callback === null) {
$callback = 'strcmp';
}
return $callback($this->string, (string) $compare);
}
|
[
"public",
"function",
"compare",
"(",
"$",
"compare",
",",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"callback",
"===",
"null",
")",
"{",
"$",
"callback",
"=",
"'strcmp'",
";",
"}",
"return",
"$",
"callback",
"(",
"$",
"this",
"->",
"string",
",",
"(",
"string",
")",
"$",
"compare",
")",
";",
"}"
] |
Compares this string to another
@param string $compare string to compare to
@param callable $callback
@return int
|
[
"Compares",
"this",
"string",
"to",
"another"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L164-L169
|
21,102 |
phootwork/lang
|
src/Text.php
|
Text.slice
|
public function slice($offset, $length = null) {
$offset = $this->prepareOffset($offset);
$length = $this->prepareLength($offset, $length);
if ($length === 0) {
return new Text('', $this->encoding);
}
return new Text(mb_substr($this->string, $offset, $length, $this->encoding), $this->encoding);
}
|
php
|
public function slice($offset, $length = null) {
$offset = $this->prepareOffset($offset);
$length = $this->prepareLength($offset, $length);
if ($length === 0) {
return new Text('', $this->encoding);
}
return new Text(mb_substr($this->string, $offset, $length, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"slice",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"prepareOffset",
"(",
"$",
"offset",
")",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"prepareLength",
"(",
"$",
"offset",
",",
"$",
"length",
")",
";",
"if",
"(",
"$",
"length",
"===",
"0",
")",
"{",
"return",
"new",
"Text",
"(",
"''",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}",
"return",
"new",
"Text",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"offset",
",",
"$",
"length",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Slices a piece of the string from a given offset with a specified length.
If no length is given, the String is sliced to its maximum length.
@see #substring
@param int $offset
@param int $length
@return Text
|
[
"Slices",
"a",
"piece",
"of",
"the",
"string",
"from",
"a",
"given",
"offset",
"with",
"a",
"specified",
"length",
".",
"If",
"no",
"length",
"is",
"given",
"the",
"String",
"is",
"sliced",
"to",
"its",
"maximum",
"length",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L206-L215
|
21,103 |
phootwork/lang
|
src/Text.php
|
Text.substring
|
public function substring($start, $end = null) {
$length = $this->length();
if ($end < 0) {
$end = $length + $end;
}
$end = $end !== null ? min($end, $length) : $length;
$start = min($start, $end);
$end = max($start, $end);
$end = $end - $start;
return new Text(mb_substr($this->string, $start, $end, $this->encoding), $this->encoding);
}
|
php
|
public function substring($start, $end = null) {
$length = $this->length();
if ($end < 0) {
$end = $length + $end;
}
$end = $end !== null ? min($end, $length) : $length;
$start = min($start, $end);
$end = max($start, $end);
$end = $end - $start;
return new Text(mb_substr($this->string, $start, $end, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substring",
"(",
"$",
"start",
",",
"$",
"end",
"=",
"null",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"length",
"(",
")",
";",
"if",
"(",
"$",
"end",
"<",
"0",
")",
"{",
"$",
"end",
"=",
"$",
"length",
"+",
"$",
"end",
";",
"}",
"$",
"end",
"=",
"$",
"end",
"!==",
"null",
"?",
"min",
"(",
"$",
"end",
",",
"$",
"length",
")",
":",
"$",
"length",
";",
"$",
"start",
"=",
"min",
"(",
"$",
"start",
",",
"$",
"end",
")",
";",
"$",
"end",
"=",
"max",
"(",
"$",
"start",
",",
"$",
"end",
")",
";",
"$",
"end",
"=",
"$",
"end",
"-",
"$",
"start",
";",
"return",
"new",
"Text",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Slices a piece of the string from a given start to an end.
If no length is given, the String is sliced to its maximum length.
@see #slice
@param int $start
@param int $end
@return Text
|
[
"Slices",
"a",
"piece",
"of",
"the",
"string",
"from",
"a",
"given",
"start",
"to",
"an",
"end",
".",
"If",
"no",
"length",
"is",
"given",
"the",
"String",
"is",
"sliced",
"to",
"its",
"maximum",
"length",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L226-L237
|
21,104 |
phootwork/lang
|
src/Text.php
|
Text.countSubstring
|
public function countSubstring($substring, $caseSensitive = true) {
$this->verifyNotEmpty($substring, '$substring');
if ($caseSensitive) {
return mb_substr_count($this->string, $substring, $this->encoding);
}
$str = mb_strtoupper($this->string, $this->encoding);
$substring = mb_strtoupper($substring, $this->encoding);
return mb_substr_count($str, $substring, $this->encoding);
}
|
php
|
public function countSubstring($substring, $caseSensitive = true) {
$this->verifyNotEmpty($substring, '$substring');
if ($caseSensitive) {
return mb_substr_count($this->string, $substring, $this->encoding);
}
$str = mb_strtoupper($this->string, $this->encoding);
$substring = mb_strtoupper($substring, $this->encoding);
return mb_substr_count($str, $substring, $this->encoding);
}
|
[
"public",
"function",
"countSubstring",
"(",
"$",
"substring",
",",
"$",
"caseSensitive",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"verifyNotEmpty",
"(",
"$",
"substring",
",",
"'$substring'",
")",
";",
"if",
"(",
"$",
"caseSensitive",
")",
"{",
"return",
"mb_substr_count",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}",
"$",
"str",
"=",
"mb_strtoupper",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"substring",
"=",
"mb_strtoupper",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"return",
"mb_substr_count",
"(",
"$",
"str",
",",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Count the number of substring occurrences.
@param string|Text $substring The substring to count the occurrencies
@param boolean $caseSensitive Force case-sensitivity
@return int
|
[
"Count",
"the",
"number",
"of",
"substring",
"occurrences",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L246-L254
|
21,105 |
phootwork/lang
|
src/Text.php
|
Text.supplant
|
public function supplant(array $map) {
return new Text(str_replace(array_keys($map), array_values($map), $this->string), $this->encoding);
}
|
php
|
public function supplant(array $map) {
return new Text(str_replace(array_keys($map), array_values($map), $this->string), $this->encoding);
}
|
[
"public",
"function",
"supplant",
"(",
"array",
"$",
"map",
")",
"{",
"return",
"new",
"Text",
"(",
"str_replace",
"(",
"array_keys",
"(",
"$",
"map",
")",
",",
"array_values",
"(",
"$",
"map",
")",
",",
"$",
"this",
"->",
"string",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Replaces all occurences of given replacement map. Keys will be replaced with its values.
@param array $map the replacements. Keys will be replaced with its value.
@return Text
|
[
"Replaces",
"all",
"occurences",
"of",
"given",
"replacement",
"map",
".",
"Keys",
"will",
"be",
"replaced",
"with",
"its",
"values",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L297-L299
|
21,106 |
phootwork/lang
|
src/Text.php
|
Text.splice
|
public function splice($replacement, $offset, $length = null) {
$offset = $this->prepareOffset($offset);
$length = $this->prepareLength($offset, $length);
$start = $this->substring(0, $offset);
$end = $this->substring($offset + $length);
return new Text($start . $replacement . $end);
}
|
php
|
public function splice($replacement, $offset, $length = null) {
$offset = $this->prepareOffset($offset);
$length = $this->prepareLength($offset, $length);
$start = $this->substring(0, $offset);
$end = $this->substring($offset + $length);
return new Text($start . $replacement . $end);
}
|
[
"public",
"function",
"splice",
"(",
"$",
"replacement",
",",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"prepareOffset",
"(",
"$",
"offset",
")",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"prepareLength",
"(",
"$",
"offset",
",",
"$",
"length",
")",
";",
"$",
"start",
"=",
"$",
"this",
"->",
"substring",
"(",
"0",
",",
"$",
"offset",
")",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"substring",
"(",
"$",
"offset",
"+",
"$",
"length",
")",
";",
"return",
"new",
"Text",
"(",
"$",
"start",
".",
"$",
"replacement",
".",
"$",
"end",
")",
";",
"}"
] |
Replace text within a portion of a string.
@param string|Text $replacement
@param int $offset
@param int|null $length
@return Text
@throws \InvalidArgumentException If $offset is greater then the string length or $length is too small.
|
[
"Replace",
"text",
"within",
"a",
"portion",
"of",
"a",
"string",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L310-L318
|
21,107 |
phootwork/lang
|
src/Text.php
|
Text.chars
|
public function chars() {
$chars = new ArrayObject();
for ($i = 0, $l = $this->length(); $i < $l; $i++) {
$chars->push($this->at($i));
}
return $chars;
}
|
php
|
public function chars() {
$chars = new ArrayObject();
for ($i = 0, $l = $this->length(); $i < $l; $i++) {
$chars->push($this->at($i));
}
return $chars;
}
|
[
"public",
"function",
"chars",
"(",
")",
"{",
"$",
"chars",
"=",
"new",
"ArrayObject",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"l",
"=",
"$",
"this",
"->",
"length",
"(",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"$",
"i",
"++",
")",
"{",
"$",
"chars",
"->",
"push",
"(",
"$",
"this",
"->",
"at",
"(",
"$",
"i",
")",
")",
";",
"}",
"return",
"$",
"chars",
";",
"}"
] |
Returns an ArrayObject consisting of the characters in the string.
@return ArrayObject An ArrayObject of all chars
|
[
"Returns",
"an",
"ArrayObject",
"consisting",
"of",
"the",
"characters",
"in",
"the",
"string",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L349-L355
|
21,108 |
phootwork/lang
|
src/Text.php
|
Text.indexOf
|
public function indexOf($string, $offset = 0) {
$offset = $this->prepareOffset($offset);
if ($string == '') {
return $offset;
}
return mb_strpos($this->string, (string) $string, $offset, $this->encoding);
}
|
php
|
public function indexOf($string, $offset = 0) {
$offset = $this->prepareOffset($offset);
if ($string == '') {
return $offset;
}
return mb_strpos($this->string, (string) $string, $offset, $this->encoding);
}
|
[
"public",
"function",
"indexOf",
"(",
"$",
"string",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"prepareOffset",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"string",
"==",
"''",
")",
"{",
"return",
"$",
"offset",
";",
"}",
"return",
"mb_strpos",
"(",
"$",
"this",
"->",
"string",
",",
"(",
"string",
")",
"$",
"string",
",",
"$",
"offset",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Returns the index of a given string, starting at the optional zero-related offset
@param string $string
@param int $offset zero-related offset
@return int|boolean int for the index or false if the given string doesn't occur
|
[
"Returns",
"the",
"index",
"of",
"a",
"given",
"string",
"starting",
"at",
"the",
"optional",
"zero",
"-",
"related",
"offset"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L364-L372
|
21,109 |
phootwork/lang
|
src/Text.php
|
Text.lastIndexOf
|
public function lastIndexOf($string, $offset = null) {
if (null === $offset) {
$offset = $this->length();
} else {
$offset = $this->prepareOffset($offset);
}
if ($string === '') {
return $offset;
}
/* Converts $offset to a negative offset as strrpos has a different
* behavior for positive offsets. */
return mb_strrpos($this, (string) $string, $offset - $this->length(), $this->encoding);
}
|
php
|
public function lastIndexOf($string, $offset = null) {
if (null === $offset) {
$offset = $this->length();
} else {
$offset = $this->prepareOffset($offset);
}
if ($string === '') {
return $offset;
}
/* Converts $offset to a negative offset as strrpos has a different
* behavior for positive offsets. */
return mb_strrpos($this, (string) $string, $offset - $this->length(), $this->encoding);
}
|
[
"public",
"function",
"lastIndexOf",
"(",
"$",
"string",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"length",
"(",
")",
";",
"}",
"else",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"prepareOffset",
"(",
"$",
"offset",
")",
";",
"}",
"if",
"(",
"$",
"string",
"===",
"''",
")",
"{",
"return",
"$",
"offset",
";",
"}",
"/* Converts $offset to a negative offset as strrpos has a different\n\t\t * behavior for positive offsets. */",
"return",
"mb_strrpos",
"(",
"$",
"this",
",",
"(",
"string",
")",
"$",
"string",
",",
"$",
"offset",
"-",
"$",
"this",
"->",
"length",
"(",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Returns the last index of a given string, starting at the optional offset
@param string $string
@param int $offset
@return int|boolean int for the index or false if the given string doesn't occur
|
[
"Returns",
"the",
"last",
"index",
"of",
"a",
"given",
"string",
"starting",
"at",
"the",
"optional",
"offset"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L381-L395
|
21,110 |
phootwork/lang
|
src/Text.php
|
Text.startsWith
|
public function startsWith($substring) {
$substringLength = mb_strlen($substring, $this->encoding);
$startOfStr = mb_substr($this->string, 0, $substringLength, $this->encoding);
return (string) $substring === $startOfStr;
}
|
php
|
public function startsWith($substring) {
$substringLength = mb_strlen($substring, $this->encoding);
$startOfStr = mb_substr($this->string, 0, $substringLength, $this->encoding);
return (string) $substring === $startOfStr;
}
|
[
"public",
"function",
"startsWith",
"(",
"$",
"substring",
")",
"{",
"$",
"substringLength",
"=",
"mb_strlen",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"startOfStr",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"0",
",",
"$",
"substringLength",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"return",
"(",
"string",
")",
"$",
"substring",
"===",
"$",
"startOfStr",
";",
"}"
] |
Checks whether the string starts with the given string. Case sensitive!
@see Text::startsWithIgnoreCase()
@param string|Text $substring The substring to look for
@return boolean
|
[
"Checks",
"whether",
"the",
"string",
"starts",
"with",
"the",
"given",
"string",
".",
"Case",
"sensitive!"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L404-L409
|
21,111 |
phootwork/lang
|
src/Text.php
|
Text.startsWithIgnoreCase
|
public function startsWithIgnoreCase($substring) {
$substring = mb_strtolower($substring, $this->encoding);
$substringLength = mb_strlen($substring, $this->encoding);
$startOfStr = mb_strtolower(mb_substr($this->string, 0, $substringLength, $this->encoding));
return (string) $substring === $startOfStr;
}
|
php
|
public function startsWithIgnoreCase($substring) {
$substring = mb_strtolower($substring, $this->encoding);
$substringLength = mb_strlen($substring, $this->encoding);
$startOfStr = mb_strtolower(mb_substr($this->string, 0, $substringLength, $this->encoding));
return (string) $substring === $startOfStr;
}
|
[
"public",
"function",
"startsWithIgnoreCase",
"(",
"$",
"substring",
")",
"{",
"$",
"substring",
"=",
"mb_strtolower",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"substringLength",
"=",
"mb_strlen",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"startOfStr",
"=",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"0",
",",
"$",
"substringLength",
",",
"$",
"this",
"->",
"encoding",
")",
")",
";",
"return",
"(",
"string",
")",
"$",
"substring",
"===",
"$",
"startOfStr",
";",
"}"
] |
Checks whether the string starts with the given string. Ignores case.
@see Text::startsWith()
@param string|Text $substring The substring to look for
@return boolean
|
[
"Checks",
"whether",
"the",
"string",
"starts",
"with",
"the",
"given",
"string",
".",
"Ignores",
"case",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L418-L424
|
21,112 |
phootwork/lang
|
src/Text.php
|
Text.endsWith
|
public function endsWith($substring) {
$substringLength = mb_strlen($substring, $this->encoding);
$endOfStr = mb_substr($this->string, $this->length() - $substringLength, $substringLength, $this->encoding);
return (string) $substring === $endOfStr;
}
|
php
|
public function endsWith($substring) {
$substringLength = mb_strlen($substring, $this->encoding);
$endOfStr = mb_substr($this->string, $this->length() - $substringLength, $substringLength, $this->encoding);
return (string) $substring === $endOfStr;
}
|
[
"public",
"function",
"endsWith",
"(",
"$",
"substring",
")",
"{",
"$",
"substringLength",
"=",
"mb_strlen",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"endOfStr",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"this",
"->",
"length",
"(",
")",
"-",
"$",
"substringLength",
",",
"$",
"substringLength",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"return",
"(",
"string",
")",
"$",
"substring",
"===",
"$",
"endOfStr",
";",
"}"
] |
Checks whether the string ends with the given string. Case sensitive!
@see Text::endsWithIgnoreCase()
@param string|Text $substring The substring to look for
@return boolean
|
[
"Checks",
"whether",
"the",
"string",
"ends",
"with",
"the",
"given",
"string",
".",
"Case",
"sensitive!"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L433-L438
|
21,113 |
phootwork/lang
|
src/Text.php
|
Text.endsWithIgnoreCase
|
public function endsWithIgnoreCase($substring) {
$substring = mb_strtolower($substring, $this->encoding);
$substringLength = mb_strlen($substring, $this->encoding);
$endOfStr = mb_strtolower(mb_substr($this->string, $this->length() - $substringLength, $substringLength, $this->encoding));
return (string) $substring === $endOfStr;
}
|
php
|
public function endsWithIgnoreCase($substring) {
$substring = mb_strtolower($substring, $this->encoding);
$substringLength = mb_strlen($substring, $this->encoding);
$endOfStr = mb_strtolower(mb_substr($this->string, $this->length() - $substringLength, $substringLength, $this->encoding));
return (string) $substring === $endOfStr;
}
|
[
"public",
"function",
"endsWithIgnoreCase",
"(",
"$",
"substring",
")",
"{",
"$",
"substring",
"=",
"mb_strtolower",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"substringLength",
"=",
"mb_strlen",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"endOfStr",
"=",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"this",
"->",
"length",
"(",
")",
"-",
"$",
"substringLength",
",",
"$",
"substringLength",
",",
"$",
"this",
"->",
"encoding",
")",
")",
";",
"return",
"(",
"string",
")",
"$",
"substring",
"===",
"$",
"endOfStr",
";",
"}"
] |
Checks whether the string ends with the given string. Ingores case.
@see Text::endsWith()
@param string|Text $substring The substring to look for
@return boolean
|
[
"Checks",
"whether",
"the",
"string",
"ends",
"with",
"the",
"given",
"string",
".",
"Ingores",
"case",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L447-L453
|
21,114 |
phootwork/lang
|
src/Text.php
|
Text.pad
|
public function pad($length, $padding = ' ') {
$len = $length - $this->length();
return $this->applyPadding(floor($len / 2), ceil($len / 2), $padding);
}
|
php
|
public function pad($length, $padding = ' ') {
$len = $length - $this->length();
return $this->applyPadding(floor($len / 2), ceil($len / 2), $padding);
}
|
[
"public",
"function",
"pad",
"(",
"$",
"length",
",",
"$",
"padding",
"=",
"' '",
")",
"{",
"$",
"len",
"=",
"$",
"length",
"-",
"$",
"this",
"->",
"length",
"(",
")",
";",
"return",
"$",
"this",
"->",
"applyPadding",
"(",
"floor",
"(",
"$",
"len",
"/",
"2",
")",
",",
"ceil",
"(",
"$",
"len",
"/",
"2",
")",
",",
"$",
"padding",
")",
";",
"}"
] |
Adds padding to the start and end
@param int $length
@param string $padding
@return Text
|
[
"Adds",
"padding",
"to",
"the",
"start",
"and",
"end"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L530-L533
|
21,115 |
phootwork/lang
|
src/Text.php
|
Text.wrapWords
|
public function wrapWords($width = 75, $break = "\n", $cut = false) {
return new Text(wordwrap($this->string, $width, $break, $cut), $this->encoding);
}
|
php
|
public function wrapWords($width = 75, $break = "\n", $cut = false) {
return new Text(wordwrap($this->string, $width, $break, $cut), $this->encoding);
}
|
[
"public",
"function",
"wrapWords",
"(",
"$",
"width",
"=",
"75",
",",
"$",
"break",
"=",
"\"\\n\"",
",",
"$",
"cut",
"=",
"false",
")",
"{",
"return",
"new",
"Text",
"(",
"wordwrap",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"width",
",",
"$",
"break",
",",
"$",
"cut",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Returns a copy of the string wrapped at a given number of characters
@param int $width The number of characters at which the string will be wrapped.
@param string $break The line is broken using the optional break parameter.
@param bool $cut
If the cut is set to TRUE, the string is always wrapped at or before the specified
width. So if you have a word that is larger than the given width, it is broken apart.
@return Text Returns the string wrapped at the specified length.
|
[
"Returns",
"a",
"copy",
"of",
"the",
"string",
"wrapped",
"at",
"a",
"given",
"number",
"of",
"characters"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L616-L618
|
21,116 |
phootwork/lang
|
src/Text.php
|
Text.truncate
|
public function truncate($length, $substring = '') {
if ($this->length() <= $length) {
return new Text($this->string, $this->encoding);
}
$substrLen = mb_strlen($substring, $this->encoding);
if ($this->length() + $substrLen > $length) {
$length -= $substrLen;
}
return $this->substring(0, $length)->append($substring);
}
|
php
|
public function truncate($length, $substring = '') {
if ($this->length() <= $length) {
return new Text($this->string, $this->encoding);
}
$substrLen = mb_strlen($substring, $this->encoding);
if ($this->length() + $substrLen > $length) {
$length -= $substrLen;
}
return $this->substring(0, $length)->append($substring);
}
|
[
"public",
"function",
"truncate",
"(",
"$",
"length",
",",
"$",
"substring",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"length",
"(",
")",
"<=",
"$",
"length",
")",
"{",
"return",
"new",
"Text",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}",
"$",
"substrLen",
"=",
"mb_strlen",
"(",
"$",
"substring",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"if",
"(",
"$",
"this",
"->",
"length",
"(",
")",
"+",
"$",
"substrLen",
">",
"$",
"length",
")",
"{",
"$",
"length",
"-=",
"$",
"substrLen",
";",
"}",
"return",
"$",
"this",
"->",
"substring",
"(",
"0",
",",
"$",
"length",
")",
"->",
"append",
"(",
"$",
"substring",
")",
";",
"}"
] |
Truncates the string with a substring and ensures it doesn't exceed the given length
@param int $length
@param string $substring
@return Text
|
[
"Truncates",
"the",
"string",
"with",
"a",
"substring",
"and",
"ensures",
"it",
"doesn",
"t",
"exceed",
"the",
"given",
"length"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L648-L660
|
21,117 |
phootwork/lang
|
src/Text.php
|
Text.split
|
public function split($delimiter, $limit = PHP_INT_MAX) {
return new ArrayObject(explode($delimiter, $this->string, $limit));
}
|
php
|
public function split($delimiter, $limit = PHP_INT_MAX) {
return new ArrayObject(explode($delimiter, $this->string, $limit));
}
|
[
"public",
"function",
"split",
"(",
"$",
"delimiter",
",",
"$",
"limit",
"=",
"PHP_INT_MAX",
")",
"{",
"return",
"new",
"ArrayObject",
"(",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"this",
"->",
"string",
",",
"$",
"limit",
")",
")",
";",
"}"
] |
Splits the string by string
@param string $delimiter The boundary string.
@param integer $limit
If limit is set and positive, the returned array will contain a maximum of
limit elements with the last element containing the rest of string.
If the limit parameter is negative, all components except the last
-limit are returned.
If the limit parameter is zero, then this is treated as 1.
@return ArrayObject
Returns an array of strings created by splitting the string parameter on boundaries
formed by the delimiter.
If delimiter is an empty string (""), split() will return FALSE. If delimiter contains
a value that is not contained in string and a negative limit is used, then an empty
array will be returned, otherwise an array containing string will be returned.
@TODO: Maybe throw an exception or something on those odd delimiters?
|
[
"Splits",
"the",
"string",
"by",
"string"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L692-L694
|
21,118 |
phootwork/lang
|
src/Text.php
|
Text.join
|
public static function join(array $pieces, $glue = '', $encoding = null) {
return new Text(implode($pieces, $glue), $encoding);
}
|
php
|
public static function join(array $pieces, $glue = '', $encoding = null) {
return new Text(implode($pieces, $glue), $encoding);
}
|
[
"public",
"static",
"function",
"join",
"(",
"array",
"$",
"pieces",
",",
"$",
"glue",
"=",
"''",
",",
"$",
"encoding",
"=",
"null",
")",
"{",
"return",
"new",
"Text",
"(",
"implode",
"(",
"$",
"pieces",
",",
"$",
"glue",
")",
",",
"$",
"encoding",
")",
";",
"}"
] |
Join array elements with a string
@param array $pieces The array of strings to join.
@param string $glue Defaults to an empty string.
@param string $encoding the desired encoding
@return Text
Returns a string containing a string representation of all the array elements in the
same order, with the glue string between each element.
|
[
"Join",
"array",
"elements",
"with",
"a",
"string"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L706-L708
|
21,119 |
phootwork/lang
|
src/Text.php
|
Text.chunk
|
public function chunk($splitLength = 1) {
$this->verifyPositive($splitLength, 'The chunk length');
return new ArrayObject(str_split($this->string, $splitLength));
}
|
php
|
public function chunk($splitLength = 1) {
$this->verifyPositive($splitLength, 'The chunk length');
return new ArrayObject(str_split($this->string, $splitLength));
}
|
[
"public",
"function",
"chunk",
"(",
"$",
"splitLength",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"verifyPositive",
"(",
"$",
"splitLength",
",",
"'The chunk length'",
")",
";",
"return",
"new",
"ArrayObject",
"(",
"str_split",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"splitLength",
")",
")",
";",
"}"
] |
Convert the string to an array
@param int $splitLength Maximum length of the chunk.
@return ArrayObject
If the optional splitLength parameter is specified, the returned array will be
broken down into chunks with each being splitLength in length, otherwise each chunk
will be one character in length.
If the split_length length exceeds the length of string, the entire string is returned
as the first (and only) array element.
@throws \InvalidArgumentException If splitLength is less than 1.
|
[
"Convert",
"the",
"string",
"to",
"an",
"array"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L723-L727
|
21,120 |
phootwork/lang
|
src/Text.php
|
Text.toLowerCaseFirst
|
public function toLowerCaseFirst() {
$first = $this->substring(0, 1);
$rest = $this->substring(1);
return new Text(mb_strtolower($first, $this->encoding) . $rest, $this->encoding);
}
|
php
|
public function toLowerCaseFirst() {
$first = $this->substring(0, 1);
$rest = $this->substring(1);
return new Text(mb_strtolower($first, $this->encoding) . $rest, $this->encoding);
}
|
[
"public",
"function",
"toLowerCaseFirst",
"(",
")",
"{",
"$",
"first",
"=",
"$",
"this",
"->",
"substring",
"(",
"0",
",",
"1",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"substring",
"(",
"1",
")",
";",
"return",
"new",
"Text",
"(",
"mb_strtolower",
"(",
"$",
"first",
",",
"$",
"this",
"->",
"encoding",
")",
".",
"$",
"rest",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Transforms the string to first character lowercased
@return Text
|
[
"Transforms",
"the",
"string",
"to",
"first",
"character",
"lowercased"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L750-L755
|
21,121 |
phootwork/lang
|
src/Text.php
|
Text.toUpperCaseFirst
|
public function toUpperCaseFirst() {
$first = $this->substring(0, 1);
$rest = $this->substring(1);
return new Text(mb_strtoupper($first, $this->encoding) . $rest, $this->encoding);
}
|
php
|
public function toUpperCaseFirst() {
$first = $this->substring(0, 1);
$rest = $this->substring(1);
return new Text(mb_strtoupper($first, $this->encoding) . $rest, $this->encoding);
}
|
[
"public",
"function",
"toUpperCaseFirst",
"(",
")",
"{",
"$",
"first",
"=",
"$",
"this",
"->",
"substring",
"(",
"0",
",",
"1",
")",
";",
"$",
"rest",
"=",
"$",
"this",
"->",
"substring",
"(",
"1",
")",
";",
"return",
"new",
"Text",
"(",
"mb_strtoupper",
"(",
"$",
"first",
",",
"$",
"this",
"->",
"encoding",
")",
".",
"$",
"rest",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Transforms the string to first character uppercased
@return Text
|
[
"Transforms",
"the",
"string",
"to",
"first",
"character",
"uppercased"
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L771-L776
|
21,122 |
phootwork/lang
|
src/Text.php
|
Text.toCapitalCaseWords
|
public function toCapitalCaseWords() {
$encoding = $this->encoding;
return $this->split(' ')->map(function ($str) use ($encoding) {
return Text::create($str, $encoding)->toCapitalCase();
})->join(' ');
}
|
php
|
public function toCapitalCaseWords() {
$encoding = $this->encoding;
return $this->split(' ')->map(function ($str) use ($encoding) {
return Text::create($str, $encoding)->toCapitalCase();
})->join(' ');
}
|
[
"public",
"function",
"toCapitalCaseWords",
"(",
")",
"{",
"$",
"encoding",
"=",
"$",
"this",
"->",
"encoding",
";",
"return",
"$",
"this",
"->",
"split",
"(",
"' '",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"str",
")",
"use",
"(",
"$",
"encoding",
")",
"{",
"return",
"Text",
"::",
"create",
"(",
"$",
"str",
",",
"$",
"encoding",
")",
"->",
"toCapitalCase",
"(",
")",
";",
"}",
")",
"->",
"join",
"(",
"' '",
")",
";",
"}"
] |
Transforms the string with the words capitalized.
@return Text
|
[
"Transforms",
"the",
"string",
"with",
"the",
"words",
"capitalized",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L792-L797
|
21,123 |
phootwork/lang
|
src/Text.php
|
Text.toStudlyCase
|
public function toStudlyCase() {
$input = $this->trim('-_');
if ($input->isEmpty()) {
return $input;
}
$encoding = $this->encoding;
return Text::create(preg_replace_callback('/([A-Z-_][a-z0-9]+)/', function ($matches) use ($encoding) {
return Text::create($matches[0], $encoding)->replace(['-', '_'], '')->toUpperCaseFirst();
}, $input), $this->encoding)->toUpperCaseFirst();
}
|
php
|
public function toStudlyCase() {
$input = $this->trim('-_');
if ($input->isEmpty()) {
return $input;
}
$encoding = $this->encoding;
return Text::create(preg_replace_callback('/([A-Z-_][a-z0-9]+)/', function ($matches) use ($encoding) {
return Text::create($matches[0], $encoding)->replace(['-', '_'], '')->toUpperCaseFirst();
}, $input), $this->encoding)->toUpperCaseFirst();
}
|
[
"public",
"function",
"toStudlyCase",
"(",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"trim",
"(",
"'-_'",
")",
";",
"if",
"(",
"$",
"input",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"$",
"input",
";",
"}",
"$",
"encoding",
"=",
"$",
"this",
"->",
"encoding",
";",
"return",
"Text",
"::",
"create",
"(",
"preg_replace_callback",
"(",
"'/([A-Z-_][a-z0-9]+)/'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"encoding",
")",
"{",
"return",
"Text",
"::",
"create",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"$",
"encoding",
")",
"->",
"replace",
"(",
"[",
"'-'",
",",
"'_'",
"]",
",",
"''",
")",
"->",
"toUpperCaseFirst",
"(",
")",
";",
"}",
",",
"$",
"input",
")",
",",
"$",
"this",
"->",
"encoding",
")",
"->",
"toUpperCaseFirst",
"(",
")",
";",
"}"
] |
Converts this string into StudlyCase. Numbers are considered as part of its previous piece.
<code>
$var = new Text('my_own_variable');<br>
$var->toStudlyCase(); // MyOwnVariable
$var = new Text('my_test3_variable');<br>
$var->toStudlyCase(); // MyTest3Variable
</code>
@return Text
|
[
"Converts",
"this",
"string",
"into",
"StudlyCase",
".",
"Numbers",
"are",
"considered",
"as",
"part",
"of",
"its",
"previous",
"piece",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L846-L855
|
21,124 |
phootwork/lang
|
src/Text.php
|
Text.toKebabCase
|
public function toKebabCase() {
if ($this->contains('_')) {
return $this->replace('_', '-');
}
return new Text(mb_strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $this->string)), $this->encoding);
}
|
php
|
public function toKebabCase() {
if ($this->contains('_')) {
return $this->replace('_', '-');
}
return new Text(mb_strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1-$2', $this->string)), $this->encoding);
}
|
[
"public",
"function",
"toKebabCase",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"'_'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"replace",
"(",
"'_'",
",",
"'-'",
")",
";",
"}",
"return",
"new",
"Text",
"(",
"mb_strtolower",
"(",
"preg_replace",
"(",
"'/([a-z0-9])([A-Z])/'",
",",
"'$1-$2'",
",",
"$",
"this",
"->",
"string",
")",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Convert this string into kebab-case. Numbers are considered as part of its previous piece.
<code>
$var = new Text('myOwnVariable');<br>
$var->toKebapCase(); // my-own-variable
$var = new Text('myTest3Variable');<br>
$var->toKebapCase(); // my-test3-variable
</code>
@return Text
|
[
"Convert",
"this",
"string",
"into",
"kebab",
"-",
"case",
".",
"Numbers",
"are",
"considered",
"as",
"part",
"of",
"its",
"previous",
"piece",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L870-L876
|
21,125 |
phootwork/lang
|
src/Text.php
|
Text.toPlural
|
public function toPlural(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return new Text($pluralizer->getPluralForm($this->string), $this->encoding);
}
|
php
|
public function toPlural(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return new Text($pluralizer->getPluralForm($this->string), $this->encoding);
}
|
[
"public",
"function",
"toPlural",
"(",
"Pluralizer",
"$",
"pluralizer",
"=",
"null",
")",
"{",
"$",
"pluralizer",
"=",
"$",
"pluralizer",
"?",
":",
"new",
"EnglishPluralizer",
"(",
")",
";",
"return",
"new",
"Text",
"(",
"$",
"pluralizer",
"->",
"getPluralForm",
"(",
"$",
"this",
"->",
"string",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Get the plural form of the Text object.
@return Text
|
[
"Get",
"the",
"plural",
"form",
"of",
"the",
"Text",
"object",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L883-L887
|
21,126 |
phootwork/lang
|
src/Text.php
|
Text.toSingular
|
public function toSingular(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return new Text($pluralizer->getSingularForm($this->string), $this->encoding);
}
|
php
|
public function toSingular(Pluralizer $pluralizer = null) {
$pluralizer = $pluralizer ?: new EnglishPluralizer();
return new Text($pluralizer->getSingularForm($this->string), $this->encoding);
}
|
[
"public",
"function",
"toSingular",
"(",
"Pluralizer",
"$",
"pluralizer",
"=",
"null",
")",
"{",
"$",
"pluralizer",
"=",
"$",
"pluralizer",
"?",
":",
"new",
"EnglishPluralizer",
"(",
")",
";",
"return",
"new",
"Text",
"(",
"$",
"pluralizer",
"->",
"getSingularForm",
"(",
"$",
"this",
"->",
"string",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Get the singular form of the Text object.
@return Text
|
[
"Get",
"the",
"singular",
"form",
"of",
"the",
"Text",
"object",
"."
] |
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
|
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/Text.php#L894-L898
|
21,127 |
rhosocial/yii2-user
|
security/PasswordHistory.php
|
PasswordHistory.isUsed
|
public static function isUsed($password, $user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
$passwords = static::find()->createdBy($user)->all();
foreach ($passwords as $p) {
/* @var $p static */
if ($p->validatePassword($password)) {
return $p;
}
}
return false;
}
|
php
|
public static function isUsed($password, $user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
$passwords = static::find()->createdBy($user)->all();
foreach ($passwords as $p) {
/* @var $p static */
if ($p->validatePassword($password)) {
return $p;
}
}
return false;
}
|
[
"public",
"static",
"function",
"isUsed",
"(",
"$",
"password",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"User",
"::",
"isValid",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'User Invalid.'",
")",
";",
"}",
"$",
"passwords",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"user",
")",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"passwords",
"as",
"$",
"p",
")",
"{",
"/* @var $p static */",
"if",
"(",
"$",
"p",
"->",
"validatePassword",
"(",
"$",
"password",
")",
")",
"{",
"return",
"$",
"p",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check whether the password has been used.
@param string $password Password or Password Hash.
@param User $user
@return false|static The first validated password model, or false if not validated.
|
[
"Check",
"whether",
"the",
"password",
"has",
"been",
"used",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/PasswordHistory.php#L62-L75
|
21,128 |
rhosocial/yii2-user
|
security/PasswordHistory.php
|
PasswordHistory.add
|
public static function add($password, $user = null)
{
if (static::isUsed($password, $user) && !$user->allowUsedPassword) {
throw new InvalidParamException('Password existed.');
}
if (static::judgePasswordHash($password)) {
$passwordHistory = $user->create(static::class);
$passwordHistory->{$passwordHistory->passwordHashAttribute} = $password;
} else {
$passwordHistory = $user->create(static::class, ['password' => $password]);
}
/* @var $passwordHistory static */
return $passwordHistory->save();
}
|
php
|
public static function add($password, $user = null)
{
if (static::isUsed($password, $user) && !$user->allowUsedPassword) {
throw new InvalidParamException('Password existed.');
}
if (static::judgePasswordHash($password)) {
$passwordHistory = $user->create(static::class);
$passwordHistory->{$passwordHistory->passwordHashAttribute} = $password;
} else {
$passwordHistory = $user->create(static::class, ['password' => $password]);
}
/* @var $passwordHistory static */
return $passwordHistory->save();
}
|
[
"public",
"static",
"function",
"add",
"(",
"$",
"password",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"static",
"::",
"isUsed",
"(",
"$",
"password",
",",
"$",
"user",
")",
"&&",
"!",
"$",
"user",
"->",
"allowUsedPassword",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'Password existed.'",
")",
";",
"}",
"if",
"(",
"static",
"::",
"judgePasswordHash",
"(",
"$",
"password",
")",
")",
"{",
"$",
"passwordHistory",
"=",
"$",
"user",
"->",
"create",
"(",
"static",
"::",
"class",
")",
";",
"$",
"passwordHistory",
"->",
"{",
"$",
"passwordHistory",
"->",
"passwordHashAttribute",
"}",
"=",
"$",
"password",
";",
"}",
"else",
"{",
"$",
"passwordHistory",
"=",
"$",
"user",
"->",
"create",
"(",
"static",
"::",
"class",
",",
"[",
"'password'",
"=>",
"$",
"password",
"]",
")",
";",
"}",
"/* @var $passwordHistory static */",
"return",
"$",
"passwordHistory",
"->",
"save",
"(",
")",
";",
"}"
] |
Add password to history.
@param string $password Password or Password Hash.
@param User $user
@return boolean
@throws InvalidParamException throw if password existed.
|
[
"Add",
"password",
"to",
"history",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/PasswordHistory.php#L99-L112
|
21,129 |
rhosocial/yii2-user
|
security/PasswordHistory.php
|
PasswordHistory.first
|
public static function first($user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
return static::find()->createdBy($user)->orderByCreatedAt()->one();
}
|
php
|
public static function first($user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
return static::find()->createdBy($user)->orderByCreatedAt()->one();
}
|
[
"public",
"static",
"function",
"first",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"User",
"::",
"isValid",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'User Invalid.'",
")",
";",
"}",
"return",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"user",
")",
"->",
"orderByCreatedAt",
"(",
")",
"->",
"one",
"(",
")",
";",
"}"
] |
Get first password hash.
@param User $user
@return static
@throws InvalidParamException throw if user invalid.
|
[
"Get",
"first",
"password",
"hash",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/PasswordHistory.php#L146-L152
|
21,130 |
rhosocial/yii2-user
|
security/PasswordHistory.php
|
PasswordHistory.last
|
public static function last($user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
return static::find()->createdBy($user)->orderByCreatedAt(SORT_DESC)->one();
}
|
php
|
public static function last($user = null)
{
if (!User::isValid($user)) {
throw new InvalidParamException('User Invalid.');
}
return static::find()->createdBy($user)->orderByCreatedAt(SORT_DESC)->one();
}
|
[
"public",
"static",
"function",
"last",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"User",
"::",
"isValid",
"(",
"$",
"user",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"'User Invalid.'",
")",
";",
"}",
"return",
"static",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"user",
")",
"->",
"orderByCreatedAt",
"(",
"SORT_DESC",
")",
"->",
"one",
"(",
")",
";",
"}"
] |
Get last password hash.
@param User $user
@return static
@throws InvalidParamException throw if user invalid.
|
[
"Get",
"last",
"password",
"hash",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/PasswordHistory.php#L161-L167
|
21,131 |
jaxon-php/jaxon-jquery
|
src/Dom/Action.php
|
Action.getScript
|
public function getScript()
{
$this->useSingleQuotes();
foreach($this->aArguments as $xArgument)
{
if($xArgument instanceof Element)
{
$this->addParameter(Jaxon::JS_VALUE, $xArgument->getScript());
}
else if($xArgument instanceof Parameter)
{
$this->addParameter($xArgument->getType(), $xArgument->getValue());
}
else if($xArgument instanceof Request)
{
$this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xArgument->getScript() . ';}');
}
else if(is_numeric($xArgument))
{
$this->addParameter(Jaxon::NUMERIC_VALUE, $xArgument);
}
else if(is_string($xArgument))
{
$this->addParameter(Jaxon::QUOTED_VALUE, $xArgument);
}
else if(is_bool($xArgument))
{
$this->addParameter(Jaxon::BOOL_VALUE, $xArgument);
}
else if(is_array($xArgument) || is_object($xArgument))
{
$this->addParameter(Jaxon::JS_VALUE, $xArgument);
}
}
return $this->sMethod . '(' . implode(', ', $this->aParameters) . ')';
}
|
php
|
public function getScript()
{
$this->useSingleQuotes();
foreach($this->aArguments as $xArgument)
{
if($xArgument instanceof Element)
{
$this->addParameter(Jaxon::JS_VALUE, $xArgument->getScript());
}
else if($xArgument instanceof Parameter)
{
$this->addParameter($xArgument->getType(), $xArgument->getValue());
}
else if($xArgument instanceof Request)
{
$this->addParameter(Jaxon::JS_VALUE, 'function(){' . $xArgument->getScript() . ';}');
}
else if(is_numeric($xArgument))
{
$this->addParameter(Jaxon::NUMERIC_VALUE, $xArgument);
}
else if(is_string($xArgument))
{
$this->addParameter(Jaxon::QUOTED_VALUE, $xArgument);
}
else if(is_bool($xArgument))
{
$this->addParameter(Jaxon::BOOL_VALUE, $xArgument);
}
else if(is_array($xArgument) || is_object($xArgument))
{
$this->addParameter(Jaxon::JS_VALUE, $xArgument);
}
}
return $this->sMethod . '(' . implode(', ', $this->aParameters) . ')';
}
|
[
"public",
"function",
"getScript",
"(",
")",
"{",
"$",
"this",
"->",
"useSingleQuotes",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"aArguments",
"as",
"$",
"xArgument",
")",
"{",
"if",
"(",
"$",
"xArgument",
"instanceof",
"Element",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"JS_VALUE",
",",
"$",
"xArgument",
"->",
"getScript",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"xArgument",
"instanceof",
"Parameter",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"$",
"xArgument",
"->",
"getType",
"(",
")",
",",
"$",
"xArgument",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"xArgument",
"instanceof",
"Request",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"JS_VALUE",
",",
"'function(){'",
".",
"$",
"xArgument",
"->",
"getScript",
"(",
")",
".",
"';}'",
")",
";",
"}",
"else",
"if",
"(",
"is_numeric",
"(",
"$",
"xArgument",
")",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"NUMERIC_VALUE",
",",
"$",
"xArgument",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"xArgument",
")",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"QUOTED_VALUE",
",",
"$",
"xArgument",
")",
";",
"}",
"else",
"if",
"(",
"is_bool",
"(",
"$",
"xArgument",
")",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"BOOL_VALUE",
",",
"$",
"xArgument",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"xArgument",
")",
"||",
"is_object",
"(",
"$",
"xArgument",
")",
")",
"{",
"$",
"this",
"->",
"addParameter",
"(",
"Jaxon",
"::",
"JS_VALUE",
",",
"$",
"xArgument",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"sMethod",
".",
"'('",
".",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"aParameters",
")",
".",
"')'",
";",
"}"
] |
Return a string representation of the call to this jQuery function
@return string
|
[
"Return",
"a",
"string",
"representation",
"of",
"the",
"call",
"to",
"this",
"jQuery",
"function"
] |
90766a8ea8a4124a3f110e96b316370f71762380
|
https://github.com/jaxon-php/jaxon-jquery/blob/90766a8ea8a4124a3f110e96b316370f71762380/src/Dom/Action.php#L41-L76
|
21,132 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/rfc822_parser.php
|
ezcMailRfc822Parser.parseBody
|
public function parseBody( $origLine )
{
$line = rtrim( $origLine, "\r\n" );
if ( $this->parserState == self::PARSE_STATE_HEADERS && $line == '' )
{
$this->parserState = self::PARSE_STATE_BODY;
// clean up headers for the part
// the rest of the headers should be set on the mail object.
$headers = new ezcMailHeadersHolder();
$headers['Content-Type'] = $this->headers['Content-Type'];
if ( isset( $this->headers['Content-Transfer-Encoding'] ) )
{
$headers['Content-Transfer-Encoding'] = $this->headers['Content-Transfer-Encoding'];
}
if ( isset( $this->headers['Content-Disposition'] ) )
{
$headers['Content-Disposition'] = $this->headers['Content-Disposition'];
}
// get the correct body type
$this->bodyParser = self::createPartParserForHeaders( $headers );
}
else if ( $this->parserState == self::PARSE_STATE_HEADERS )
{
$this->parseHeader( $line, $this->headers );
}
else // we are parsing headers
{
$this->bodyParser->parseBody( $origLine );
}
}
|
php
|
public function parseBody( $origLine )
{
$line = rtrim( $origLine, "\r\n" );
if ( $this->parserState == self::PARSE_STATE_HEADERS && $line == '' )
{
$this->parserState = self::PARSE_STATE_BODY;
// clean up headers for the part
// the rest of the headers should be set on the mail object.
$headers = new ezcMailHeadersHolder();
$headers['Content-Type'] = $this->headers['Content-Type'];
if ( isset( $this->headers['Content-Transfer-Encoding'] ) )
{
$headers['Content-Transfer-Encoding'] = $this->headers['Content-Transfer-Encoding'];
}
if ( isset( $this->headers['Content-Disposition'] ) )
{
$headers['Content-Disposition'] = $this->headers['Content-Disposition'];
}
// get the correct body type
$this->bodyParser = self::createPartParserForHeaders( $headers );
}
else if ( $this->parserState == self::PARSE_STATE_HEADERS )
{
$this->parseHeader( $line, $this->headers );
}
else // we are parsing headers
{
$this->bodyParser->parseBody( $origLine );
}
}
|
[
"public",
"function",
"parseBody",
"(",
"$",
"origLine",
")",
"{",
"$",
"line",
"=",
"rtrim",
"(",
"$",
"origLine",
",",
"\"\\r\\n\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_HEADERS",
"&&",
"$",
"line",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"parserState",
"=",
"self",
"::",
"PARSE_STATE_BODY",
";",
"// clean up headers for the part",
"// the rest of the headers should be set on the mail object.",
"$",
"headers",
"=",
"new",
"ezcMailHeadersHolder",
"(",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"$",
"this",
"->",
"headers",
"[",
"'Content-Type'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
"=",
"$",
"this",
"->",
"headers",
"[",
"'Content-Transfer-Encoding'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"'Content-Disposition'",
"]",
"=",
"$",
"this",
"->",
"headers",
"[",
"'Content-Disposition'",
"]",
";",
"}",
"// get the correct body type",
"$",
"this",
"->",
"bodyParser",
"=",
"self",
"::",
"createPartParserForHeaders",
"(",
"$",
"headers",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_HEADERS",
")",
"{",
"$",
"this",
"->",
"parseHeader",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"headers",
")",
";",
"}",
"else",
"// we are parsing headers",
"{",
"$",
"this",
"->",
"bodyParser",
"->",
"parseBody",
"(",
"$",
"origLine",
")",
";",
"}",
"}"
] |
Parses the body of an rfc 2822 message.
@throws ezcBaseFileNotFoundException
if a neccessary temporary file could not be openened.
@param string $origLine
|
[
"Parses",
"the",
"body",
"of",
"an",
"rfc",
"2822",
"message",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/rfc822_parser.php#L71-L104
|
21,133 |
spiderling-php/spiderling
|
src/CrawlerSession.php
|
CrawlerSession.saveHtml
|
public function saveHtml($filename, $base = null)
{
$this->ensureWritableDirectory(dirname($filename));
$html = new Html($this->getHtml());
if (null !== $base) {
$html->resolveLinks(\GuzzleHttp\Psr7\uri_for($base));
}
file_put_contents($filename, $html->get());
return $this;
}
|
php
|
public function saveHtml($filename, $base = null)
{
$this->ensureWritableDirectory(dirname($filename));
$html = new Html($this->getHtml());
if (null !== $base) {
$html->resolveLinks(\GuzzleHttp\Psr7\uri_for($base));
}
file_put_contents($filename, $html->get());
return $this;
}
|
[
"public",
"function",
"saveHtml",
"(",
"$",
"filename",
",",
"$",
"base",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"ensureWritableDirectory",
"(",
"dirname",
"(",
"$",
"filename",
")",
")",
";",
"$",
"html",
"=",
"new",
"Html",
"(",
"$",
"this",
"->",
"getHtml",
"(",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"base",
")",
"{",
"$",
"html",
"->",
"resolveLinks",
"(",
"\\",
"GuzzleHttp",
"\\",
"Psr7",
"\\",
"uri_for",
"(",
"$",
"base",
")",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"html",
"->",
"get",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Save the HTML of the session into a file
Optionally resolve all the links with a base uri
@param string $filename
@throws InvalidArgumentException if directory doesnt exist or is not writable
@param UriInterface|string $base
|
[
"Save",
"the",
"HTML",
"of",
"the",
"session",
"into",
"a",
"file",
"Optionally",
"resolve",
"all",
"the",
"links",
"with",
"a",
"base",
"uri"
] |
030d70fb71c89256e3b256dda7fa4c47751d9c53
|
https://github.com/spiderling-php/spiderling/blob/030d70fb71c89256e3b256dda7fa4c47751d9c53/src/CrawlerSession.php#L85-L98
|
21,134 |
fccn/oai-pmh-core
|
src/libs/phprop.php
|
Phprop.parse
|
public static function parse($filename, $del=".")
{
if (is_null(self::$_instance)) {
self::$_instance = new self($filename, $del);
}
return self::$_instance->getObj();
//return self::$_instance;
}
|
php
|
public static function parse($filename, $del=".")
{
if (is_null(self::$_instance)) {
self::$_instance = new self($filename, $del);
}
return self::$_instance->getObj();
//return self::$_instance;
}
|
[
"public",
"static",
"function",
"parse",
"(",
"$",
"filename",
",",
"$",
"del",
"=",
"\".\"",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"_instance",
")",
")",
"{",
"self",
"::",
"$",
"_instance",
"=",
"new",
"self",
"(",
"$",
"filename",
",",
"$",
"del",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_instance",
"->",
"getObj",
"(",
")",
";",
"//return self::$_instance;",
"}"
] |
Singleton pattern constructor
@param string ini filename
@param string delimiter, it is '.' by default but can be changed
@return object : object containing ini data
|
[
"Singleton",
"pattern",
"constructor"
] |
a9c6852482c7bd7c48911a2165120325ecc27ea2
|
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/libs/phprop.php#L91-L98
|
21,135 |
fccn/oai-pmh-core
|
src/libs/phprop.php
|
Phprop._parseIni
|
private function _parseIni($iniFile)
{
$aParsedIni = parse_ini_file($iniFile, true, INI_SCANNER_RAW);
$tmpArray = array();
foreach ($aParsedIni as $key=>$value) {
if (strpos($key, ':') !== false) {
$sections = explode(':', $key);
if (count($sections) != 2) {
throw new Exception('Malformed section header!');
}
$currentSection = trim($sections[0]);
$parentSection = trim($sections[1]);
$value = array_merge_recursive(
$aParsedIni[$parentSection],
$aParsedIni[$key]
);
$aParsedIni[$currentSection] = $value;
unset($aParsedIni[$key]);
$key = $currentSection;
}
if (is_array($value)) {
foreach ($value as $vk=>$vv) {
$newKey = $key.".".$vk;
$tmpArray[$newKey] = $vv;
if (
is_string($vv) &&
preg_match_all('/\${([a-zA-Z0-9\.]+)}/', $vv, $match)
) {
if (!isset($match[1])) {
continue;
}
$variableKey = $match[1];
foreach ($variableKey as &$var) {
if (strpos($var, '.') === false) {
$var = $key . '.' . $var;
}
}
$this->_varDeps[$newKey] = $variableKey;
}
}
}
}
if (!empty($tmpArray)) {
$aParsedIni = $tmpArray;
}
foreach ($aParsedIni as $key=>$value) { //extract parsed array keys
if (array_key_exists($key, $this->_varDeps)) {
$deps = &$this->_varDeps;
$value = preg_replace_callback(
'/\${([a-zA-Z0-9\.]+)}/',
function ($match) use ($key, $aParsedIni, &$deps) {
return $aParsedIni[array_shift($deps[$key])];
},
$value
);
$aParsedIni[$key] = $value;
}
$this->_tmpValue = $value;//set temporay value to current ini value
$aXKey = explode($this->_delimiter, $key); //get ini key segments
//set object properties recursively based on parsed ini
$this->_recursiveInit($this->_obj, $aXKey);
}
}
|
php
|
private function _parseIni($iniFile)
{
$aParsedIni = parse_ini_file($iniFile, true, INI_SCANNER_RAW);
$tmpArray = array();
foreach ($aParsedIni as $key=>$value) {
if (strpos($key, ':') !== false) {
$sections = explode(':', $key);
if (count($sections) != 2) {
throw new Exception('Malformed section header!');
}
$currentSection = trim($sections[0]);
$parentSection = trim($sections[1]);
$value = array_merge_recursive(
$aParsedIni[$parentSection],
$aParsedIni[$key]
);
$aParsedIni[$currentSection] = $value;
unset($aParsedIni[$key]);
$key = $currentSection;
}
if (is_array($value)) {
foreach ($value as $vk=>$vv) {
$newKey = $key.".".$vk;
$tmpArray[$newKey] = $vv;
if (
is_string($vv) &&
preg_match_all('/\${([a-zA-Z0-9\.]+)}/', $vv, $match)
) {
if (!isset($match[1])) {
continue;
}
$variableKey = $match[1];
foreach ($variableKey as &$var) {
if (strpos($var, '.') === false) {
$var = $key . '.' . $var;
}
}
$this->_varDeps[$newKey] = $variableKey;
}
}
}
}
if (!empty($tmpArray)) {
$aParsedIni = $tmpArray;
}
foreach ($aParsedIni as $key=>$value) { //extract parsed array keys
if (array_key_exists($key, $this->_varDeps)) {
$deps = &$this->_varDeps;
$value = preg_replace_callback(
'/\${([a-zA-Z0-9\.]+)}/',
function ($match) use ($key, $aParsedIni, &$deps) {
return $aParsedIni[array_shift($deps[$key])];
},
$value
);
$aParsedIni[$key] = $value;
}
$this->_tmpValue = $value;//set temporay value to current ini value
$aXKey = explode($this->_delimiter, $key); //get ini key segments
//set object properties recursively based on parsed ini
$this->_recursiveInit($this->_obj, $aXKey);
}
}
|
[
"private",
"function",
"_parseIni",
"(",
"$",
"iniFile",
")",
"{",
"$",
"aParsedIni",
"=",
"parse_ini_file",
"(",
"$",
"iniFile",
",",
"true",
",",
"INI_SCANNER_RAW",
")",
";",
"$",
"tmpArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aParsedIni",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"$",
"sections",
"=",
"explode",
"(",
"':'",
",",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sections",
")",
"!=",
"2",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Malformed section header!'",
")",
";",
"}",
"$",
"currentSection",
"=",
"trim",
"(",
"$",
"sections",
"[",
"0",
"]",
")",
";",
"$",
"parentSection",
"=",
"trim",
"(",
"$",
"sections",
"[",
"1",
"]",
")",
";",
"$",
"value",
"=",
"array_merge_recursive",
"(",
"$",
"aParsedIni",
"[",
"$",
"parentSection",
"]",
",",
"$",
"aParsedIni",
"[",
"$",
"key",
"]",
")",
";",
"$",
"aParsedIni",
"[",
"$",
"currentSection",
"]",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"aParsedIni",
"[",
"$",
"key",
"]",
")",
";",
"$",
"key",
"=",
"$",
"currentSection",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"vk",
"=>",
"$",
"vv",
")",
"{",
"$",
"newKey",
"=",
"$",
"key",
".",
"\".\"",
".",
"$",
"vk",
";",
"$",
"tmpArray",
"[",
"$",
"newKey",
"]",
"=",
"$",
"vv",
";",
"if",
"(",
"is_string",
"(",
"$",
"vv",
")",
"&&",
"preg_match_all",
"(",
"'/\\${([a-zA-Z0-9\\.]+)}/'",
",",
"$",
"vv",
",",
"$",
"match",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"variableKey",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"foreach",
"(",
"$",
"variableKey",
"as",
"&",
"$",
"var",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"var",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"var",
"=",
"$",
"key",
".",
"'.'",
".",
"$",
"var",
";",
"}",
"}",
"$",
"this",
"->",
"_varDeps",
"[",
"$",
"newKey",
"]",
"=",
"$",
"variableKey",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"tmpArray",
")",
")",
"{",
"$",
"aParsedIni",
"=",
"$",
"tmpArray",
";",
"}",
"foreach",
"(",
"$",
"aParsedIni",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//extract parsed array keys",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_varDeps",
")",
")",
"{",
"$",
"deps",
"=",
"&",
"$",
"this",
"->",
"_varDeps",
";",
"$",
"value",
"=",
"preg_replace_callback",
"(",
"'/\\${([a-zA-Z0-9\\.]+)}/'",
",",
"function",
"(",
"$",
"match",
")",
"use",
"(",
"$",
"key",
",",
"$",
"aParsedIni",
",",
"&",
"$",
"deps",
")",
"{",
"return",
"$",
"aParsedIni",
"[",
"array_shift",
"(",
"$",
"deps",
"[",
"$",
"key",
"]",
")",
"]",
";",
"}",
",",
"$",
"value",
")",
";",
"$",
"aParsedIni",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_tmpValue",
"=",
"$",
"value",
";",
"//set temporay value to current ini value",
"$",
"aXKey",
"=",
"explode",
"(",
"$",
"this",
"->",
"_delimiter",
",",
"$",
"key",
")",
";",
"//get ini key segments",
"//set object properties recursively based on parsed ini",
"$",
"this",
"->",
"_recursiveInit",
"(",
"$",
"this",
"->",
"_obj",
",",
"$",
"aXKey",
")",
";",
"}",
"}"
] |
Parses ini file and extract its keys and prepare it for object creation
|
[
"Parses",
"ini",
"file",
"and",
"extract",
"its",
"keys",
"and",
"prepare",
"it",
"for",
"object",
"creation"
] |
a9c6852482c7bd7c48911a2165120325ecc27ea2
|
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/libs/phprop.php#L103-L165
|
21,136 |
hametuha/wpametu
|
src/WPametu/File/Image.php
|
Image.trim
|
public function trim( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ){
$editor = wp_get_image_editor( $file );
if ( is_wp_error( $editor ) )
return $editor;
$editor->set_quality( $jpeg_quality );
$resized = $editor->resize( $max_w, $max_h, $crop );
if ( is_wp_error( $resized ) )
return $resized;
$dest_file = $editor->generate_filename( $suffix, $dest_path );
$saved = $editor->save( $dest_file );
if ( is_wp_error( $saved ) )
return $saved;
return $dest_file;
}
|
php
|
public function trim( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ){
$editor = wp_get_image_editor( $file );
if ( is_wp_error( $editor ) )
return $editor;
$editor->set_quality( $jpeg_quality );
$resized = $editor->resize( $max_w, $max_h, $crop );
if ( is_wp_error( $resized ) )
return $resized;
$dest_file = $editor->generate_filename( $suffix, $dest_path );
$saved = $editor->save( $dest_file );
if ( is_wp_error( $saved ) )
return $saved;
return $dest_file;
}
|
[
"public",
"function",
"trim",
"(",
"$",
"file",
",",
"$",
"max_w",
",",
"$",
"max_h",
",",
"$",
"crop",
"=",
"false",
",",
"$",
"suffix",
"=",
"null",
",",
"$",
"dest_path",
"=",
"null",
",",
"$",
"jpeg_quality",
"=",
"90",
")",
"{",
"$",
"editor",
"=",
"wp_get_image_editor",
"(",
"$",
"file",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"editor",
")",
")",
"return",
"$",
"editor",
";",
"$",
"editor",
"->",
"set_quality",
"(",
"$",
"jpeg_quality",
")",
";",
"$",
"resized",
"=",
"$",
"editor",
"->",
"resize",
"(",
"$",
"max_w",
",",
"$",
"max_h",
",",
"$",
"crop",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"resized",
")",
")",
"return",
"$",
"resized",
";",
"$",
"dest_file",
"=",
"$",
"editor",
"->",
"generate_filename",
"(",
"$",
"suffix",
",",
"$",
"dest_path",
")",
";",
"$",
"saved",
"=",
"$",
"editor",
"->",
"save",
"(",
"$",
"dest_file",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"saved",
")",
")",
"return",
"$",
"saved",
";",
"return",
"$",
"dest_file",
";",
"}"
] |
Clone of image resize
@see image_resize
@param string $file Image file path.
@param int $max_w Maximum width to resize to.
@param int $max_h Maximum height to resize to.
@param bool $crop Optional. Whether to crop image or resize.
@param string $suffix Optional. File suffix.
@param string $dest_path Optional. New image file path.
@param int $jpeg_quality Optional, default is 90. Image quality percentage.
@return mixed WP_Error on failure. String with new destination path.
|
[
"Clone",
"of",
"image",
"resize"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/File/Image.php#L39-L56
|
21,137 |
hametuha/wpametu
|
src/WPametu/File/Image.php
|
Image.fit
|
public function fit($src, $dest, $width, $height){
// Calculate
$size = getimagesize($src);
$ratio = max($width / $size[0], $height / $size[1]);
$old_width = $size[0];
$old_height = $size[1];
$new_width = intval($old_width * $ratio);
$new_height = intval($old_height * $ratio);
// Resize
@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$image = imagecreatefromstring( file_get_contents( $src ) );
$new_image = wp_imagecreatetruecolor( $new_width, $new_height );
imagecopyresampled( $new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
if ( IMAGETYPE_PNG == $size[2] && function_exists('imageistruecolor') && !imageistruecolor( $image ) ){
imagetruecolortopalette( $new_image, false, imagecolorstotal( $image ) );
}
// Destroy old image
imagedestroy( $image );
// Save
switch($size[2]){
case IMAGETYPE_GIF:
$result = imagegif($new_image, $dest);
break;
case IMAGETYPE_PNG:
$result = imagepng($new_image, $dest);
break;
default:
$result = imagejpeg($new_image, $dest);
break;
}
imagedestroy($new_image);
return $result;
}
|
php
|
public function fit($src, $dest, $width, $height){
// Calculate
$size = getimagesize($src);
$ratio = max($width / $size[0], $height / $size[1]);
$old_width = $size[0];
$old_height = $size[1];
$new_width = intval($old_width * $ratio);
$new_height = intval($old_height * $ratio);
// Resize
@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$image = imagecreatefromstring( file_get_contents( $src ) );
$new_image = wp_imagecreatetruecolor( $new_width, $new_height );
imagecopyresampled( $new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
if ( IMAGETYPE_PNG == $size[2] && function_exists('imageistruecolor') && !imageistruecolor( $image ) ){
imagetruecolortopalette( $new_image, false, imagecolorstotal( $image ) );
}
// Destroy old image
imagedestroy( $image );
// Save
switch($size[2]){
case IMAGETYPE_GIF:
$result = imagegif($new_image, $dest);
break;
case IMAGETYPE_PNG:
$result = imagepng($new_image, $dest);
break;
default:
$result = imagejpeg($new_image, $dest);
break;
}
imagedestroy($new_image);
return $result;
}
|
[
"public",
"function",
"fit",
"(",
"$",
"src",
",",
"$",
"dest",
",",
"$",
"width",
",",
"$",
"height",
")",
"{",
"// Calculate",
"$",
"size",
"=",
"getimagesize",
"(",
"$",
"src",
")",
";",
"$",
"ratio",
"=",
"max",
"(",
"$",
"width",
"/",
"$",
"size",
"[",
"0",
"]",
",",
"$",
"height",
"/",
"$",
"size",
"[",
"1",
"]",
")",
";",
"$",
"old_width",
"=",
"$",
"size",
"[",
"0",
"]",
";",
"$",
"old_height",
"=",
"$",
"size",
"[",
"1",
"]",
";",
"$",
"new_width",
"=",
"intval",
"(",
"$",
"old_width",
"*",
"$",
"ratio",
")",
";",
"$",
"new_height",
"=",
"intval",
"(",
"$",
"old_height",
"*",
"$",
"ratio",
")",
";",
"// Resize",
"@",
"ini_set",
"(",
"'memory_limit'",
",",
"apply_filters",
"(",
"'image_memory_limit'",
",",
"WP_MAX_MEMORY_LIMIT",
")",
")",
";",
"$",
"image",
"=",
"imagecreatefromstring",
"(",
"file_get_contents",
"(",
"$",
"src",
")",
")",
";",
"$",
"new_image",
"=",
"wp_imagecreatetruecolor",
"(",
"$",
"new_width",
",",
"$",
"new_height",
")",
";",
"imagecopyresampled",
"(",
"$",
"new_image",
",",
"$",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"new_width",
",",
"$",
"new_height",
",",
"$",
"old_width",
",",
"$",
"old_height",
")",
";",
"if",
"(",
"IMAGETYPE_PNG",
"==",
"$",
"size",
"[",
"2",
"]",
"&&",
"function_exists",
"(",
"'imageistruecolor'",
")",
"&&",
"!",
"imageistruecolor",
"(",
"$",
"image",
")",
")",
"{",
"imagetruecolortopalette",
"(",
"$",
"new_image",
",",
"false",
",",
"imagecolorstotal",
"(",
"$",
"image",
")",
")",
";",
"}",
"// Destroy old image",
"imagedestroy",
"(",
"$",
"image",
")",
";",
"// Save",
"switch",
"(",
"$",
"size",
"[",
"2",
"]",
")",
"{",
"case",
"IMAGETYPE_GIF",
":",
"$",
"result",
"=",
"imagegif",
"(",
"$",
"new_image",
",",
"$",
"dest",
")",
";",
"break",
";",
"case",
"IMAGETYPE_PNG",
":",
"$",
"result",
"=",
"imagepng",
"(",
"$",
"new_image",
",",
"$",
"dest",
")",
";",
"break",
";",
"default",
":",
"$",
"result",
"=",
"imagejpeg",
"(",
"$",
"new_image",
",",
"$",
"dest",
")",
";",
"break",
";",
"}",
"imagedestroy",
"(",
"$",
"new_image",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Fit small image to specified bound
@param string $src
@param string $dest
@param int $width
@param int $height
@return bool
|
[
"Fit",
"small",
"image",
"to",
"specified",
"bound"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/File/Image.php#L67-L99
|
21,138 |
blast-project/BaseEntitiesBundle
|
src/Controller/SearchController.php
|
SearchController.retrieveFormFieldDescription
|
private function retrieveFormFieldDescription(AdminInterface $admin, $field)
{
$admin->getFormFieldDescriptions();
$fieldDescription = $admin->getFormFieldDescription($field);
if (!$fieldDescription) {
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}
if (null === $fieldDescription->getTargetEntity()) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}
return $fieldDescription;
}
|
php
|
private function retrieveFormFieldDescription(AdminInterface $admin, $field)
{
$admin->getFormFieldDescriptions();
$fieldDescription = $admin->getFormFieldDescription($field);
if (!$fieldDescription) {
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}
if (null === $fieldDescription->getTargetEntity()) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}
return $fieldDescription;
}
|
[
"private",
"function",
"retrieveFormFieldDescription",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"field",
")",
"{",
"$",
"admin",
"->",
"getFormFieldDescriptions",
"(",
")",
";",
"$",
"fieldDescription",
"=",
"$",
"admin",
"->",
"getFormFieldDescription",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"$",
"fieldDescription",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The field \"%s\" does not exist.'",
",",
"$",
"field",
")",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"fieldDescription",
"->",
"getTargetEntity",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'No associated entity with field \"%s\".'",
",",
"$",
"field",
")",
")",
";",
"}",
"return",
"$",
"fieldDescription",
";",
"}"
] |
Retrieve the form field description given by field name.
Copied from Sonata\AdminBundle\Controller\HelperController.
@param AdminInterface $admin
@param string $field
@return FormInterface
@throws \RuntimeException
|
[
"Retrieve",
"the",
"form",
"field",
"description",
"given",
"by",
"field",
"name",
".",
"Copied",
"from",
"Sonata",
"\\",
"AdminBundle",
"\\",
"Controller",
"\\",
"HelperController",
"."
] |
abd06891fc38922225ab7e4fcb437a286ba2c0c4
|
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Controller/SearchController.php#L143-L158
|
21,139 |
webdevvie/pheanstalk-task-queue-bundle
|
Command/Example/AddExampleTaskCommand.php
|
AddExampleTaskCommand.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->initialiseWorker($input, $output);
$totalTasks = $input->getOption('total-tasks');
for ($counter = 0; $counter < $totalTasks; $counter++) {
$task = new ExampleTaskDescription();
$task->message = 'hello world';
$task->wait = 1;
$this->taskQueueService->queueTask($task, $this->tube);
}
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->initialiseWorker($input, $output);
$totalTasks = $input->getOption('total-tasks');
for ($counter = 0; $counter < $totalTasks; $counter++) {
$task = new ExampleTaskDescription();
$task->message = 'hello world';
$task->wait = 1;
$this->taskQueueService->queueTask($task, $this->tube);
}
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"initialiseWorker",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"totalTasks",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'total-tasks'",
")",
";",
"for",
"(",
"$",
"counter",
"=",
"0",
";",
"$",
"counter",
"<",
"$",
"totalTasks",
";",
"$",
"counter",
"++",
")",
"{",
"$",
"task",
"=",
"new",
"ExampleTaskDescription",
"(",
")",
";",
"$",
"task",
"->",
"message",
"=",
"'hello world'",
";",
"$",
"task",
"->",
"wait",
"=",
"1",
";",
"$",
"this",
"->",
"taskQueueService",
"->",
"queueTask",
"(",
"$",
"task",
",",
"$",
"this",
"->",
"tube",
")",
";",
"}",
"}"
] |
Adds an example task to the task queue using the ExampleTask.php
@param InputInterface $input
@param OutputInterface $output
@return void
@throws \InvalidArgumentException
|
[
"Adds",
"an",
"example",
"task",
"to",
"the",
"task",
"queue",
"using",
"the",
"ExampleTask",
".",
"php"
] |
db5e63a8f844e345dc2e69ce8e94b32d851020eb
|
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/Example/AddExampleTaskCommand.php#L43-L53
|
21,140 |
Visithor/visithor
|
src/Visithor/Reader/YamlConfigurationReader.php
|
YamlConfigurationReader.read
|
public function read($path)
{
$config = $this
->readByFilename(
$path,
Visithor::CONFIG_FILE_NAME_DISTR
);
if (false === $config) {
$config = $this
->readByFilename(
$path,
Visithor::CONFIG_FILE_NAME
);
}
return $config;
}
|
php
|
public function read($path)
{
$config = $this
->readByFilename(
$path,
Visithor::CONFIG_FILE_NAME_DISTR
);
if (false === $config) {
$config = $this
->readByFilename(
$path,
Visithor::CONFIG_FILE_NAME
);
}
return $config;
}
|
[
"public",
"function",
"read",
"(",
"$",
"path",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"readByFilename",
"(",
"$",
"path",
",",
"Visithor",
"::",
"CONFIG_FILE_NAME_DISTR",
")",
";",
"if",
"(",
"false",
"===",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"readByFilename",
"(",
"$",
"path",
",",
"Visithor",
"::",
"CONFIG_FILE_NAME",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Read all the configuration given a path
@param string $path Path
@return array|false Configuration loaded or false if file not exists
|
[
"Read",
"all",
"the",
"configuration",
"given",
"a",
"path"
] |
201ba2cfc536a0875983c79226947aa20b9f4dca
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Reader/YamlConfigurationReader.php#L32-L49
|
21,141 |
Visithor/visithor
|
src/Visithor/Reader/YamlConfigurationReader.php
|
YamlConfigurationReader.readByFilename
|
public function readByFilename($path, $filename)
{
$config = false;
$configFilePath = rtrim($path, '/') . '/' . $filename;
if (is_file($configFilePath)) {
$yamlParser = new YamlParser();
$config = $yamlParser->parse(file_get_contents($configFilePath));
}
return $config;
}
|
php
|
public function readByFilename($path, $filename)
{
$config = false;
$configFilePath = rtrim($path, '/') . '/' . $filename;
if (is_file($configFilePath)) {
$yamlParser = new YamlParser();
$config = $yamlParser->parse(file_get_contents($configFilePath));
}
return $config;
}
|
[
"public",
"function",
"readByFilename",
"(",
"$",
"path",
",",
"$",
"filename",
")",
"{",
"$",
"config",
"=",
"false",
";",
"$",
"configFilePath",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"filename",
";",
"if",
"(",
"is_file",
"(",
"$",
"configFilePath",
")",
")",
"{",
"$",
"yamlParser",
"=",
"new",
"YamlParser",
"(",
")",
";",
"$",
"config",
"=",
"$",
"yamlParser",
"->",
"parse",
"(",
"file_get_contents",
"(",
"$",
"configFilePath",
")",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Read all the configuration given a path and a filename
@param string $path Path
@param string $filename File name
@return array Configuration
|
[
"Read",
"all",
"the",
"configuration",
"given",
"a",
"path",
"and",
"a",
"filename"
] |
201ba2cfc536a0875983c79226947aa20b9f4dca
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Reader/YamlConfigurationReader.php#L60-L71
|
21,142 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.addClass
|
public function addClass($class, $extends = null, $implements = [])
{
$classId = $this->registerClass($class);
if ($extends) {
$parentClassId = $this->registerClass($extends);
$this->extends[$classId] = [$parentClassId];
}
if (!empty($implements)) {
$interfaceIds = [];
foreach ($implements as $interface) {
$interfaceIds[] = $this->registerInterface($interface);
}
$this->implements[$classId] = $interfaceIds;
}
}
|
php
|
public function addClass($class, $extends = null, $implements = [])
{
$classId = $this->registerClass($class);
if ($extends) {
$parentClassId = $this->registerClass($extends);
$this->extends[$classId] = [$parentClassId];
}
if (!empty($implements)) {
$interfaceIds = [];
foreach ($implements as $interface) {
$interfaceIds[] = $this->registerInterface($interface);
}
$this->implements[$classId] = $interfaceIds;
}
}
|
[
"public",
"function",
"addClass",
"(",
"$",
"class",
",",
"$",
"extends",
"=",
"null",
",",
"$",
"implements",
"=",
"[",
"]",
")",
"{",
"$",
"classId",
"=",
"$",
"this",
"->",
"registerClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"extends",
")",
"{",
"$",
"parentClassId",
"=",
"$",
"this",
"->",
"registerClass",
"(",
"$",
"extends",
")",
";",
"$",
"this",
"->",
"extends",
"[",
"$",
"classId",
"]",
"=",
"[",
"$",
"parentClassId",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"implements",
")",
")",
"{",
"$",
"interfaceIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"implements",
"as",
"$",
"interface",
")",
"{",
"$",
"interfaceIds",
"[",
"]",
"=",
"$",
"this",
"->",
"registerInterface",
"(",
"$",
"interface",
")",
";",
"}",
"$",
"this",
"->",
"implements",
"[",
"$",
"classId",
"]",
"=",
"$",
"interfaceIds",
";",
"}",
"}"
] |
add class to hierarchy tree
@param string $class
@param string $extends parent class
@param array $implements interfaces that implements
@return self
|
[
"add",
"class",
"to",
"hierarchy",
"tree"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L74-L88
|
21,143 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.addInterface
|
public function addInterface($interface, $extends = [])
{
$interfaceId = $this->registerInterface($interface);
if (!empty($extends)) {
$interfaceIds = [];
foreach ($extends as $name) {
$interfaceIds[] = $this->registerInterface($name);
}
$this->interfaceExtends[$interfaceId] = $interfaceIds;
}
}
|
php
|
public function addInterface($interface, $extends = [])
{
$interfaceId = $this->registerInterface($interface);
if (!empty($extends)) {
$interfaceIds = [];
foreach ($extends as $name) {
$interfaceIds[] = $this->registerInterface($name);
}
$this->interfaceExtends[$interfaceId] = $interfaceIds;
}
}
|
[
"public",
"function",
"addInterface",
"(",
"$",
"interface",
",",
"$",
"extends",
"=",
"[",
"]",
")",
"{",
"$",
"interfaceId",
"=",
"$",
"this",
"->",
"registerInterface",
"(",
"$",
"interface",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"extends",
")",
")",
"{",
"$",
"interfaceIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"extends",
"as",
"$",
"name",
")",
"{",
"$",
"interfaceIds",
"[",
"]",
"=",
"$",
"this",
"->",
"registerInterface",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"interfaceExtends",
"[",
"$",
"interfaceId",
"]",
"=",
"$",
"interfaceIds",
";",
"}",
"}"
] |
add interface to hierarchy tree
@param string $interface
@param array $extends
@return self
|
[
"add",
"interface",
"to",
"hierarchy",
"tree"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L97-L107
|
21,144 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.getParent
|
public function getParent($class)
{
$classId = $this->getClassId($class);
if (!isset($classId)) {
return false;
}
$parentClassId = $this->extends[$classId];
return isset($parentClassId) ? $this->classes[$parentClassId[0]] : null;
}
|
php
|
public function getParent($class)
{
$classId = $this->getClassId($class);
if (!isset($classId)) {
return false;
}
$parentClassId = $this->extends[$classId];
return isset($parentClassId) ? $this->classes[$parentClassId[0]] : null;
}
|
[
"public",
"function",
"getParent",
"(",
"$",
"class",
")",
"{",
"$",
"classId",
"=",
"$",
"this",
"->",
"getClassId",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"classId",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"parentClassId",
"=",
"$",
"this",
"->",
"extends",
"[",
"$",
"classId",
"]",
";",
"return",
"isset",
"(",
"$",
"parentClassId",
")",
"?",
"$",
"this",
"->",
"classes",
"[",
"$",
"parentClassId",
"[",
"0",
"]",
"]",
":",
"null",
";",
"}"
] |
gets parent class
@param string $class
@retutn string|null|false
|
[
"gets",
"parent",
"class"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L115-L123
|
21,145 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.getAncestors
|
public function getAncestors($class)
{
$ancestors = [];
while (true) {
$parent = $this->getParent($class);
if ($parent) {
$ancestors[] = $parent;
$class = $parent;
} else {
break;
}
}
return $ancestors;
}
|
php
|
public function getAncestors($class)
{
$ancestors = [];
while (true) {
$parent = $this->getParent($class);
if ($parent) {
$ancestors[] = $parent;
$class = $parent;
} else {
break;
}
}
return $ancestors;
}
|
[
"public",
"function",
"getAncestors",
"(",
"$",
"class",
")",
"{",
"$",
"ancestors",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"ancestors",
"[",
"]",
"=",
"$",
"parent",
";",
"$",
"class",
"=",
"$",
"parent",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"ancestors",
";",
"}"
] |
gets all parent classes
@param string $class
@return array
|
[
"gets",
"all",
"parent",
"classes"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L131-L144
|
21,146 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.getImplements
|
public function getImplements($class)
{
$interfaces = [];
$classId = $this->getClassId($class);
if (isset($classId)) {
if (isset($this->implements[$classId])) {
foreach ($this->implements[$classId] as $interfaceId) {
$interfaces[$this->interfaces[$interfaceId]] = 1;
}
}
foreach ($this->getAncestors($class) as $parent) {
foreach ($this->getImplements($parent) as $interface) {
$interfaces[$interface] = 1;
}
}
}
return array_keys($interfaces);
}
|
php
|
public function getImplements($class)
{
$interfaces = [];
$classId = $this->getClassId($class);
if (isset($classId)) {
if (isset($this->implements[$classId])) {
foreach ($this->implements[$classId] as $interfaceId) {
$interfaces[$this->interfaces[$interfaceId]] = 1;
}
}
foreach ($this->getAncestors($class) as $parent) {
foreach ($this->getImplements($parent) as $interface) {
$interfaces[$interface] = 1;
}
}
}
return array_keys($interfaces);
}
|
[
"public",
"function",
"getImplements",
"(",
"$",
"class",
")",
"{",
"$",
"interfaces",
"=",
"[",
"]",
";",
"$",
"classId",
"=",
"$",
"this",
"->",
"getClassId",
"(",
"$",
"class",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"classId",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"implements",
"[",
"$",
"classId",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"implements",
"[",
"$",
"classId",
"]",
"as",
"$",
"interfaceId",
")",
"{",
"$",
"interfaces",
"[",
"$",
"this",
"->",
"interfaces",
"[",
"$",
"interfaceId",
"]",
"]",
"=",
"1",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getAncestors",
"(",
"$",
"class",
")",
"as",
"$",
"parent",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getImplements",
"(",
"$",
"parent",
")",
"as",
"$",
"interface",
")",
"{",
"$",
"interfaces",
"[",
"$",
"interface",
"]",
"=",
"1",
";",
"}",
"}",
"}",
"return",
"array_keys",
"(",
"$",
"interfaces",
")",
";",
"}"
] |
gets implemented interfaces
@param string $class
@return array|false
|
[
"gets",
"implemented",
"interfaces"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L152-L169
|
21,147 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.isA
|
public function isA($class, $test_class)
{
$test_class = $this->normalize($test_class);
if ($this->classExists($test_class)) {
return in_array($test_class, $this->getAncestors($class));
} elseif ($this->interfaceExists($test_class)) {
return in_array($test_class, $this->getImplements($class));
} else {
throw new ClassNotExistException($test_class);
}
}
|
php
|
public function isA($class, $test_class)
{
$test_class = $this->normalize($test_class);
if ($this->classExists($test_class)) {
return in_array($test_class, $this->getAncestors($class));
} elseif ($this->interfaceExists($test_class)) {
return in_array($test_class, $this->getImplements($class));
} else {
throw new ClassNotExistException($test_class);
}
}
|
[
"public",
"function",
"isA",
"(",
"$",
"class",
",",
"$",
"test_class",
")",
"{",
"$",
"test_class",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"test_class",
")",
";",
"if",
"(",
"$",
"this",
"->",
"classExists",
"(",
"$",
"test_class",
")",
")",
"{",
"return",
"in_array",
"(",
"$",
"test_class",
",",
"$",
"this",
"->",
"getAncestors",
"(",
"$",
"class",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"interfaceExists",
"(",
"$",
"test_class",
")",
")",
"{",
"return",
"in_array",
"(",
"$",
"test_class",
",",
"$",
"this",
"->",
"getImplements",
"(",
"$",
"class",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ClassNotExistException",
"(",
"$",
"test_class",
")",
";",
"}",
"}"
] |
checks the class is subclass or implements the test class
@param string $class
@param string $test_class class or interface name
@return boolean
|
[
"checks",
"the",
"class",
"is",
"subclass",
"or",
"implements",
"the",
"test",
"class"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L202-L212
|
21,148 |
wenbinye/PhalconX
|
src/Php/ClassHierarchy.php
|
ClassHierarchy.getSubClasses
|
public function getSubClasses($class)
{
$class = $this->normalize($class);
if ($this->classExists($class)) {
return $this->getSubclassOfClass($class);
} elseif ($this->interfaceExists($class)) {
return $this->getSubclassOfInterface($class);
} else {
throw new ClassNotExistException($class);
}
}
|
php
|
public function getSubClasses($class)
{
$class = $this->normalize($class);
if ($this->classExists($class)) {
return $this->getSubclassOfClass($class);
} elseif ($this->interfaceExists($class)) {
return $this->getSubclassOfInterface($class);
} else {
throw new ClassNotExistException($class);
}
}
|
[
"public",
"function",
"getSubClasses",
"(",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"this",
"->",
"classExists",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSubclassOfClass",
"(",
"$",
"class",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"interfaceExists",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSubclassOfInterface",
"(",
"$",
"class",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ClassNotExistException",
"(",
"$",
"class",
")",
";",
"}",
"}"
] |
gets all subclass of the class or interface
@param string $class
@return array
|
[
"gets",
"all",
"subclass",
"of",
"the",
"class",
"or",
"interface"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/ClassHierarchy.php#L220-L230
|
21,149 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.paginate
|
public function paginate()
{
$this->count = $this->query->get()->count();
$this->limit = $this->limit ?: $this->count;
$this->query->skip($this->offset)->take($this->limit);
}
|
php
|
public function paginate()
{
$this->count = $this->query->get()->count();
$this->limit = $this->limit ?: $this->count;
$this->query->skip($this->offset)->take($this->limit);
}
|
[
"public",
"function",
"paginate",
"(",
")",
"{",
"$",
"this",
"->",
"count",
"=",
"$",
"this",
"->",
"query",
"->",
"get",
"(",
")",
"->",
"count",
"(",
")",
";",
"$",
"this",
"->",
"limit",
"=",
"$",
"this",
"->",
"limit",
"?",
":",
"$",
"this",
"->",
"count",
";",
"$",
"this",
"->",
"query",
"->",
"skip",
"(",
"$",
"this",
"->",
"offset",
")",
"->",
"take",
"(",
"$",
"this",
"->",
"limit",
")",
";",
"}"
] |
Will modify a query builder to get paginated data and will
return an array with the meta data.
@param Illuminate\Database\Query\Builder $query
@return array
|
[
"Will",
"modify",
"a",
"query",
"builder",
"to",
"get",
"paginated",
"data",
"and",
"will",
"return",
"an",
"array",
"with",
"the",
"meta",
"data",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L68-L73
|
21,150 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.getNextPageParams
|
public function getNextPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$next_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
if ($this->count <= ($this->offset + $limit)) {
return false;
}
if ($this->count >= $limit) {
$next_url = $this->offset_key
. ($this->offset + $limit)
. $this->limit_key
. $limit;
}
return $next_url;
}
|
php
|
public function getNextPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$next_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
if ($this->count <= ($this->offset + $limit)) {
return false;
}
if ($this->count >= $limit) {
$next_url = $this->offset_key
. ($this->offset + $limit)
. $this->limit_key
. $limit;
}
return $next_url;
}
|
[
"public",
"function",
"getNextPageParams",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"limit",
"<=",
"0",
"?",
"$",
"this",
"->",
"count",
":",
"$",
"this",
"->",
"limit",
";",
"$",
"next_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"$",
"this",
"->",
"offset",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"if",
"(",
"$",
"this",
"->",
"count",
"<=",
"(",
"$",
"this",
"->",
"offset",
"+",
"$",
"limit",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"count",
">=",
"$",
"limit",
")",
"{",
"$",
"next_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"(",
"$",
"this",
"->",
"offset",
"+",
"$",
"limit",
")",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"}",
"return",
"$",
"next_url",
";",
"}"
] |
Generate the next page url parameters as string.
@param int $count
@param int $currentOffset
@param int $limit
@return string
|
[
"Generate",
"the",
"next",
"page",
"url",
"parameters",
"as",
"string",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L84-L104
|
21,151 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.getPrevPageParams
|
public function getPrevPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$prev_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
if ($this->count >= $limit) {
$prev_url = $this->offset_key
. ($this->offset - $limit)
. $this->limit_key
. $limit;
}
if ($this->count <= ($this->offset - $limit)) {
$prev_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
}
return $prev_url;
}
|
php
|
public function getPrevPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$prev_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
if ($this->count >= $limit) {
$prev_url = $this->offset_key
. ($this->offset - $limit)
. $this->limit_key
. $limit;
}
if ($this->count <= ($this->offset - $limit)) {
$prev_url = $this->offset_key
. $this->offset
. $this->limit_key
. $limit;
}
return $prev_url;
}
|
[
"public",
"function",
"getPrevPageParams",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"limit",
"<=",
"0",
"?",
"$",
"this",
"->",
"count",
":",
"$",
"this",
"->",
"limit",
";",
"$",
"prev_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"$",
"this",
"->",
"offset",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"if",
"(",
"$",
"this",
"->",
"count",
">=",
"$",
"limit",
")",
"{",
"$",
"prev_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"(",
"$",
"this",
"->",
"offset",
"-",
"$",
"limit",
")",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"count",
"<=",
"(",
"$",
"this",
"->",
"offset",
"-",
"$",
"limit",
")",
")",
"{",
"$",
"prev_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"$",
"this",
"->",
"offset",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"}",
"return",
"$",
"prev_url",
";",
"}"
] |
Generate the prev page url parameters as string.
@param int $count
@param int $currentOffset
@param int $limit
@return string
|
[
"Generate",
"the",
"prev",
"page",
"url",
"parameters",
"as",
"string",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L115-L136
|
21,152 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.getLastPageParams
|
public function getLastPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$last_page = intdiv(intval($this->count), intval($limit));
$last_url = $this->offset_key
. ($last_page * $limit)
. $this->limit_key
. $limit;
return $last_url;
}
|
php
|
public function getLastPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$last_page = intdiv(intval($this->count), intval($limit));
$last_url = $this->offset_key
. ($last_page * $limit)
. $this->limit_key
. $limit;
return $last_url;
}
|
[
"public",
"function",
"getLastPageParams",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"limit",
"<=",
"0",
"?",
"$",
"this",
"->",
"count",
":",
"$",
"this",
"->",
"limit",
";",
"$",
"last_page",
"=",
"intdiv",
"(",
"intval",
"(",
"$",
"this",
"->",
"count",
")",
",",
"intval",
"(",
"$",
"limit",
")",
")",
";",
"$",
"last_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"(",
"$",
"last_page",
"*",
"$",
"limit",
")",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"return",
"$",
"last_url",
";",
"}"
] |
Generate the last page url parameters as string.
@param int $count
@param int $currentOffset
@param int $limit
@return string
|
[
"Generate",
"the",
"last",
"page",
"url",
"parameters",
"as",
"string",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L147-L157
|
21,153 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.getFirstPageParams
|
public function getFirstPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$first_url = $this->offset_key . '0' . $this->limit_key . $limit;
return $first_url;
}
|
php
|
public function getFirstPageParams()
{
$limit = $this->limit <= 0 ? $this->count : $this->limit;
$first_url = $this->offset_key . '0' . $this->limit_key . $limit;
return $first_url;
}
|
[
"public",
"function",
"getFirstPageParams",
"(",
")",
"{",
"$",
"limit",
"=",
"$",
"this",
"->",
"limit",
"<=",
"0",
"?",
"$",
"this",
"->",
"count",
":",
"$",
"this",
"->",
"limit",
";",
"$",
"first_url",
"=",
"$",
"this",
"->",
"offset_key",
".",
"'0'",
".",
"$",
"this",
"->",
"limit_key",
".",
"$",
"limit",
";",
"return",
"$",
"first_url",
";",
"}"
] |
Generate the first page url parameters as string.
@param int $count
@param int $currentOffset
@param int $limit
@return string
|
[
"Generate",
"the",
"first",
"page",
"url",
"parameters",
"as",
"string",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L168-L174
|
21,154 |
jnaxo/country-codes
|
src/Store/api/Paginator.php
|
Paginator.getPaginationMetaData
|
public function getPaginationMetaData()
{
$pagination = [
'count' => $this->count,
'offset' => $this->offset,
'limit' => $this->limit,
'next_page_params' => $this->getNextPageParams(),
];
return $pagination;
}
|
php
|
public function getPaginationMetaData()
{
$pagination = [
'count' => $this->count,
'offset' => $this->offset,
'limit' => $this->limit,
'next_page_params' => $this->getNextPageParams(),
];
return $pagination;
}
|
[
"public",
"function",
"getPaginationMetaData",
"(",
")",
"{",
"$",
"pagination",
"=",
"[",
"'count'",
"=>",
"$",
"this",
"->",
"count",
",",
"'offset'",
"=>",
"$",
"this",
"->",
"offset",
",",
"'limit'",
"=>",
"$",
"this",
"->",
"limit",
",",
"'next_page_params'",
"=>",
"$",
"this",
"->",
"getNextPageParams",
"(",
")",
",",
"]",
";",
"return",
"$",
"pagination",
";",
"}"
] |
Get a json encoded array with pagination metadata
|
[
"Get",
"a",
"json",
"encoded",
"array",
"with",
"pagination",
"metadata"
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Paginator.php#L180-L190
|
21,155 |
Danzabar/config-builder
|
src/Data/ParamBag.php
|
ParamBag.recursiveReplace
|
public function recursiveReplace($search, $replace)
{
$json = json_encode($this->params);
$json = str_replace($search, $replace, $json);
$this->params = json_decode($json, TRUE);
}
|
php
|
public function recursiveReplace($search, $replace)
{
$json = json_encode($this->params);
$json = str_replace($search, $replace, $json);
$this->params = json_decode($json, TRUE);
}
|
[
"public",
"function",
"recursiveReplace",
"(",
"$",
"search",
",",
"$",
"replace",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"this",
"->",
"params",
")",
";",
"$",
"json",
"=",
"str_replace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"json",
")",
";",
"$",
"this",
"->",
"params",
"=",
"json_decode",
"(",
"$",
"json",
",",
"TRUE",
")",
";",
"}"
] |
Search and replace function for multi level arrays
@param String $search
@param String $replace
@return void
@author Dan Cox
|
[
"Search",
"and",
"replace",
"function",
"for",
"multi",
"level",
"arrays"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/ParamBag.php#L145-L152
|
21,156 |
Danzabar/config-builder
|
src/Data/ParamBag.php
|
ParamBag.rollback
|
public function rollback()
{
if($this->hasBackup)
{
$this->params = $this->backup;
} else
{
throw new Exceptions\NoValidBackup($this->params);
}
}
|
php
|
public function rollback()
{
if($this->hasBackup)
{
$this->params = $this->backup;
} else
{
throw new Exceptions\NoValidBackup($this->params);
}
}
|
[
"public",
"function",
"rollback",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasBackup",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"this",
"->",
"backup",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"NoValidBackup",
"(",
"$",
"this",
"->",
"params",
")",
";",
"}",
"}"
] |
Uses the backup array to revert the params array
@return void
@author Dan Cox
@throws Exceptions\NoValidBackup
|
[
"Uses",
"the",
"backup",
"array",
"to",
"revert",
"the",
"params",
"array"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/ParamBag.php#L187-L197
|
21,157 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.activateSubscription
|
public function activateSubscription( $hashString )
{
// 1. fetch the subscription object
$subscription = ezcomSubscription::fetchByHashString( $hashString );
if ( is_null( $subscription ) )
{
$this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate',
'There is no subscription with the hash string!' ) );
}
else
{
if ( $subscription->attribute( 'enabled' ) )
{
ezDebugSetting::writeNotice( 'extension-ezcomments', 'Subscription activated', __METHOD__ );
}
$subscriber = ezcomSubscriber::fetch( $subscription->attribute( 'subscriber_id' ) );
if ( $subscriber->attribute( 'enabled' ) )
{
$subscription->enable();
$this->tpl->setVariable( 'subscriber', $subscriber );
}
else
{
$this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate',
'The subscriber is disabled!' ) );
}
}
}
|
php
|
public function activateSubscription( $hashString )
{
// 1. fetch the subscription object
$subscription = ezcomSubscription::fetchByHashString( $hashString );
if ( is_null( $subscription ) )
{
$this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate',
'There is no subscription with the hash string!' ) );
}
else
{
if ( $subscription->attribute( 'enabled' ) )
{
ezDebugSetting::writeNotice( 'extension-ezcomments', 'Subscription activated', __METHOD__ );
}
$subscriber = ezcomSubscriber::fetch( $subscription->attribute( 'subscriber_id' ) );
if ( $subscriber->attribute( 'enabled' ) )
{
$subscription->enable();
$this->tpl->setVariable( 'subscriber', $subscriber );
}
else
{
$this->tpl->setVariable( 'error_message', ezpI18n::tr( 'ezcomments/comment/activate',
'The subscriber is disabled!' ) );
}
}
}
|
[
"public",
"function",
"activateSubscription",
"(",
"$",
"hashString",
")",
"{",
"// 1. fetch the subscription object",
"$",
"subscription",
"=",
"ezcomSubscription",
"::",
"fetchByHashString",
"(",
"$",
"hashString",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"subscription",
")",
")",
"{",
"$",
"this",
"->",
"tpl",
"->",
"setVariable",
"(",
"'error_message'",
",",
"ezpI18n",
"::",
"tr",
"(",
"'ezcomments/comment/activate'",
",",
"'There is no subscription with the hash string!'",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"subscription",
"->",
"attribute",
"(",
"'enabled'",
")",
")",
"{",
"ezDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'Subscription activated'",
",",
"__METHOD__",
")",
";",
"}",
"$",
"subscriber",
"=",
"ezcomSubscriber",
"::",
"fetch",
"(",
"$",
"subscription",
"->",
"attribute",
"(",
"'subscriber_id'",
")",
")",
";",
"if",
"(",
"$",
"subscriber",
"->",
"attribute",
"(",
"'enabled'",
")",
")",
"{",
"$",
"subscription",
"->",
"enable",
"(",
")",
";",
"$",
"this",
"->",
"tpl",
"->",
"setVariable",
"(",
"'subscriber'",
",",
"$",
"subscriber",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"tpl",
"->",
"setVariable",
"(",
"'error_message'",
",",
"ezpI18n",
"::",
"tr",
"(",
"'ezcomments/comment/activate'",
",",
"'The subscriber is disabled!'",
")",
")",
";",
"}",
"}",
"}"
] |
Activate subscription
If there is error,set 'error_message' to the template,
If activation succeeds, set 'subscriber' to the template
@param string: $hashString
@return void
|
[
"Activate",
"subscription",
"If",
"there",
"is",
"error",
"set",
"error_message",
"to",
"the",
"template",
"If",
"activation",
"succeeds",
"set",
"subscriber",
"to",
"the",
"template"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L35-L64
|
21,158 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.addSubscription
|
public function addSubscription( $email, $user, $contentID, $languageID, $subscriptionType, $currentTime, $activate = true )
{
//1. insert into subscriber
$ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
$subscriber = ezcomSubscriber::fetchByEmail( $email );
//if there is no data in subscriber for same email, save it
if ( is_null( $subscriber ) )
{
$subscriber = ezcomSubscriber::create();
$subscriber->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
$subscriber->setAttribute( 'email', $email );
if ( $user->isAnonymous() )
{
$util = ezcomUtility::instance();
$hashString = $util->generateSusbcriberHashString( $subscriber );
$subscriber->setAttribute( 'hash_string', $hashString );
}
$subscriber->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Subscriber does not exist, added one', __METHOD__ );
$subscriber = ezcomSubscriber::fetchByEmail( $email );
}
else
{
if ( $subscriber->attribute( 'enabled' ) == false )
{
throw new Exception('Subscription can not be added because the subscriber is disabled.', self::ERROR_SUBSCRIBER_DISABLED );
}
}
//3 insert into subscription table
// if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id
$hasSubscription = ezcomSubscription::exists( $contentID,
$languageID,
$subscriptionType,
$email );
if ( $hasSubscription === false )
{
$subscription = ezcomSubscription::create();
$subscription->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
$subscription->setAttribute( 'subscriber_id', $subscriber->attribute( 'id' ) );
$subscription->setAttribute( 'subscription_type', $subscriptionType );
$subscription->setAttribute( 'content_id', $contentID );
$subscription->setAttribute( 'language_id', $languageID );
$subscription->setAttribute( 'subscription_time', $currentTime );
$defaultActivated = $ezcommentsINI->variable( 'CommentSettings', 'SubscriptionActivated' );
if ( $user->isAnonymous() && $defaultActivated !== 'true' && $activate === true )
{
$subscription->setAttribute( 'enabled', 0 );
$utility = ezcomUtility::instance();
$subscription->setAttribute( 'hash_string', $utility->generateSubscriptionHashString( $subscription ) );
$subscription->store();
$result = ezcomSubscriptionManager::sendActivationEmail( eZContentObject::fetch( $contentID ),
$subscriber,
$subscription );
if ( !$result )
{
eZDebug::writeError( "Error sending mail to '$email'", __METHOD__ );
}
}
else
{
$subscription->setAttribute( 'enabled', 1 );
$subscription->store();
}
eZDebugSetting::writeNotice( 'extension-ezcomments', 'No existing subscription for this content and user, added one', __METHOD__ );
}
}
|
php
|
public function addSubscription( $email, $user, $contentID, $languageID, $subscriptionType, $currentTime, $activate = true )
{
//1. insert into subscriber
$ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
$subscriber = ezcomSubscriber::fetchByEmail( $email );
//if there is no data in subscriber for same email, save it
if ( is_null( $subscriber ) )
{
$subscriber = ezcomSubscriber::create();
$subscriber->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
$subscriber->setAttribute( 'email', $email );
if ( $user->isAnonymous() )
{
$util = ezcomUtility::instance();
$hashString = $util->generateSusbcriberHashString( $subscriber );
$subscriber->setAttribute( 'hash_string', $hashString );
}
$subscriber->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Subscriber does not exist, added one', __METHOD__ );
$subscriber = ezcomSubscriber::fetchByEmail( $email );
}
else
{
if ( $subscriber->attribute( 'enabled' ) == false )
{
throw new Exception('Subscription can not be added because the subscriber is disabled.', self::ERROR_SUBSCRIBER_DISABLED );
}
}
//3 insert into subscription table
// if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id
$hasSubscription = ezcomSubscription::exists( $contentID,
$languageID,
$subscriptionType,
$email );
if ( $hasSubscription === false )
{
$subscription = ezcomSubscription::create();
$subscription->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
$subscription->setAttribute( 'subscriber_id', $subscriber->attribute( 'id' ) );
$subscription->setAttribute( 'subscription_type', $subscriptionType );
$subscription->setAttribute( 'content_id', $contentID );
$subscription->setAttribute( 'language_id', $languageID );
$subscription->setAttribute( 'subscription_time', $currentTime );
$defaultActivated = $ezcommentsINI->variable( 'CommentSettings', 'SubscriptionActivated' );
if ( $user->isAnonymous() && $defaultActivated !== 'true' && $activate === true )
{
$subscription->setAttribute( 'enabled', 0 );
$utility = ezcomUtility::instance();
$subscription->setAttribute( 'hash_string', $utility->generateSubscriptionHashString( $subscription ) );
$subscription->store();
$result = ezcomSubscriptionManager::sendActivationEmail( eZContentObject::fetch( $contentID ),
$subscriber,
$subscription );
if ( !$result )
{
eZDebug::writeError( "Error sending mail to '$email'", __METHOD__ );
}
}
else
{
$subscription->setAttribute( 'enabled', 1 );
$subscription->store();
}
eZDebugSetting::writeNotice( 'extension-ezcomments', 'No existing subscription for this content and user, added one', __METHOD__ );
}
}
|
[
"public",
"function",
"addSubscription",
"(",
"$",
"email",
",",
"$",
"user",
",",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"currentTime",
",",
"$",
"activate",
"=",
"true",
")",
"{",
"//1. insert into subscriber",
"$",
"ezcommentsINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"subscriber",
"=",
"ezcomSubscriber",
"::",
"fetchByEmail",
"(",
"$",
"email",
")",
";",
"//if there is no data in subscriber for same email, save it",
"if",
"(",
"is_null",
"(",
"$",
"subscriber",
")",
")",
"{",
"$",
"subscriber",
"=",
"ezcomSubscriber",
"::",
"create",
"(",
")",
";",
"$",
"subscriber",
"->",
"setAttribute",
"(",
"'user_id'",
",",
"$",
"user",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"subscriber",
"->",
"setAttribute",
"(",
"'email'",
",",
"$",
"email",
")",
";",
"if",
"(",
"$",
"user",
"->",
"isAnonymous",
"(",
")",
")",
"{",
"$",
"util",
"=",
"ezcomUtility",
"::",
"instance",
"(",
")",
";",
"$",
"hashString",
"=",
"$",
"util",
"->",
"generateSusbcriberHashString",
"(",
"$",
"subscriber",
")",
";",
"$",
"subscriber",
"->",
"setAttribute",
"(",
"'hash_string'",
",",
"$",
"hashString",
")",
";",
"}",
"$",
"subscriber",
"->",
"store",
"(",
")",
";",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'Subscriber does not exist, added one'",
",",
"__METHOD__",
")",
";",
"$",
"subscriber",
"=",
"ezcomSubscriber",
"::",
"fetchByEmail",
"(",
"$",
"email",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"subscriber",
"->",
"attribute",
"(",
"'enabled'",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Subscription can not be added because the subscriber is disabled.'",
",",
"self",
"::",
"ERROR_SUBSCRIBER_DISABLED",
")",
";",
"}",
"}",
"//3 insert into subscription table",
"// if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id",
"$",
"hasSubscription",
"=",
"ezcomSubscription",
"::",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"email",
")",
";",
"if",
"(",
"$",
"hasSubscription",
"===",
"false",
")",
"{",
"$",
"subscription",
"=",
"ezcomSubscription",
"::",
"create",
"(",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'user_id'",
",",
"$",
"user",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'subscriber_id'",
",",
"$",
"subscriber",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'subscription_type'",
",",
"$",
"subscriptionType",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'content_id'",
",",
"$",
"contentID",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'language_id'",
",",
"$",
"languageID",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'subscription_time'",
",",
"$",
"currentTime",
")",
";",
"$",
"defaultActivated",
"=",
"$",
"ezcommentsINI",
"->",
"variable",
"(",
"'CommentSettings'",
",",
"'SubscriptionActivated'",
")",
";",
"if",
"(",
"$",
"user",
"->",
"isAnonymous",
"(",
")",
"&&",
"$",
"defaultActivated",
"!==",
"'true'",
"&&",
"$",
"activate",
"===",
"true",
")",
"{",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'enabled'",
",",
"0",
")",
";",
"$",
"utility",
"=",
"ezcomUtility",
"::",
"instance",
"(",
")",
";",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'hash_string'",
",",
"$",
"utility",
"->",
"generateSubscriptionHashString",
"(",
"$",
"subscription",
")",
")",
";",
"$",
"subscription",
"->",
"store",
"(",
")",
";",
"$",
"result",
"=",
"ezcomSubscriptionManager",
"::",
"sendActivationEmail",
"(",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"contentID",
")",
",",
"$",
"subscriber",
",",
"$",
"subscription",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"eZDebug",
"::",
"writeError",
"(",
"\"Error sending mail to '$email'\"",
",",
"__METHOD__",
")",
";",
"}",
"}",
"else",
"{",
"$",
"subscription",
"->",
"setAttribute",
"(",
"'enabled'",
",",
"1",
")",
";",
"$",
"subscription",
"->",
"store",
"(",
")",
";",
"}",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'No existing subscription for this content and user, added one'",
",",
"__METHOD__",
")",
";",
"}",
"}"
] |
Add an subscription. If the subscriber is disabled, throw an exception
If there is no subscriber, add one.
If there is no subscription for the content, add one
@param $email: user's email
@return void
|
[
"Add",
"an",
"subscription",
".",
"If",
"the",
"subscriber",
"is",
"disabled",
"throw",
"an",
"exception",
"If",
"there",
"is",
"no",
"subscriber",
"add",
"one",
".",
"If",
"there",
"is",
"no",
"subscription",
"for",
"the",
"content",
"add",
"one"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L73-L140
|
21,159 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.sendActivationEmail
|
public static function sendActivationEmail( $contentObject, $subscriber, $subscription )
{
$transport = eZNotificationTransport::instance( 'ezmail' );
$email = $subscriber->attribute( 'email' );
$tpl = eZTemplate::factory();
$tpl->setVariable( 'contentobject', $contentObject );
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'subscription', $subscription );
$mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' );
$mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' );
$parameters = array();
$ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
$mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' );
$parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' );
$parameters['content_type'] = $mailContentType;
$result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters );
return $result;
}
|
php
|
public static function sendActivationEmail( $contentObject, $subscriber, $subscription )
{
$transport = eZNotificationTransport::instance( 'ezmail' );
$email = $subscriber->attribute( 'email' );
$tpl = eZTemplate::factory();
$tpl->setVariable( 'contentobject', $contentObject );
$tpl->setVariable( 'subscriber', $subscriber );
$tpl->setVariable( 'subscription', $subscription );
$mailSubject = $tpl->fetch( 'design:comment/notification_activation_subject.tpl' );
$mailBody = $tpl->fetch( 'design:comment/notification_activation_body.tpl' );
$parameters = array();
$ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
$mailContentType = $ezcommentsINI->variable( 'NotificationSettings', 'ActivationMailContentType' );
$parameters['from'] = $ezcommentsINI->variable( 'NotificationSettings', 'MailFrom' );
$parameters['content_type'] = $mailContentType;
$result = $transport->send( array( $email ), $mailSubject, $mailBody, null, $parameters );
return $result;
}
|
[
"public",
"static",
"function",
"sendActivationEmail",
"(",
"$",
"contentObject",
",",
"$",
"subscriber",
",",
"$",
"subscription",
")",
"{",
"$",
"transport",
"=",
"eZNotificationTransport",
"::",
"instance",
"(",
"'ezmail'",
")",
";",
"$",
"email",
"=",
"$",
"subscriber",
"->",
"attribute",
"(",
"'email'",
")",
";",
"$",
"tpl",
"=",
"eZTemplate",
"::",
"factory",
"(",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'contentobject'",
",",
"$",
"contentObject",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'subscriber'",
",",
"$",
"subscriber",
")",
";",
"$",
"tpl",
"->",
"setVariable",
"(",
"'subscription'",
",",
"$",
"subscription",
")",
";",
"$",
"mailSubject",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"'design:comment/notification_activation_subject.tpl'",
")",
";",
"$",
"mailBody",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"'design:comment/notification_activation_body.tpl'",
")",
";",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"ezcommentsINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"mailContentType",
"=",
"$",
"ezcommentsINI",
"->",
"variable",
"(",
"'NotificationSettings'",
",",
"'ActivationMailContentType'",
")",
";",
"$",
"parameters",
"[",
"'from'",
"]",
"=",
"$",
"ezcommentsINI",
"->",
"variable",
"(",
"'NotificationSettings'",
",",
"'MailFrom'",
")",
";",
"$",
"parameters",
"[",
"'content_type'",
"]",
"=",
"$",
"mailContentType",
";",
"$",
"result",
"=",
"$",
"transport",
"->",
"send",
"(",
"array",
"(",
"$",
"email",
")",
",",
"$",
"mailSubject",
",",
"$",
"mailBody",
",",
"null",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
send activation email to the user
@param ezcomContentObject $contentObject
@param ezcomSubscriber $subscriber
@param ezcomSubscription $subscription
@return true if mail sending succeeds
false if mail sending fails
|
[
"send",
"activation",
"email",
"to",
"the",
"user"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L150-L169
|
21,160 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.cleanupExpiredSubscription
|
public static function cleanupExpiredSubscription( $time )
{
//1. find the subscription which is disabled and whose time is too long
$startTime = time() - $time;
$db = eZDB::instance();
$selectSql = "SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0";
$result = $db->arrayQuery( $selectSql );
if ( is_array( $result ) && count( $result ) > 0 )
{
//2. clean up the subscription
$deleteSql = "DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0";
$db->query( $deleteSql );
return $result;
}
else
{
return null;
}
}
|
php
|
public static function cleanupExpiredSubscription( $time )
{
//1. find the subscription which is disabled and whose time is too long
$startTime = time() - $time;
$db = eZDB::instance();
$selectSql = "SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0";
$result = $db->arrayQuery( $selectSql );
if ( is_array( $result ) && count( $result ) > 0 )
{
//2. clean up the subscription
$deleteSql = "DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0";
$db->query( $deleteSql );
return $result;
}
else
{
return null;
}
}
|
[
"public",
"static",
"function",
"cleanupExpiredSubscription",
"(",
"$",
"time",
")",
"{",
"//1. find the subscription which is disabled and whose time is too long",
"$",
"startTime",
"=",
"time",
"(",
")",
"-",
"$",
"time",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"selectSql",
"=",
"\"SELECT id FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0\"",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"arrayQuery",
"(",
"$",
"selectSql",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"result",
")",
"&&",
"count",
"(",
"$",
"result",
")",
">",
"0",
")",
"{",
"//2. clean up the subscription",
"$",
"deleteSql",
"=",
"\"DELETE FROM ezcomment_subscription WHERE subscription_time < $startTime AND enabled = 0\"",
";",
"$",
"db",
"->",
"query",
"(",
"$",
"deleteSql",
")",
";",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
clean up the subscription if the subscription has not been activate for very long
@return array id of subscription cleaned up
null if nothing cleaned up
|
[
"clean",
"up",
"the",
"subscription",
"if",
"the",
"subscription",
"has",
"not",
"been",
"activate",
"for",
"very",
"long"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L176-L194
|
21,161 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.deleteSubscription
|
public function deleteSubscription( $email, $contentObjectID, $languageID )
{
$subscriber = ezcomSubscriber::fetchByEmail( $email );
$cond = array();
$cond['subscriber_id'] = $subscriber->attribute( 'id' );
$cond['content_id'] = $contentObjectID;
$cond['language_id'] = $languageID;
$cond['subscription_type'] = 'ezcomcomment';
$subscription = ezcomSubscription::fetchByCond( $cond );
$subscription->remove();
}
|
php
|
public function deleteSubscription( $email, $contentObjectID, $languageID )
{
$subscriber = ezcomSubscriber::fetchByEmail( $email );
$cond = array();
$cond['subscriber_id'] = $subscriber->attribute( 'id' );
$cond['content_id'] = $contentObjectID;
$cond['language_id'] = $languageID;
$cond['subscription_type'] = 'ezcomcomment';
$subscription = ezcomSubscription::fetchByCond( $cond );
$subscription->remove();
}
|
[
"public",
"function",
"deleteSubscription",
"(",
"$",
"email",
",",
"$",
"contentObjectID",
",",
"$",
"languageID",
")",
"{",
"$",
"subscriber",
"=",
"ezcomSubscriber",
"::",
"fetchByEmail",
"(",
"$",
"email",
")",
";",
"$",
"cond",
"=",
"array",
"(",
")",
";",
"$",
"cond",
"[",
"'subscriber_id'",
"]",
"=",
"$",
"subscriber",
"->",
"attribute",
"(",
"'id'",
")",
";",
"$",
"cond",
"[",
"'content_id'",
"]",
"=",
"$",
"contentObjectID",
";",
"$",
"cond",
"[",
"'language_id'",
"]",
"=",
"$",
"languageID",
";",
"$",
"cond",
"[",
"'subscription_type'",
"]",
"=",
"'ezcomcomment'",
";",
"$",
"subscription",
"=",
"ezcomSubscription",
"::",
"fetchByCond",
"(",
"$",
"cond",
")",
";",
"$",
"subscription",
"->",
"remove",
"(",
")",
";",
"}"
] |
delete the subscription given the subscriber's email
@param $email
@param $contentObjectID
@param $languageID
@return unknown_type
|
[
"delete",
"the",
"subscription",
"given",
"the",
"subscriber",
"s",
"email"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L203-L213
|
21,162 |
ezsystems/ezcomments-ls-extension
|
classes/ezcomsubscriptionmanager.php
|
ezcomSubscriptionManager.instance
|
public static function instance( $tpl = null, $module = null, $params = null, $className = null )
{
$object = null;
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'ManagerClasses', 'SubscriptionManagerClass' );
}
if ( !is_null( self::$instance ) )
{
$object = self::$instance;
}
else
{
$object = new $className();
$object->tpl = $tpl;
$object->module = $module;
$object->params = $params;
}
return $object;
}
|
php
|
public static function instance( $tpl = null, $module = null, $params = null, $className = null )
{
$object = null;
if ( is_null( $className ) )
{
$ini = eZINI::instance( 'ezcomments.ini' );
$className = $ini->variable( 'ManagerClasses', 'SubscriptionManagerClass' );
}
if ( !is_null( self::$instance ) )
{
$object = self::$instance;
}
else
{
$object = new $className();
$object->tpl = $tpl;
$object->module = $module;
$object->params = $params;
}
return $object;
}
|
[
"public",
"static",
"function",
"instance",
"(",
"$",
"tpl",
"=",
"null",
",",
"$",
"module",
"=",
"null",
",",
"$",
"params",
"=",
"null",
",",
"$",
"className",
"=",
"null",
")",
"{",
"$",
"object",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"className",
")",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'ezcomments.ini'",
")",
";",
"$",
"className",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'ManagerClasses'",
",",
"'SubscriptionManagerClass'",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"$",
"object",
"=",
"self",
"::",
"$",
"instance",
";",
"}",
"else",
"{",
"$",
"object",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"object",
"->",
"tpl",
"=",
"$",
"tpl",
";",
"$",
"object",
"->",
"module",
"=",
"$",
"module",
";",
"$",
"object",
"->",
"params",
"=",
"$",
"params",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
method for creating object
@return ezcomSubscriptionManager
|
[
"method",
"for",
"creating",
"object"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomsubscriptionmanager.php#L219-L240
|
21,163 |
raideer/twitch-api
|
src/Resources/Games.php
|
Games.getTopGames
|
public function getTopGames($params = [])
{
$defaults = [
'limit' => 10,
'offset' => 0,
];
return $this->wrapper->request('GET', 'games/top', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
php
|
public function getTopGames($params = [])
{
$defaults = [
'limit' => 10,
'offset' => 0,
];
return $this->wrapper->request('GET', 'games/top', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
[
"public",
"function",
"getTopGames",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'limit'",
"=>",
"10",
",",
"'offset'",
"=>",
"0",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'games/top'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] |
Returns a list of games objects sorted by number of current viewers on Twitch, most popular first.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md#get-gamestop
@param array $params Optional parameters
@return array
|
[
"Returns",
"a",
"list",
"of",
"games",
"objects",
"sorted",
"by",
"number",
"of",
"current",
"viewers",
"on",
"Twitch",
"most",
"popular",
"first",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Games.php#L31-L39
|
21,164 |
derhasi/buddy
|
src/Config.php
|
Config.load
|
public function load($workingDir)
{
$locator = new FileLocator($this->getPotentialDirectories($workingDir));
$loader = new YamlLoader($locator);
// Config validation.
$processor = new Processor();
$schema = new BuddySchema();
$files = $locator->locate(static::FILENAME, NULL, FALSE);
foreach ($files as $file) {
// After loading the raw data from the yaml file, we validate given
// configuration.
$raw = $loader->load($file);
$conf = $processor->processConfiguration($schema, array('buddy' => $raw));
if (isset($conf['commands'])) {
foreach($conf['commands'] as $command => $specs) {
if (!isset($this->commands[$command])) {
$this->commands[$command] = array(
'options' => $specs,
'file' => $file,
);
}
}
}
// In the case 'root' is set, we do not process any parent buddy files.
if (!empty($values['root'])) {
break;
}
}
return $this;
}
|
php
|
public function load($workingDir)
{
$locator = new FileLocator($this->getPotentialDirectories($workingDir));
$loader = new YamlLoader($locator);
// Config validation.
$processor = new Processor();
$schema = new BuddySchema();
$files = $locator->locate(static::FILENAME, NULL, FALSE);
foreach ($files as $file) {
// After loading the raw data from the yaml file, we validate given
// configuration.
$raw = $loader->load($file);
$conf = $processor->processConfiguration($schema, array('buddy' => $raw));
if (isset($conf['commands'])) {
foreach($conf['commands'] as $command => $specs) {
if (!isset($this->commands[$command])) {
$this->commands[$command] = array(
'options' => $specs,
'file' => $file,
);
}
}
}
// In the case 'root' is set, we do not process any parent buddy files.
if (!empty($values['root'])) {
break;
}
}
return $this;
}
|
[
"public",
"function",
"load",
"(",
"$",
"workingDir",
")",
"{",
"$",
"locator",
"=",
"new",
"FileLocator",
"(",
"$",
"this",
"->",
"getPotentialDirectories",
"(",
"$",
"workingDir",
")",
")",
";",
"$",
"loader",
"=",
"new",
"YamlLoader",
"(",
"$",
"locator",
")",
";",
"// Config validation.",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"schema",
"=",
"new",
"BuddySchema",
"(",
")",
";",
"$",
"files",
"=",
"$",
"locator",
"->",
"locate",
"(",
"static",
"::",
"FILENAME",
",",
"NULL",
",",
"FALSE",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"// After loading the raw data from the yaml file, we validate given",
"// configuration.",
"$",
"raw",
"=",
"$",
"loader",
"->",
"load",
"(",
"$",
"file",
")",
";",
"$",
"conf",
"=",
"$",
"processor",
"->",
"processConfiguration",
"(",
"$",
"schema",
",",
"array",
"(",
"'buddy'",
"=>",
"$",
"raw",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"conf",
"[",
"'commands'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"conf",
"[",
"'commands'",
"]",
"as",
"$",
"command",
"=>",
"$",
"specs",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"command",
"]",
")",
")",
"{",
"$",
"this",
"->",
"commands",
"[",
"$",
"command",
"]",
"=",
"array",
"(",
"'options'",
"=>",
"$",
"specs",
",",
"'file'",
"=>",
"$",
"file",
",",
")",
";",
"}",
"}",
"}",
"// In the case 'root' is set, we do not process any parent buddy files.",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
"[",
"'root'",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Loads the configuration file data.
|
[
"Loads",
"the",
"configuration",
"file",
"data",
"."
] |
a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165
|
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L29-L62
|
21,165 |
derhasi/buddy
|
src/Config.php
|
Config.getCommand
|
public function getCommand($command)
{
return new CommandShortcut($command, $this->commands[$command]['options'], $this->commands[$command]['file']);
}
|
php
|
public function getCommand($command)
{
return new CommandShortcut($command, $this->commands[$command]['options'], $this->commands[$command]['file']);
}
|
[
"public",
"function",
"getCommand",
"(",
"$",
"command",
")",
"{",
"return",
"new",
"CommandShortcut",
"(",
"$",
"command",
",",
"$",
"this",
"->",
"commands",
"[",
"$",
"command",
"]",
"[",
"'options'",
"]",
",",
"$",
"this",
"->",
"commands",
"[",
"$",
"command",
"]",
"[",
"'file'",
"]",
")",
";",
"}"
] |
Provides the command specification.
@param string $command
@return \derhasi\buddy\CommandShortcut
Command shortcut
|
[
"Provides",
"the",
"command",
"specification",
"."
] |
a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165
|
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L86-L89
|
21,166 |
derhasi/buddy
|
src/Config.php
|
Config.getPotentialDirectories
|
protected function getPotentialDirectories($workingDir)
{
$paths = array();
$path = '';
foreach (explode('/', $workingDir) as $part) {
$path .= $part . '/';
$paths[] = rtrim($path, '/');
}
return $paths;
}
|
php
|
protected function getPotentialDirectories($workingDir)
{
$paths = array();
$path = '';
foreach (explode('/', $workingDir) as $part) {
$path .= $part . '/';
$paths[] = rtrim($path, '/');
}
return $paths;
}
|
[
"protected",
"function",
"getPotentialDirectories",
"(",
"$",
"workingDir",
")",
"{",
"$",
"paths",
"=",
"array",
"(",
")",
";",
"$",
"path",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"'/'",
",",
"$",
"workingDir",
")",
"as",
"$",
"part",
")",
"{",
"$",
"path",
".=",
"$",
"part",
".",
"'/'",
";",
"$",
"paths",
"[",
"]",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"}",
"return",
"$",
"paths",
";",
"}"
] |
Helper to provide potential directories to look for .buddy.yml files.
@return array
List of directory paths.
|
[
"Helper",
"to",
"provide",
"potential",
"directories",
"to",
"look",
"for",
".",
"buddy",
".",
"yml",
"files",
"."
] |
a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165
|
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/Config.php#L97-L106
|
21,167 |
nabab/bbn
|
src/bbn/db/languages/mysql.php
|
mysql.get_group_by
|
public function get_group_by(array $cfg): string
{
$res = '';
$group_to_put = [];
if ( !empty($cfg['group_by']) ){
foreach ( $cfg['group_by'] as $g ){
if ( isset($cfg['available_fields'][$g]) ){
$group_to_put[] = $this->escape($g);
//$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);
}
else{
$this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true));
}
}
if ( count($group_to_put) ){
$res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL;
}
}
return $res;
}
|
php
|
public function get_group_by(array $cfg): string
{
$res = '';
$group_to_put = [];
if ( !empty($cfg['group_by']) ){
foreach ( $cfg['group_by'] as $g ){
if ( isset($cfg['available_fields'][$g]) ){
$group_to_put[] = $this->escape($g);
//$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);
}
else{
$this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true));
}
}
if ( count($group_to_put) ){
$res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL;
}
}
return $res;
}
|
[
"public",
"function",
"get_group_by",
"(",
"array",
"$",
"cfg",
")",
":",
"string",
"{",
"$",
"res",
"=",
"''",
";",
"$",
"group_to_put",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'group_by'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"cfg",
"[",
"'group_by'",
"]",
"as",
"$",
"g",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cfg",
"[",
"'available_fields'",
"]",
"[",
"$",
"g",
"]",
")",
")",
"{",
"$",
"group_to_put",
"[",
"]",
"=",
"$",
"this",
"->",
"escape",
"(",
"$",
"g",
")",
";",
"//$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);",
"}",
"else",
"{",
"$",
"this",
"->",
"db",
"->",
"error",
"(",
"\"Error! The column '$g' doesn't exist for group by \"",
".",
"print_r",
"(",
"$",
"cfg",
",",
"true",
")",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"group_to_put",
")",
")",
"{",
"$",
"res",
".=",
"'GROUP BY '",
".",
"implode",
"(",
"', '",
",",
"$",
"group_to_put",
")",
".",
"PHP_EOL",
";",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] |
Returns a string with the GROUP BY part of the query if there is, empty otherwise
@param array $cfg
@return string
|
[
"Returns",
"a",
"string",
"with",
"the",
"GROUP",
"BY",
"part",
"of",
"the",
"query",
"if",
"there",
"is",
"empty",
"otherwise"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L948-L967
|
21,168 |
nabab/bbn
|
src/bbn/db/languages/mysql.php
|
mysql.get_having
|
public function get_having(array $cfg): string
{
$res = '';
if ( !empty($cfg['group_by']) && !empty($cfg['having']) && ($cond = $this->get_conditions($cfg['having'], $cfg, true)) ){
$res .= 'HAVING '.$cond.PHP_EOL;
}
return $res;
}
|
php
|
public function get_having(array $cfg): string
{
$res = '';
if ( !empty($cfg['group_by']) && !empty($cfg['having']) && ($cond = $this->get_conditions($cfg['having'], $cfg, true)) ){
$res .= 'HAVING '.$cond.PHP_EOL;
}
return $res;
}
|
[
"public",
"function",
"get_having",
"(",
"array",
"$",
"cfg",
")",
":",
"string",
"{",
"$",
"res",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'group_by'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'having'",
"]",
")",
"&&",
"(",
"$",
"cond",
"=",
"$",
"this",
"->",
"get_conditions",
"(",
"$",
"cfg",
"[",
"'having'",
"]",
",",
"$",
"cfg",
",",
"true",
")",
")",
")",
"{",
"$",
"res",
".=",
"'HAVING '",
".",
"$",
"cond",
".",
"PHP_EOL",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Returns a string with the HAVING part of the query if there is, empty otherwise
@param array $cfg
@return string
|
[
"Returns",
"a",
"string",
"with",
"the",
"HAVING",
"part",
"of",
"the",
"query",
"if",
"there",
"is",
"empty",
"otherwise"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L975-L982
|
21,169 |
nabab/bbn
|
src/bbn/db/languages/mysql.php
|
mysql.create_index
|
public function create_index(string $table, $column, bool $unique = false, $length = null): bool
{
$column = (array)$column;
if ( $length ){
$length = (array)$length;
}
$name = bbn\str::encode_filename($table);
if ( $table = $this->table_full_name($table, true) ){
foreach ( $column as $i => $c ){
if ( !bbn\str::check_name($c) ){
$this->db->error("Illegal column $c");
}
$name .= '_'.$c;
$column[$i] = $this->escape($column[$i]);
if ( \is_int($length[$i]) && $length[$i] > 0 ){
$column[$i] .= '('.$length[$i].')';
}
}
$name = bbn\str::cut($name, 50);
return (bool)$this->db->query('CREATE '.( $unique ? 'UNIQUE ' : '' )."INDEX `$name` ON $table ( ".
implode(', ', $column).' )');
}
return false;
}
|
php
|
public function create_index(string $table, $column, bool $unique = false, $length = null): bool
{
$column = (array)$column;
if ( $length ){
$length = (array)$length;
}
$name = bbn\str::encode_filename($table);
if ( $table = $this->table_full_name($table, true) ){
foreach ( $column as $i => $c ){
if ( !bbn\str::check_name($c) ){
$this->db->error("Illegal column $c");
}
$name .= '_'.$c;
$column[$i] = $this->escape($column[$i]);
if ( \is_int($length[$i]) && $length[$i] > 0 ){
$column[$i] .= '('.$length[$i].')';
}
}
$name = bbn\str::cut($name, 50);
return (bool)$this->db->query('CREATE '.( $unique ? 'UNIQUE ' : '' )."INDEX `$name` ON $table ( ".
implode(', ', $column).' )');
}
return false;
}
|
[
"public",
"function",
"create_index",
"(",
"string",
"$",
"table",
",",
"$",
"column",
",",
"bool",
"$",
"unique",
"=",
"false",
",",
"$",
"length",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"column",
"=",
"(",
"array",
")",
"$",
"column",
";",
"if",
"(",
"$",
"length",
")",
"{",
"$",
"length",
"=",
"(",
"array",
")",
"$",
"length",
";",
"}",
"$",
"name",
"=",
"bbn",
"\\",
"str",
"::",
"encode_filename",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"table",
"=",
"$",
"this",
"->",
"table_full_name",
"(",
"$",
"table",
",",
"true",
")",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"i",
"=>",
"$",
"c",
")",
"{",
"if",
"(",
"!",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"c",
")",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"error",
"(",
"\"Illegal column $c\"",
")",
";",
"}",
"$",
"name",
".=",
"'_'",
".",
"$",
"c",
";",
"$",
"column",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"escape",
"(",
"$",
"column",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"length",
"[",
"$",
"i",
"]",
")",
"&&",
"$",
"length",
"[",
"$",
"i",
"]",
">",
"0",
")",
"{",
"$",
"column",
"[",
"$",
"i",
"]",
".=",
"'('",
".",
"$",
"length",
"[",
"$",
"i",
"]",
".",
"')'",
";",
"}",
"}",
"$",
"name",
"=",
"bbn",
"\\",
"str",
"::",
"cut",
"(",
"$",
"name",
",",
"50",
")",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'CREATE '",
".",
"(",
"$",
"unique",
"?",
"'UNIQUE '",
":",
"''",
")",
".",
"\"INDEX `$name` ON $table ( \"",
".",
"implode",
"(",
"', '",
",",
"$",
"column",
")",
".",
"' )'",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Creates an index
@param null|string $table
@param string|array $column
@param bool $unique
@param null $length
@return bool
|
[
"Creates",
"an",
"index"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1124-L1147
|
21,170 |
nabab/bbn
|
src/bbn/db/languages/mysql.php
|
mysql.delete_user
|
public function delete_user(string $user): bool
{
if ( bbn\str::check_name($user) ){
$this->db->raw_query("
REVOKE ALL PRIVILEGES ON *.*
FROM $user");
return (bool)$this->db->query("DROP USER $user");
}
return false;
}
|
php
|
public function delete_user(string $user): bool
{
if ( bbn\str::check_name($user) ){
$this->db->raw_query("
REVOKE ALL PRIVILEGES ON *.*
FROM $user");
return (bool)$this->db->query("DROP USER $user");
}
return false;
}
|
[
"public",
"function",
"delete_user",
"(",
"string",
"$",
"user",
")",
":",
"bool",
"{",
"if",
"(",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"user",
")",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"raw_query",
"(",
"\"\n\t\t\tREVOKE ALL PRIVILEGES ON *.*\n\t\t\tFROM $user\"",
")",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"DROP USER $user\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Deletes a database user
@param string $user
@return bool
|
[
"Deletes",
"a",
"database",
"user"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/mysql.php#L1206-L1215
|
21,171 |
Laralum/Users
|
src/Controllers/UserController.php
|
UserController.manageRoles
|
public function manageRoles(User $user)
{
$this->authorize('roles', $user);
$roles = Role::all();
return view('laralum_users::roles', ['user' => $user, 'roles' => $roles]);
}
|
php
|
public function manageRoles(User $user)
{
$this->authorize('roles', $user);
$roles = Role::all();
return view('laralum_users::roles', ['user' => $user, 'roles' => $roles]);
}
|
[
"public",
"function",
"manageRoles",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'roles'",
",",
"$",
"user",
")",
";",
"$",
"roles",
"=",
"Role",
"::",
"all",
"(",
")",
";",
"return",
"view",
"(",
"'laralum_users::roles'",
",",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'roles'",
"=>",
"$",
"roles",
"]",
")",
";",
"}"
] |
Manage roles from users.
@param \Laralum\Users\Models\User $user
@return \Illuminate\Http\Response
|
[
"Manage",
"roles",
"from",
"users",
"."
] |
788851d4cdf4bff548936faf1b12cf4697d13428
|
https://github.com/Laralum/Users/blob/788851d4cdf4bff548936faf1b12cf4697d13428/src/Controllers/UserController.php#L137-L144
|
21,172 |
GrupaZero/api
|
src/Gzero/Api/Transformer/UserTransformer.php
|
UserTransformer.transform
|
public function transform($user)
{
$user = $this->entityToArray(User::class, $user);
return [
'id' => (int) $user['id'],
'email' => $user['email'],
'nick' => $user['nick'],
'firstName' => $user['first_name'],
'lastName' => $user['last_name'],
'roles' => !empty($user['roles']) ? $user['roles'] : []
];
}
|
php
|
public function transform($user)
{
$user = $this->entityToArray(User::class, $user);
return [
'id' => (int) $user['id'],
'email' => $user['email'],
'nick' => $user['nick'],
'firstName' => $user['first_name'],
'lastName' => $user['last_name'],
'roles' => !empty($user['roles']) ? $user['roles'] : []
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"User",
"::",
"class",
",",
"$",
"user",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"user",
"[",
"'id'",
"]",
",",
"'email'",
"=>",
"$",
"user",
"[",
"'email'",
"]",
",",
"'nick'",
"=>",
"$",
"user",
"[",
"'nick'",
"]",
",",
"'firstName'",
"=>",
"$",
"user",
"[",
"'first_name'",
"]",
",",
"'lastName'",
"=>",
"$",
"user",
"[",
"'last_name'",
"]",
",",
"'roles'",
"=>",
"!",
"empty",
"(",
"$",
"user",
"[",
"'roles'",
"]",
")",
"?",
"$",
"user",
"[",
"'roles'",
"]",
":",
"[",
"]",
"]",
";",
"}"
] |
Transforms user entity
@param User|array $user User entity
@return array
|
[
"Transforms",
"user",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/UserTransformer.php#L35-L46
|
21,173 |
SporkCode/Spork
|
src/Mvc/Listener/XmlHttpRequestStrategy.php
|
XmlHttpRequestStrategy.handleXmlHttpRequest
|
public function handleXmlHttpRequest(MvcEvent $event)
{
$request = $event->getRequest();
if ($request->isXMLHttpRequest()) {
$dispatchResult = $event->getResult();
if ($dispatchResult instanceof ViewModel) {
$dispatchResult->setTerminal(true);
}
}
}
|
php
|
public function handleXmlHttpRequest(MvcEvent $event)
{
$request = $event->getRequest();
if ($request->isXMLHttpRequest()) {
$dispatchResult = $event->getResult();
if ($dispatchResult instanceof ViewModel) {
$dispatchResult->setTerminal(true);
}
}
}
|
[
"public",
"function",
"handleXmlHttpRequest",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isXMLHttpRequest",
"(",
")",
")",
"{",
"$",
"dispatchResult",
"=",
"$",
"event",
"->",
"getResult",
"(",
")",
";",
"if",
"(",
"$",
"dispatchResult",
"instanceof",
"ViewModel",
")",
"{",
"$",
"dispatchResult",
"->",
"setTerminal",
"(",
"true",
")",
";",
"}",
"}",
"}"
] |
If request is an XML HTTP Request disable layouts
@param MvcEvent $event
|
[
"If",
"request",
"is",
"an",
"XML",
"HTTP",
"Request",
"disable",
"layouts"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/XmlHttpRequestStrategy.php#L41-L50
|
21,174 |
ajgarlag/AjglSessionConcurrency
|
src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php
|
ConcurrentSessionControlAuthenticationStrategy.allowedSessionsExceeded
|
protected function allowedSessionsExceeded($orderedSessions, $allowableSessions, SessionRegistry $registry)
{
if ($this->errorIfMaximumExceeded) {
throw new MaxSessionsExceededException(sprintf('Maximum number of sessions (%s) exceeded', $allowableSessions));
}
// Expire oldest session
$orderedSessionsVector = array_values($orderedSessions);
for ($i = $allowableSessions - 1, $countSessions = count($orderedSessionsVector); $i < $countSessions; $i++) {
$registry->expireNow($orderedSessionsVector[$i]->getSessionId());
}
}
|
php
|
protected function allowedSessionsExceeded($orderedSessions, $allowableSessions, SessionRegistry $registry)
{
if ($this->errorIfMaximumExceeded) {
throw new MaxSessionsExceededException(sprintf('Maximum number of sessions (%s) exceeded', $allowableSessions));
}
// Expire oldest session
$orderedSessionsVector = array_values($orderedSessions);
for ($i = $allowableSessions - 1, $countSessions = count($orderedSessionsVector); $i < $countSessions; $i++) {
$registry->expireNow($orderedSessionsVector[$i]->getSessionId());
}
}
|
[
"protected",
"function",
"allowedSessionsExceeded",
"(",
"$",
"orderedSessions",
",",
"$",
"allowableSessions",
",",
"SessionRegistry",
"$",
"registry",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"errorIfMaximumExceeded",
")",
"{",
"throw",
"new",
"MaxSessionsExceededException",
"(",
"sprintf",
"(",
"'Maximum number of sessions (%s) exceeded'",
",",
"$",
"allowableSessions",
")",
")",
";",
"}",
"// Expire oldest session",
"$",
"orderedSessionsVector",
"=",
"array_values",
"(",
"$",
"orderedSessions",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"allowableSessions",
"-",
"1",
",",
"$",
"countSessions",
"=",
"count",
"(",
"$",
"orderedSessionsVector",
")",
";",
"$",
"i",
"<",
"$",
"countSessions",
";",
"$",
"i",
"++",
")",
"{",
"$",
"registry",
"->",
"expireNow",
"(",
"$",
"orderedSessionsVector",
"[",
"$",
"i",
"]",
"->",
"getSessionId",
"(",
")",
")",
";",
"}",
"}"
] |
Allows subclasses to customize behavior when too many sessions are detected.
@param Registry\SessionInformation[] $orderedSessions Array of SessionInformation ordered from newest to oldest
@param int $allowableSessions
@param SessionRegistry $registry
|
[
"Allows",
"subclasses",
"to",
"customize",
"behavior",
"when",
"too",
"many",
"sessions",
"are",
"detected",
"."
] |
daa3b1ff3ad4951947f7192e12b2496555e135fb
|
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/Session/ConcurrentSessionControlAuthenticationStrategy.php#L104-L115
|
21,175 |
ClementIV/yii-rest-rbac2.0
|
controllers/MenuController.php
|
MenuController.actionGetMenus
|
public function actionGetMenus()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
return Menu::getMenuSource();
}catch(Exception $e){
throw new Exception($e);
}
}
|
php
|
public function actionGetMenus()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
return Menu::getMenuSource();
}catch(Exception $e){
throw new Exception($e);
}
}
|
[
"public",
"function",
"actionGetMenus",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'index'",
"]",
")",
";",
"}",
"try",
"{",
"return",
"Menu",
"::",
"getMenuSource",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
list all menus
@return json list
|
[
"list",
"all",
"menus"
] |
435ffceca8d51b4d369182db3a06c20f336e9ac4
|
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L71-L82
|
21,176 |
ClementIV/yii-rest-rbac2.0
|
controllers/MenuController.php
|
MenuController.actionGetSavedRoutes
|
public function actionGetSavedRoutes()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
return Menu::getSavedRoutes();
}catch(Exception $e){
throw new Exception($e);
}
}
|
php
|
public function actionGetSavedRoutes()
{
$request = \Yii::$app->request;
if ($request->getIsOptions()) {
return $this->ResponseOptions($this->verbs()['index']);
}
try{
return Menu::getSavedRoutes();
}catch(Exception $e){
throw new Exception($e);
}
}
|
[
"public",
"function",
"actionGetSavedRoutes",
"(",
")",
"{",
"$",
"request",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
";",
"if",
"(",
"$",
"request",
"->",
"getIsOptions",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"ResponseOptions",
"(",
"$",
"this",
"->",
"verbs",
"(",
")",
"[",
"'index'",
"]",
")",
";",
"}",
"try",
"{",
"return",
"Menu",
"::",
"getSavedRoutes",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
list all menus route
@return json list
|
[
"list",
"all",
"menus",
"route"
] |
435ffceca8d51b4d369182db3a06c20f336e9ac4
|
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/MenuController.php#L88-L99
|
21,177 |
novaway/open-graph
|
src/OpenGraphGenerator.php
|
OpenGraphGenerator.generate
|
public function generate($obj)
{
if (!is_object($obj)) {
throw new \InvalidArgumentException('OpenGraphGenerator::generate only accept object argument.');
}
$openGraph = new OpenGraph();
$classType = get_class($obj);
$metadata = $this->factory->getMetadataForClass($classType);
if (is_array($metadata->namespaces)) {
foreach ($metadata->namespaces as $namespace) {
$openGraph->addNamespace($namespace->prefix, $namespace->uri);
}
}
if (is_array($metadata->nodes)) {
foreach ($metadata->nodes as $graphNode) {
if (!empty($graphNode['node']->namespaceUri)) {
$openGraph->addNamespace($graphNode['node']->namespace, $graphNode['node']->namespaceUri);
}
$openGraph->add($graphNode['node']->namespace, $graphNode['node']->tag, $graphNode['object']->getValue($obj));
}
}
return $openGraph;
}
|
php
|
public function generate($obj)
{
if (!is_object($obj)) {
throw new \InvalidArgumentException('OpenGraphGenerator::generate only accept object argument.');
}
$openGraph = new OpenGraph();
$classType = get_class($obj);
$metadata = $this->factory->getMetadataForClass($classType);
if (is_array($metadata->namespaces)) {
foreach ($metadata->namespaces as $namespace) {
$openGraph->addNamespace($namespace->prefix, $namespace->uri);
}
}
if (is_array($metadata->nodes)) {
foreach ($metadata->nodes as $graphNode) {
if (!empty($graphNode['node']->namespaceUri)) {
$openGraph->addNamespace($graphNode['node']->namespace, $graphNode['node']->namespaceUri);
}
$openGraph->add($graphNode['node']->namespace, $graphNode['node']->tag, $graphNode['object']->getValue($obj));
}
}
return $openGraph;
}
|
[
"public",
"function",
"generate",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'OpenGraphGenerator::generate only accept object argument.'",
")",
";",
"}",
"$",
"openGraph",
"=",
"new",
"OpenGraph",
"(",
")",
";",
"$",
"classType",
"=",
"get_class",
"(",
"$",
"obj",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"factory",
"->",
"getMetadataForClass",
"(",
"$",
"classType",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"metadata",
"->",
"namespaces",
")",
")",
"{",
"foreach",
"(",
"$",
"metadata",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"openGraph",
"->",
"addNamespace",
"(",
"$",
"namespace",
"->",
"prefix",
",",
"$",
"namespace",
"->",
"uri",
")",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"metadata",
"->",
"nodes",
")",
")",
"{",
"foreach",
"(",
"$",
"metadata",
"->",
"nodes",
"as",
"$",
"graphNode",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"graphNode",
"[",
"'node'",
"]",
"->",
"namespaceUri",
")",
")",
"{",
"$",
"openGraph",
"->",
"addNamespace",
"(",
"$",
"graphNode",
"[",
"'node'",
"]",
"->",
"namespace",
",",
"$",
"graphNode",
"[",
"'node'",
"]",
"->",
"namespaceUri",
")",
";",
"}",
"$",
"openGraph",
"->",
"add",
"(",
"$",
"graphNode",
"[",
"'node'",
"]",
"->",
"namespace",
",",
"$",
"graphNode",
"[",
"'node'",
"]",
"->",
"tag",
",",
"$",
"graphNode",
"[",
"'object'",
"]",
"->",
"getValue",
"(",
"$",
"obj",
")",
")",
";",
"}",
"}",
"return",
"$",
"openGraph",
";",
"}"
] |
Generate OpenGraph through metadata
@param object $obj
@return OpenGraphInterface
|
[
"Generate",
"OpenGraph",
"through",
"metadata"
] |
19817bee4b91cf26ca3fe44883ad58b32328e464
|
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/OpenGraphGenerator.php#L29-L58
|
21,178 |
OKTOTV/OktolabMediaBundle
|
Model/EpisodeAssetDataJob.php
|
EpisodeAssetDataJob.getStreamInformationsOfEpisode
|
private function getStreamInformationsOfEpisode($episode)
{
$uri = $this->getContainer()->get('bprs.asset_helper')->getAbsoluteUrl($episode->getVideo());
if (!$uri) { // can't create uri of episode video
$this->logbook->error('oktolab_media.episode_assetdatajob_nourl', [], $this->args['uniqID']);
return false;
}
$metadata = ['video' => false, 'audio' => false];
try {
$metainfo = json_decode(shell_exec(sprintf('ffprobe -v error -show_streams -print_format json %s', $uri)), true);
foreach ($metainfo['streams'] as $stream) {
if ($metadata['video'] && $metadata['audio']) {
break;
}
if ($stream['codec_type'] == "audio") {
$metadata['audio'] = $stream;
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
}
}
} catch (Exception $e) {
$metadata = null;
}
return $metadata;
}
|
php
|
private function getStreamInformationsOfEpisode($episode)
{
$uri = $this->getContainer()->get('bprs.asset_helper')->getAbsoluteUrl($episode->getVideo());
if (!$uri) { // can't create uri of episode video
$this->logbook->error('oktolab_media.episode_assetdatajob_nourl', [], $this->args['uniqID']);
return false;
}
$metadata = ['video' => false, 'audio' => false];
try {
$metainfo = json_decode(shell_exec(sprintf('ffprobe -v error -show_streams -print_format json %s', $uri)), true);
foreach ($metainfo['streams'] as $stream) {
if ($metadata['video'] && $metadata['audio']) {
break;
}
if ($stream['codec_type'] == "audio") {
$metadata['audio'] = $stream;
}
if ($stream['codec_type'] == "video") {
$metadata['video'] = $stream;
}
}
} catch (Exception $e) {
$metadata = null;
}
return $metadata;
}
|
[
"private",
"function",
"getStreamInformationsOfEpisode",
"(",
"$",
"episode",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'bprs.asset_helper'",
")",
"->",
"getAbsoluteUrl",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"uri",
")",
"{",
"// can't create uri of episode video",
"$",
"this",
"->",
"logbook",
"->",
"error",
"(",
"'oktolab_media.episode_assetdatajob_nourl'",
",",
"[",
"]",
",",
"$",
"this",
"->",
"args",
"[",
"'uniqID'",
"]",
")",
";",
"return",
"false",
";",
"}",
"$",
"metadata",
"=",
"[",
"'video'",
"=>",
"false",
",",
"'audio'",
"=>",
"false",
"]",
";",
"try",
"{",
"$",
"metainfo",
"=",
"json_decode",
"(",
"shell_exec",
"(",
"sprintf",
"(",
"'ffprobe -v error -show_streams -print_format json %s'",
",",
"$",
"uri",
")",
")",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"metainfo",
"[",
"'streams'",
"]",
"as",
"$",
"stream",
")",
"{",
"if",
"(",
"$",
"metadata",
"[",
"'video'",
"]",
"&&",
"$",
"metadata",
"[",
"'audio'",
"]",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"audio\"",
")",
"{",
"$",
"metadata",
"[",
"'audio'",
"]",
"=",
"$",
"stream",
";",
"}",
"if",
"(",
"$",
"stream",
"[",
"'codec_type'",
"]",
"==",
"\"video\"",
")",
"{",
"$",
"metadata",
"[",
"'video'",
"]",
"=",
"$",
"stream",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"metadata",
"=",
"null",
";",
"}",
"return",
"$",
"metadata",
";",
"}"
] |
extracts streaminformations of an episode from its video.
returns false if informations can't be extracted
returns array of video and audio info.
|
[
"extracts",
"streaminformations",
"of",
"an",
"episode",
"from",
"its",
"video",
".",
"returns",
"false",
"if",
"informations",
"can",
"t",
"be",
"extracted",
"returns",
"array",
"of",
"video",
"and",
"audio",
"info",
"."
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/EpisodeAssetDataJob.php#L77-L103
|
21,179 |
oroinc/OroLayoutComponent
|
Layouts.php
|
Layouts.createLayoutFactoryBuilder
|
public static function createLayoutFactoryBuilder()
{
$builder = new LayoutFactoryBuilder(
new ExpressionProcessor(
new ExpressionLanguage(),
new ExpressionEncoderRegistry(
[
'json' => new JsonExpressionEncoder(new ExpressionManipulator())
]
)
)
);
$builder->addExtension(new CoreExtension());
return $builder;
}
|
php
|
public static function createLayoutFactoryBuilder()
{
$builder = new LayoutFactoryBuilder(
new ExpressionProcessor(
new ExpressionLanguage(),
new ExpressionEncoderRegistry(
[
'json' => new JsonExpressionEncoder(new ExpressionManipulator())
]
)
)
);
$builder->addExtension(new CoreExtension());
return $builder;
}
|
[
"public",
"static",
"function",
"createLayoutFactoryBuilder",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"LayoutFactoryBuilder",
"(",
"new",
"ExpressionProcessor",
"(",
"new",
"ExpressionLanguage",
"(",
")",
",",
"new",
"ExpressionEncoderRegistry",
"(",
"[",
"'json'",
"=>",
"new",
"JsonExpressionEncoder",
"(",
"new",
"ExpressionManipulator",
"(",
")",
")",
"]",
")",
")",
")",
";",
"$",
"builder",
"->",
"addExtension",
"(",
"new",
"CoreExtension",
"(",
")",
")",
";",
"return",
"$",
"builder",
";",
"}"
] |
Creates a layout factory builder with the default configuration.
@return LayoutFactoryBuilderInterface
|
[
"Creates",
"a",
"layout",
"factory",
"builder",
"with",
"the",
"default",
"configuration",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Layouts.php#L110-L126
|
21,180 |
phpnfe/tools
|
src/Strings.php
|
Strings.clearXml
|
public static function clearXml($xml = '', $remEnc = false)
{
//$xml = self::clearMsg($xml);
$aFind = [
'xmlns:default="http://www.w3.org/2000/09/xmldsig#"',
' standalone="no"',
'default:',
':default',
"\n",
"\r",
"\t",
];
if ($remEnc) {
$aFind[] = '<?xml version="1.0"?>';
$aFind[] = '<?xml version="1.0" encoding="utf-8"?>';
$aFind[] = '<?xml version="1.0" encoding="UTF-8"?>';
$aFind[] = '<?xml version="1.0" encoding="utf-8" standalone="no"?>';
$aFind[] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
}
$retXml = str_replace($aFind, '', $xml);
return $retXml;
}
|
php
|
public static function clearXml($xml = '', $remEnc = false)
{
//$xml = self::clearMsg($xml);
$aFind = [
'xmlns:default="http://www.w3.org/2000/09/xmldsig#"',
' standalone="no"',
'default:',
':default',
"\n",
"\r",
"\t",
];
if ($remEnc) {
$aFind[] = '<?xml version="1.0"?>';
$aFind[] = '<?xml version="1.0" encoding="utf-8"?>';
$aFind[] = '<?xml version="1.0" encoding="UTF-8"?>';
$aFind[] = '<?xml version="1.0" encoding="utf-8" standalone="no"?>';
$aFind[] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
}
$retXml = str_replace($aFind, '', $xml);
return $retXml;
}
|
[
"public",
"static",
"function",
"clearXml",
"(",
"$",
"xml",
"=",
"''",
",",
"$",
"remEnc",
"=",
"false",
")",
"{",
"//$xml = self::clearMsg($xml);",
"$",
"aFind",
"=",
"[",
"'xmlns:default=\"http://www.w3.org/2000/09/xmldsig#\"'",
",",
"' standalone=\"no\"'",
",",
"'default:'",
",",
"':default'",
",",
"\"\\n\"",
",",
"\"\\r\"",
",",
"\"\\t\"",
",",
"]",
";",
"if",
"(",
"$",
"remEnc",
")",
"{",
"$",
"aFind",
"[",
"]",
"=",
"'<?xml version=\"1.0\"?>'",
";",
"$",
"aFind",
"[",
"]",
"=",
"'<?xml version=\"1.0\" encoding=\"utf-8\"?>'",
";",
"$",
"aFind",
"[",
"]",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
";",
"$",
"aFind",
"[",
"]",
"=",
"'<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>'",
";",
"$",
"aFind",
"[",
"]",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>'",
";",
"}",
"$",
"retXml",
"=",
"str_replace",
"(",
"$",
"aFind",
",",
"''",
",",
"$",
"xml",
")",
";",
"return",
"$",
"retXml",
";",
"}"
] |
clearXml
Remove \r \n \s \t.
@param string $xml
@param bool $remEnc remover encoding do xml
@return string
|
[
"clearXml",
"Remove",
"\\",
"r",
"\\",
"n",
"\\",
"s",
"\\",
"t",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Strings.php#L38-L60
|
21,181 |
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Parser/UTF8Utils.php
|
HTML5_Parser_UTF8Utils.countChars
|
public static function countChars($string) {
// Get the length for the string we need.
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, 'utf-8');
} elseif (function_exists('mb_strlen')) {
return mb_strlen($string, 'utf-8');
} elseif (function_exists('utf8_decode')) {
// MPB: Will this work? Won't certain decodes lead to two chars
// extrapolated out of 2-byte chars?
return strlen(utf8_decode($string));
}
$count = count_chars($string);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) + array_sum(array_slice($count, 0xC2, 0x33));
}
|
php
|
public static function countChars($string) {
// Get the length for the string we need.
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, 'utf-8');
} elseif (function_exists('mb_strlen')) {
return mb_strlen($string, 'utf-8');
} elseif (function_exists('utf8_decode')) {
// MPB: Will this work? Won't certain decodes lead to two chars
// extrapolated out of 2-byte chars?
return strlen(utf8_decode($string));
}
$count = count_chars($string);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) + array_sum(array_slice($count, 0xC2, 0x33));
}
|
[
"public",
"static",
"function",
"countChars",
"(",
"$",
"string",
")",
"{",
"// Get the length for the string we need.",
"if",
"(",
"function_exists",
"(",
"'iconv_strlen'",
")",
")",
"{",
"return",
"iconv_strlen",
"(",
"$",
"string",
",",
"'utf-8'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'mb_strlen'",
")",
")",
"{",
"return",
"mb_strlen",
"(",
"$",
"string",
",",
"'utf-8'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'utf8_decode'",
")",
")",
"{",
"// MPB: Will this work? Won't certain decodes lead to two chars",
"// extrapolated out of 2-byte chars?",
"return",
"strlen",
"(",
"utf8_decode",
"(",
"$",
"string",
")",
")",
";",
"}",
"$",
"count",
"=",
"count_chars",
"(",
"$",
"string",
")",
";",
"// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)",
"// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)",
"return",
"array_sum",
"(",
"array_slice",
"(",
"$",
"count",
",",
"0",
",",
"0x80",
")",
")",
"+",
"array_sum",
"(",
"array_slice",
"(",
"$",
"count",
",",
"0xC2",
",",
"0x33",
")",
")",
";",
"}"
] |
Count the number of characters in a string.
UTF-8 aware. This will try (in order) iconv,
MB, libxml, and finally a custom counter.
@todo Move this to a general utility class.
|
[
"Count",
"the",
"number",
"of",
"characters",
"in",
"a",
"string",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L133-L148
|
21,182 |
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Parser/UTF8Utils.php
|
HTML5_Parser_UTF8Utils.convertToUTF8
|
public static function convertToUTF8($data, $encoding = 'UTF-8') {
/*
* From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.
*/
// mb_convert_encoding is chosen over iconv because of a bug. The best
// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643
// which contains links to the actual but reports as well as work around
// details.
if (function_exists('mb_convert_encoding')) {
// mb library has the following behaviors:
// - UTF-16 surrogates result in false.
// - Overlongs and outside Plane 16 result in empty strings.
// Before we run mb_convert_encoding we need to tell it what to do with
// characters it does not know. This could be different than the parent
// application executing this library so we store the value, change it
// to our needs, and then change it back when we are done. This feels
// a little excessive and it would be great if there was a better way.
$save = ini_get('mbstring.substitute_character');
ini_set('mbstring.substitute_character', "none");
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
ini_set('mbstring.substitute_character', $save);
} // @todo Get iconv running in at least some environments if that is possible.
elseif (function_exists('iconv') && $encoding != 'auto') {
// fprintf(STDOUT, "iconv found\n");
// iconv has the following behaviors:
// - Overlong representations are ignored.
// - Beyond Plane 16 is replaced with a lower char.
// - Incomplete sequences generate a warning.
$data = @iconv($encoding, 'UTF-8//IGNORE', $data);
} else {
// we can make a conforming native implementation
throw new Exception('Not implemented, please install mbstring or iconv');
}
/*
* One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.
*/
if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
$data = substr($data, 3);
}
return $data;
}
|
php
|
public static function convertToUTF8($data, $encoding = 'UTF-8') {
/*
* From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.
*/
// mb_convert_encoding is chosen over iconv because of a bug. The best
// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643
// which contains links to the actual but reports as well as work around
// details.
if (function_exists('mb_convert_encoding')) {
// mb library has the following behaviors:
// - UTF-16 surrogates result in false.
// - Overlongs and outside Plane 16 result in empty strings.
// Before we run mb_convert_encoding we need to tell it what to do with
// characters it does not know. This could be different than the parent
// application executing this library so we store the value, change it
// to our needs, and then change it back when we are done. This feels
// a little excessive and it would be great if there was a better way.
$save = ini_get('mbstring.substitute_character');
ini_set('mbstring.substitute_character', "none");
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
ini_set('mbstring.substitute_character', $save);
} // @todo Get iconv running in at least some environments if that is possible.
elseif (function_exists('iconv') && $encoding != 'auto') {
// fprintf(STDOUT, "iconv found\n");
// iconv has the following behaviors:
// - Overlong representations are ignored.
// - Beyond Plane 16 is replaced with a lower char.
// - Incomplete sequences generate a warning.
$data = @iconv($encoding, 'UTF-8//IGNORE', $data);
} else {
// we can make a conforming native implementation
throw new Exception('Not implemented, please install mbstring or iconv');
}
/*
* One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.
*/
if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
$data = substr($data, 3);
}
return $data;
}
|
[
"public",
"static",
"function",
"convertToUTF8",
"(",
"$",
"data",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"/*\n * From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.\n */",
"// mb_convert_encoding is chosen over iconv because of a bug. The best",
"// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643",
"// which contains links to the actual but reports as well as work around",
"// details.",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
")",
"{",
"// mb library has the following behaviors:",
"// - UTF-16 surrogates result in false.",
"// - Overlongs and outside Plane 16 result in empty strings.",
"// Before we run mb_convert_encoding we need to tell it what to do with",
"// characters it does not know. This could be different than the parent",
"// application executing this library so we store the value, change it",
"// to our needs, and then change it back when we are done. This feels",
"// a little excessive and it would be great if there was a better way.",
"$",
"save",
"=",
"ini_get",
"(",
"'mbstring.substitute_character'",
")",
";",
"ini_set",
"(",
"'mbstring.substitute_character'",
",",
"\"none\"",
")",
";",
"$",
"data",
"=",
"mb_convert_encoding",
"(",
"$",
"data",
",",
"'UTF-8'",
",",
"$",
"encoding",
")",
";",
"ini_set",
"(",
"'mbstring.substitute_character'",
",",
"$",
"save",
")",
";",
"}",
"// @todo Get iconv running in at least some environments if that is possible.",
"elseif",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"$",
"encoding",
"!=",
"'auto'",
")",
"{",
"// fprintf(STDOUT, \"iconv found\\n\");",
"// iconv has the following behaviors:",
"// - Overlong representations are ignored.",
"// - Beyond Plane 16 is replaced with a lower char.",
"// - Incomplete sequences generate a warning.",
"$",
"data",
"=",
"@",
"iconv",
"(",
"$",
"encoding",
",",
"'UTF-8//IGNORE'",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// we can make a conforming native implementation",
"throw",
"new",
"Exception",
"(",
"'Not implemented, please install mbstring or iconv'",
")",
";",
"}",
"/*\n * One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.\n */",
"if",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"3",
")",
"===",
"\"\\xEF\\xBB\\xBF\"",
")",
"{",
"$",
"data",
"=",
"substr",
"(",
"$",
"data",
",",
"3",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Convert data from the given encoding to UTF-8.
This has not yet been tested with charactersets other than UTF-8.
It should work with ISO-8859-1/-13 and standard Latin Win charsets.
@param string $data
The data to convert.
@param string $encoding
A valid encoding. Examples: http://www.php.net/manual/en/mbstring.supported-encodings.php
|
[
"Convert",
"data",
"from",
"the",
"given",
"encoding",
"to",
"UTF",
"-",
"8",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L161-L204
|
21,183 |
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Parser/UTF8Utils.php
|
HTML5_Parser_UTF8Utils.checkForIllegalCodepoints
|
public static function checkForIllegalCodepoints($data) {
if (!function_exists('preg_match_all')) {
throw HTML5_Exception('The PCRE library is not loaded or is not available.');
}
// Vestigal error handling.
$errors = array();
/*
* All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
*/
for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i ++) {
$errors[] = 'null-character';
}
/*
* Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)
*/
// Check PCRE is loaded.
$count = preg_match_all(
'/(?:
[\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F
|
\xC2[\x80-\x9F] # U+0080 to U+009F
|
\xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF
|
\xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF
|
\xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF
|
[\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
)/x', $data, $matches);
for ($i = 0; $i < $count; $i ++) {
$errors[] = 'invalid-codepoint';
}
return $errors;
}
|
php
|
public static function checkForIllegalCodepoints($data) {
if (!function_exists('preg_match_all')) {
throw HTML5_Exception('The PCRE library is not loaded or is not available.');
}
// Vestigal error handling.
$errors = array();
/*
* All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
*/
for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i ++) {
$errors[] = 'null-character';
}
/*
* Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)
*/
// Check PCRE is loaded.
$count = preg_match_all(
'/(?:
[\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F
|
\xC2[\x80-\x9F] # U+0080 to U+009F
|
\xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF
|
\xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF
|
\xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF
|
[\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
)/x', $data, $matches);
for ($i = 0; $i < $count; $i ++) {
$errors[] = 'invalid-codepoint';
}
return $errors;
}
|
[
"public",
"static",
"function",
"checkForIllegalCodepoints",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'preg_match_all'",
")",
")",
"{",
"throw",
"HTML5_Exception",
"(",
"'The PCRE library is not loaded or is not available.'",
")",
";",
"}",
"// Vestigal error handling.",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/*\n * All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.\n */",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"substr_count",
"(",
"$",
"data",
",",
"\"\\0\"",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'null-character'",
";",
"}",
"/*\n * Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)\n */",
"// Check PCRE is loaded.",
"$",
"count",
"=",
"preg_match_all",
"(",
"'/(?:\n [\\x01-\\x08\\x0B\\x0E-\\x1F\\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F\n |\n \\xC2[\\x80-\\x9F] # U+0080 to U+009F\n |\n \\xED(?:\\xA0[\\x80-\\xFF]|[\\xA1-\\xBE][\\x00-\\xFF]|\\xBF[\\x00-\\xBF]) # U+D800 to U+DFFFF\n |\n \\xEF\\xB7[\\x90-\\xAF] # U+FDD0 to U+FDEF\n |\n \\xEF\\xBF[\\xBE\\xBF] # U+FFFE and U+FFFF\n |\n [\\xF0-\\xF4][\\x8F-\\xBF]\\xBF[\\xBE\\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})\n )/x'",
",",
"$",
"data",
",",
"$",
"matches",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'invalid-codepoint'",
";",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Checks for Unicode code points that are not valid in a document.
@param string $data
A string to analyze.
@return array An array of (string) error messages produced by the scanning.
|
[
"Checks",
"for",
"Unicode",
"code",
"points",
"that",
"are",
"not",
"valid",
"in",
"a",
"document",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L213-L251
|
21,184 |
wplibs/rules
|
src/Rule.php
|
Rule.apply
|
public function apply( $context ) {
if ( ! $context instanceof RContext ) {
$context = new Context( $context );
}
return $this->evaluate( $context );
}
|
php
|
public function apply( $context ) {
if ( ! $context instanceof RContext ) {
$context = new Context( $context );
}
return $this->evaluate( $context );
}
|
[
"public",
"function",
"apply",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"instanceof",
"RContext",
")",
"{",
"$",
"context",
"=",
"new",
"Context",
"(",
"$",
"context",
")",
";",
"}",
"return",
"$",
"this",
"->",
"evaluate",
"(",
"$",
"context",
")",
";",
"}"
] |
Evaluate the Rule with the given Context.
@param \Ruler\Context|array $context Context with which to evaluate this Rule.
@return boolean
|
[
"Evaluate",
"the",
"Rule",
"with",
"the",
"given",
"Context",
"."
] |
29b4495e2ae87349fd64fcd844f3ba96cc268e3d
|
https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Rule.php#L31-L37
|
21,185 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php
|
ezcMailTools.generateMessageId
|
public static function generateMessageId( $hostname )
{
if ( strpos( $hostname, '@' ) !== false )
{
$hostname = strstr( $hostname, '@' );
}
else
{
$hostname = '@' . $hostname;
}
return date( 'YmdGHjs' ) . '.' . getmypid() . '.' . self::$idCounter++ . $hostname;
}
|
php
|
public static function generateMessageId( $hostname )
{
if ( strpos( $hostname, '@' ) !== false )
{
$hostname = strstr( $hostname, '@' );
}
else
{
$hostname = '@' . $hostname;
}
return date( 'YmdGHjs' ) . '.' . getmypid() . '.' . self::$idCounter++ . $hostname;
}
|
[
"public",
"static",
"function",
"generateMessageId",
"(",
"$",
"hostname",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"hostname",
",",
"'@'",
")",
"!==",
"false",
")",
"{",
"$",
"hostname",
"=",
"strstr",
"(",
"$",
"hostname",
",",
"'@'",
")",
";",
"}",
"else",
"{",
"$",
"hostname",
"=",
"'@'",
".",
"$",
"hostname",
";",
"}",
"return",
"date",
"(",
"'YmdGHjs'",
")",
".",
"'.'",
".",
"getmypid",
"(",
")",
".",
"'.'",
".",
"self",
"::",
"$",
"idCounter",
"++",
".",
"$",
"hostname",
";",
"}"
] |
Returns an unique message ID to be used for a mail message.
The hostname $hostname will be added to the unique ID as required by RFC822.
If an e-mail address is provided instead, the hostname is extracted and used.
The formula to generate the message ID is: [time_and_date].[process_id].[counter]
@param string $hostname
@return string
|
[
"Returns",
"an",
"unique",
"message",
"ID",
"to",
"be",
"used",
"for",
"a",
"mail",
"message",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L502-L513
|
21,186 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php
|
ezcMailTools.mimeDecode
|
public static function mimeDecode( $text, $charset = 'utf-8' )
{
$origtext = $text;
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// something went wrong while decoding, let's see if we can fix it
// Try to fix lower case hex digits
$text = preg_replace_callback(
'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
create_function( '$matches', 'return strtoupper($matches[0]);' ),
$origtext
);
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
// are not understood (but only "B" and "Q")
$text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Try it as latin 1 string
$text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
$text = iconv_mime_decode( $text, 0, $charset );
return $text;
}
|
php
|
public static function mimeDecode( $text, $charset = 'utf-8' )
{
$origtext = $text;
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// something went wrong while decoding, let's see if we can fix it
// Try to fix lower case hex digits
$text = preg_replace_callback(
'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
create_function( '$matches', 'return strtoupper($matches[0]);' ),
$origtext
);
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
// are not understood (but only "B" and "Q")
$text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Try it as latin 1 string
$text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
$text = iconv_mime_decode( $text, 0, $charset );
return $text;
}
|
[
"public",
"static",
"function",
"mimeDecode",
"(",
"$",
"text",
",",
"$",
"charset",
"=",
"'utf-8'",
")",
"{",
"$",
"origtext",
"=",
"$",
"text",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// something went wrong while decoding, let's see if we can fix it",
"// Try to fix lower case hex digits",
"$",
"text",
"=",
"preg_replace_callback",
"(",
"'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/'",
",",
"create_function",
"(",
"'$matches'",
",",
"'return strtoupper($matches[0]);'",
")",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// Workaround a bug in PHP 5.1.0-5.1.3 where the \"b\" and \"q\" methods",
"// are not understood (but only \"B\" and \"Q\")",
"$",
"text",
"=",
"str_replace",
"(",
"array",
"(",
"'?b?'",
",",
"'?q?'",
")",
",",
"array",
"(",
"'?B?'",
",",
"'?Q?'",
")",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// Try it as latin 1 string",
"$",
"text",
"=",
"preg_replace",
"(",
"'/=\\?([^?]+)\\?/'",
",",
"'=?iso-8859-1?'",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Decodes mime encoded fields and tries to recover from errors.
Decodes the $text encoded as a MIME string to the $charset. In case the
strict conversion fails this method tries to workaround the issues by
trying to "fix" the original $text before trying to convert it.
@param string $text
@param string $charset
@return string
|
[
"Decodes",
"mime",
"encoded",
"fields",
"and",
"tries",
"to",
"recover",
"from",
"errors",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L568-L604
|
21,187 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php
|
ezcMailTools.replyToMail
|
static public function replyToMail( ezcMail $mail, ezcMailAddress $from,
$type = self::REPLY_SENDER, $subjectPrefix = "Re: ",
$mailClass = "ezcMail" )
{
$reply = new $mailClass();
$reply->from = $from;
// To = Reply-To if set
if ( $mail->getHeader( 'Reply-To' ) != '' )
{
$reply->to = ezcMailTools::parseEmailAddresses( $mail->getHeader( 'Reply-To' ) );
}
else // Else To = From
{
$reply->to = array( $mail->from );
}
if ( $type == self::REPLY_ALL )
{
// Cc = Cc + To - your own address
$cc = array();
foreach ( $mail->to as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
foreach ( $mail->cc as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
$reply->cc = $cc;
}
$reply->subject = $subjectPrefix . $mail->subject;
if ( $mail->getHeader( 'Message-Id' ) )
{
// In-Reply-To = Message-Id
$reply->setHeader( 'In-Reply-To', $mail->getHeader( 'Message-ID' ) );
// References = References . Message-Id
if ( $mail->getHeader( 'References' ) != '' )
{
$reply->setHeader( 'References', $mail->getHeader( 'References' )
. ' ' . $mail->getHeader( 'Message-ID' ) );
}
else
{
$reply->setHeader( 'References', $mail->getHeader( 'Message-ID' ) );
}
}
else // original mail is borked. Let's support it anyway.
{
$reply->setHeader( 'References', $mail->getHeader( 'References' ) );
}
return $reply;
}
|
php
|
static public function replyToMail( ezcMail $mail, ezcMailAddress $from,
$type = self::REPLY_SENDER, $subjectPrefix = "Re: ",
$mailClass = "ezcMail" )
{
$reply = new $mailClass();
$reply->from = $from;
// To = Reply-To if set
if ( $mail->getHeader( 'Reply-To' ) != '' )
{
$reply->to = ezcMailTools::parseEmailAddresses( $mail->getHeader( 'Reply-To' ) );
}
else // Else To = From
{
$reply->to = array( $mail->from );
}
if ( $type == self::REPLY_ALL )
{
// Cc = Cc + To - your own address
$cc = array();
foreach ( $mail->to as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
foreach ( $mail->cc as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
$reply->cc = $cc;
}
$reply->subject = $subjectPrefix . $mail->subject;
if ( $mail->getHeader( 'Message-Id' ) )
{
// In-Reply-To = Message-Id
$reply->setHeader( 'In-Reply-To', $mail->getHeader( 'Message-ID' ) );
// References = References . Message-Id
if ( $mail->getHeader( 'References' ) != '' )
{
$reply->setHeader( 'References', $mail->getHeader( 'References' )
. ' ' . $mail->getHeader( 'Message-ID' ) );
}
else
{
$reply->setHeader( 'References', $mail->getHeader( 'Message-ID' ) );
}
}
else // original mail is borked. Let's support it anyway.
{
$reply->setHeader( 'References', $mail->getHeader( 'References' ) );
}
return $reply;
}
|
[
"static",
"public",
"function",
"replyToMail",
"(",
"ezcMail",
"$",
"mail",
",",
"ezcMailAddress",
"$",
"from",
",",
"$",
"type",
"=",
"self",
"::",
"REPLY_SENDER",
",",
"$",
"subjectPrefix",
"=",
"\"Re: \"",
",",
"$",
"mailClass",
"=",
"\"ezcMail\"",
")",
"{",
"$",
"reply",
"=",
"new",
"$",
"mailClass",
"(",
")",
";",
"$",
"reply",
"->",
"from",
"=",
"$",
"from",
";",
"// To = Reply-To if set",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Reply-To'",
")",
"!=",
"''",
")",
"{",
"$",
"reply",
"->",
"to",
"=",
"ezcMailTools",
"::",
"parseEmailAddresses",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Reply-To'",
")",
")",
";",
"}",
"else",
"// Else To = From",
"{",
"$",
"reply",
"->",
"to",
"=",
"array",
"(",
"$",
"mail",
"->",
"from",
")",
";",
"}",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"REPLY_ALL",
")",
"{",
"// Cc = Cc + To - your own address",
"$",
"cc",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mail",
"->",
"to",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"->",
"email",
"!=",
"$",
"from",
"->",
"email",
")",
"{",
"$",
"cc",
"[",
"]",
"=",
"$",
"address",
";",
"}",
"}",
"foreach",
"(",
"$",
"mail",
"->",
"cc",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"->",
"email",
"!=",
"$",
"from",
"->",
"email",
")",
"{",
"$",
"cc",
"[",
"]",
"=",
"$",
"address",
";",
"}",
"}",
"$",
"reply",
"->",
"cc",
"=",
"$",
"cc",
";",
"}",
"$",
"reply",
"->",
"subject",
"=",
"$",
"subjectPrefix",
".",
"$",
"mail",
"->",
"subject",
";",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-Id'",
")",
")",
"{",
"// In-Reply-To = Message-Id",
"$",
"reply",
"->",
"setHeader",
"(",
"'In-Reply-To'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"// References = References . Message-Id",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
"!=",
"''",
")",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
".",
"' '",
".",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"}",
"else",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"}",
"}",
"else",
"// original mail is borked. Let's support it anyway.",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
")",
";",
"}",
"return",
"$",
"reply",
";",
"}"
] |
Returns a new mail object that is a reply to the current object.
The new mail will have the correct to, cc, bcc and reference headers set.
It will not have any body set.
By default the reply will only be sent to the sender of the original mail.
If $type is set to REPLY_ALL, all the original recipients will be included
in the reply.
Use $subjectPrefix to set the prefix to the subject of the mail. The default
is to prefix with 'Re: '.
@param ezcMail $mail
@param ezcMailAddress $from
@param int $type REPLY_SENDER or REPLY_ALL
@param string $subjectPrefix
@param string $mailClass
@return ezcMail
|
[
"Returns",
"a",
"new",
"mail",
"object",
"that",
"is",
"a",
"reply",
"to",
"the",
"current",
"object",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L626-L689
|
21,188 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php
|
ezcMailTools.guessContentType
|
static public function guessContentType( $fileName, &$contentType, &$mimeType )
{
$extension = strtolower( pathinfo( $fileName, PATHINFO_EXTENSION ) );
switch ( $extension )
{
case 'gif':
$contentType = 'image';
$mimeType = 'gif';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
$contentType = 'image';
$mimeType = 'jpeg';
break;
case 'png':
$contentType = 'image';
$mimeType = 'png';
break;
case 'bmp':
$contentType = 'image';
$mimeType = 'bmp';
break;
case 'tif':
case 'tiff':
$contentType = 'image';
$mimeType = 'tiff';
break;
default:
return false;
}
return true;
}
|
php
|
static public function guessContentType( $fileName, &$contentType, &$mimeType )
{
$extension = strtolower( pathinfo( $fileName, PATHINFO_EXTENSION ) );
switch ( $extension )
{
case 'gif':
$contentType = 'image';
$mimeType = 'gif';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
$contentType = 'image';
$mimeType = 'jpeg';
break;
case 'png':
$contentType = 'image';
$mimeType = 'png';
break;
case 'bmp':
$contentType = 'image';
$mimeType = 'bmp';
break;
case 'tif':
case 'tiff':
$contentType = 'image';
$mimeType = 'tiff';
break;
default:
return false;
}
return true;
}
|
[
"static",
"public",
"function",
"guessContentType",
"(",
"$",
"fileName",
",",
"&",
"$",
"contentType",
",",
"&",
"$",
"mimeType",
")",
"{",
"$",
"extension",
"=",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"fileName",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"switch",
"(",
"$",
"extension",
")",
"{",
"case",
"'gif'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'gif'",
";",
"break",
";",
"case",
"'jpg'",
":",
"case",
"'jpe'",
":",
"case",
"'jpeg'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'jpeg'",
";",
"break",
";",
"case",
"'png'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'png'",
";",
"break",
";",
"case",
"'bmp'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'bmp'",
";",
"break",
";",
"case",
"'tif'",
":",
"case",
"'tiff'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'tiff'",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Guesses the content and mime type by using the file extension.
The content and mime types are returned through the $contentType
and $mimeType arguments.
For the moment only for image files.
@param string $fileName
@param string $contentType
@param string $mimeType
|
[
"Guesses",
"the",
"content",
"and",
"mime",
"type",
"by",
"using",
"the",
"file",
"extension",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L702-L739
|
21,189 |
robrogers3/laraldap-auth
|
src/LdapUserProvider.php
|
LdapUserProvider.authenticate
|
public function authenticate(Authenticatable $user, array $credentials)
{
$handler = ldap_connect($this->host);
if (! $handler) {
throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
}
try {
ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
} catch (\ErrorException $e) {
;
}
$username = strtok($user->email, '@');
$rdn = $this->makeRdn($username);
try {
$bind = ldap_bind($handler, $rdn, $credentials['password']);
} catch (\ErrorException $e) {
$bind = false;
}
if ($handler) {
ldap_close($handler);
unset($handler);
}
if ($bind) {
$user->save();
}
return $bind;
}
|
php
|
public function authenticate(Authenticatable $user, array $credentials)
{
$handler = ldap_connect($this->host);
if (! $handler) {
throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
}
try {
ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
} catch (\ErrorException $e) {
;
}
$username = strtok($user->email, '@');
$rdn = $this->makeRdn($username);
try {
$bind = ldap_bind($handler, $rdn, $credentials['password']);
} catch (\ErrorException $e) {
$bind = false;
}
if ($handler) {
ldap_close($handler);
unset($handler);
}
if ($bind) {
$user->save();
}
return $bind;
}
|
[
"public",
"function",
"authenticate",
"(",
"Authenticatable",
"$",
"user",
",",
"array",
"$",
"credentials",
")",
"{",
"$",
"handler",
"=",
"ldap_connect",
"(",
"$",
"this",
"->",
"host",
")",
";",
"if",
"(",
"!",
"$",
"handler",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Connection fail! Check your server address: '{$this->host}'.\"",
")",
";",
"}",
"try",
"{",
"ldap_set_option",
"(",
"$",
"handler",
",",
"LDAP_OPT_PROTOCOL_VERSION",
",",
"3",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
";",
"}",
"$",
"username",
"=",
"strtok",
"(",
"$",
"user",
"->",
"email",
",",
"'@'",
")",
";",
"$",
"rdn",
"=",
"$",
"this",
"->",
"makeRdn",
"(",
"$",
"username",
")",
";",
"try",
"{",
"$",
"bind",
"=",
"ldap_bind",
"(",
"$",
"handler",
",",
"$",
"rdn",
",",
"$",
"credentials",
"[",
"'password'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
"$",
"bind",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"handler",
")",
"{",
"ldap_close",
"(",
"$",
"handler",
")",
";",
"unset",
"(",
"$",
"handler",
")",
";",
"}",
"if",
"(",
"$",
"bind",
")",
"{",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"bind",
";",
"}"
] |
Check user's credentials against LDAP server.
@param Authenticatable $user
@param array $credentials
@return bool
|
[
"Check",
"user",
"s",
"credentials",
"against",
"LDAP",
"server",
"."
] |
f1b8d001f8b230389c7fbc5fdd59e39663d8ad36
|
https://github.com/robrogers3/laraldap-auth/blob/f1b8d001f8b230389c7fbc5fdd59e39663d8ad36/src/LdapUserProvider.php#L183-L219
|
21,190 |
willhoffmann/domuserp-php
|
src/Resources/Companies/Companies.php
|
Companies.getList
|
public function getList(array $query = [])
{
$list = $this->execute(self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/empresas');
return $list;
}
|
php
|
public function getList(array $query = [])
{
$list = $this->execute(self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/empresas');
return $list;
}
|
[
"public",
"function",
"getList",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"execute",
"(",
"self",
"::",
"HTTP_GET",
",",
"self",
"::",
"DOMUSERP_API_PEDIDOVENDA",
".",
"'/empresas'",
")",
";",
"return",
"$",
"list",
";",
"}"
] |
List of companies
@param array $query
@return array|string
@throws \GuzzleHttp\Exception\GuzzleException
|
[
"List",
"of",
"companies"
] |
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
|
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Companies/Companies.php#L18-L23
|
21,191 |
wilgucki/php-csv
|
src/Writer.php
|
Writer.flush
|
public function flush()
{
rewind($this->handle);
$out = stream_get_contents($this->handle);
fseek($this->handle, 0, SEEK_END);
return $out;
}
|
php
|
public function flush()
{
rewind($this->handle);
$out = stream_get_contents($this->handle);
fseek($this->handle, 0, SEEK_END);
return $out;
}
|
[
"public",
"function",
"flush",
"(",
")",
"{",
"rewind",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"out",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"fseek",
"(",
"$",
"this",
"->",
"handle",
",",
"0",
",",
"SEEK_END",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
Output all written data as string.
@return string
|
[
"Output",
"all",
"written",
"data",
"as",
"string",
"."
] |
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
|
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Writer.php#L60-L66
|
21,192 |
wilgucki/php-csv
|
src/Writer.php
|
Writer.write
|
private function write(array $row)
{
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($row as $k => $v) {
$row[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return fputcsv($this->handle, $row, $this->delimiter, $this->enclosure, $this->escape);
}
|
php
|
private function write(array $row)
{
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($row as $k => $v) {
$row[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return fputcsv($this->handle, $row, $this->delimiter, $this->enclosure, $this->escape);
}
|
[
"private",
"function",
"write",
"(",
"array",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"encodingFrom",
"!==",
"null",
"&&",
"$",
"this",
"->",
"encodingTo",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"row",
"[",
"$",
"k",
"]",
"=",
"iconv",
"(",
"$",
"this",
"->",
"encodingFrom",
",",
"$",
"this",
"->",
"encodingTo",
",",
"$",
"v",
")",
";",
"}",
"}",
"return",
"fputcsv",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"row",
",",
"$",
"this",
"->",
"delimiter",
",",
"$",
"this",
"->",
"enclosure",
",",
"$",
"this",
"->",
"escape",
")",
";",
"}"
] |
Wrapper for fputcsv function
@param array $row
@return bool|int
|
[
"Wrapper",
"for",
"fputcsv",
"function"
] |
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
|
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Writer.php#L74-L83
|
21,193 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/utilities.php
|
ezcDbUtilities.createTemporaryTable
|
public function createTemporaryTable( $tableName, $tableDefinition )
{
$tableName = str_replace( '%', '', $tableName );
$tableName = $this->getPrefixedTableNames($tableName);
$this->db->exec( "CREATE TEMPORARY TABLE $tableName ($tableDefinition)" );
return $tableName;
}
|
php
|
public function createTemporaryTable( $tableName, $tableDefinition )
{
$tableName = str_replace( '%', '', $tableName );
$tableName = $this->getPrefixedTableNames($tableName);
$this->db->exec( "CREATE TEMPORARY TABLE $tableName ($tableDefinition)" );
return $tableName;
}
|
[
"public",
"function",
"createTemporaryTable",
"(",
"$",
"tableName",
",",
"$",
"tableDefinition",
")",
"{",
"$",
"tableName",
"=",
"str_replace",
"(",
"'%'",
",",
"''",
",",
"$",
"tableName",
")",
";",
"$",
"tableName",
"=",
"$",
"this",
"->",
"getPrefixedTableNames",
"(",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"db",
"->",
"exec",
"(",
"\"CREATE TEMPORARY TABLE $tableName ($tableDefinition)\"",
")",
";",
"return",
"$",
"tableName",
";",
"}"
] |
Create temporary table.
Developers should use this method rather than creating temporary
tables by hand, executing the appropriate SQL queries.
If the specified table name contains percent character (%)
then it might be substituted with a unique number by some handlers.
For example, Oracle handler does this to guarantee uniqueness of
temporary tables names.
Handlers that do not need this just remove percent characters
from the table name.
Example of usage:
<code>
$actualTableName = $db->createTemporaryTable(
'my_tmp_%', 'field1 char(255), field2 int' );
$db->dropTemporaryTable( $actualTableName );
</code>
@see dropTemporaryTable()
@param string $tableName Name of temporary table user wants
to create.
@param string $tableDefinition Definition for the table, i.e.
everything that goes between braces after
CREATE TEMPORARY TABLE clause.
@return string Table name, that might have been changed
by the handler to guarantee its uniqueness.
|
[
"Create",
"temporary",
"table",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/utilities.php#L69-L75
|
21,194 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php
|
Dwoo_Adapters_ZendFramework_PluginProxy.handles
|
public function handles($name) {
try {
$this->view->getHelper($name);
} catch (Zend_Loader_PluginLoader_Exception $e) {
return false;
}
return true;
}
|
php
|
public function handles($name) {
try {
$this->view->getHelper($name);
} catch (Zend_Loader_PluginLoader_Exception $e) {
return false;
}
return true;
}
|
[
"public",
"function",
"handles",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"view",
"->",
"getHelper",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"Zend_Loader_PluginLoader_Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Called from Dwoo_Compiler to check if the requested plugin is available
@param string $name
@return bool
|
[
"Called",
"from",
"Dwoo_Compiler",
"to",
"check",
"if",
"the",
"requested",
"plugin",
"is",
"available"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php#L43-L51
|
21,195 |
antaresproject/notifications
|
src/Decorator/SidebarItemDecorator.php
|
SidebarItemDecorator.decorate
|
public function decorate(Collection $items, $type = 'notification')
{
$view = config('antares/notifications::templates.' . $type);
if (is_null($view)) {
throw new RuntimeException('Unable to resolve notification partial view.');
}
$return = [];
foreach ($items as $item) {
$return[] = $this->item($item, $view);
}
return $return;
}
|
php
|
public function decorate(Collection $items, $type = 'notification')
{
$view = config('antares/notifications::templates.' . $type);
if (is_null($view)) {
throw new RuntimeException('Unable to resolve notification partial view.');
}
$return = [];
foreach ($items as $item) {
$return[] = $this->item($item, $view);
}
return $return;
}
|
[
"public",
"function",
"decorate",
"(",
"Collection",
"$",
"items",
",",
"$",
"type",
"=",
"'notification'",
")",
"{",
"$",
"view",
"=",
"config",
"(",
"'antares/notifications::templates.'",
".",
"$",
"type",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"view",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to resolve notification partial view.'",
")",
";",
"}",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"this",
"->",
"item",
"(",
"$",
"item",
",",
"$",
"view",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Decorates notifications of alerts
@param Collection $items
@param String $type
@return array
@throws RuntimeException
|
[
"Decorates",
"notifications",
"of",
"alerts"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Decorator/SidebarItemDecorator.php#L39-L50
|
21,196 |
antaresproject/notifications
|
src/Decorator/SidebarItemDecorator.php
|
SidebarItemDecorator.item
|
public function item(Model $item, $view)
{
$content = $this->getVariablesAdapter()->get($item->content[0]->content, (array) $item->variables);
return view($view, [
'id' => $item->id,
'author' => $item->author,
'title' => $item->content[0]->title,
'value' => $content,
'priority' => priority_label($item->notification->severity->name),
'created_at' => $item->created_at
])->render();
}
|
php
|
public function item(Model $item, $view)
{
$content = $this->getVariablesAdapter()->get($item->content[0]->content, (array) $item->variables);
return view($view, [
'id' => $item->id,
'author' => $item->author,
'title' => $item->content[0]->title,
'value' => $content,
'priority' => priority_label($item->notification->severity->name),
'created_at' => $item->created_at
])->render();
}
|
[
"public",
"function",
"item",
"(",
"Model",
"$",
"item",
",",
"$",
"view",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getVariablesAdapter",
"(",
")",
"->",
"get",
"(",
"$",
"item",
"->",
"content",
"[",
"0",
"]",
"->",
"content",
",",
"(",
"array",
")",
"$",
"item",
"->",
"variables",
")",
";",
"return",
"view",
"(",
"$",
"view",
",",
"[",
"'id'",
"=>",
"$",
"item",
"->",
"id",
",",
"'author'",
"=>",
"$",
"item",
"->",
"author",
",",
"'title'",
"=>",
"$",
"item",
"->",
"content",
"[",
"0",
"]",
"->",
"title",
",",
"'value'",
"=>",
"$",
"content",
",",
"'priority'",
"=>",
"priority_label",
"(",
"$",
"item",
"->",
"notification",
"->",
"severity",
"->",
"name",
")",
",",
"'created_at'",
"=>",
"$",
"item",
"->",
"created_at",
"]",
")",
"->",
"render",
"(",
")",
";",
"}"
] |
Decorates single item
@param Model $item
@param String $view
@return String
|
[
"Decorates",
"single",
"item"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Decorator/SidebarItemDecorator.php#L59-L71
|
21,197 |
WellCommerce/AppBundle
|
Controller/Front/CurrencyController.php
|
CurrencyController.switchAction
|
public function switchAction(Request $request, string $currency) : RedirectResponse
{
$result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
if (null !== $result) {
$request->getSession()->set('_currency', $currency);
}
return new RedirectResponse($request->headers->get('referer'));
}
|
php
|
public function switchAction(Request $request, string $currency) : RedirectResponse
{
$result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
if (null !== $result) {
$request->getSession()->set('_currency', $currency);
}
return new RedirectResponse($request->headers->get('referer'));
}
|
[
"public",
"function",
"switchAction",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"currency",
")",
":",
"RedirectResponse",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"'currency.repository'",
")",
"->",
"findOneBy",
"(",
"[",
"'code'",
"=>",
"$",
"currency",
"]",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"result",
")",
"{",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'_currency'",
",",
"$",
"currency",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'referer'",
")",
")",
";",
"}"
] |
Sets new session currency
@param Request $request
@param string $currency
@return RedirectResponse
|
[
"Sets",
"new",
"session",
"currency"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Controller/Front/CurrencyController.php#L34-L42
|
21,198 |
nabab/bbn
|
src/bbn/api/cloudmin.php
|
cloudmin.sanitize
|
private function sanitize($st){
$st = trim((string)$st);
if ( strpos($st, ';') !== false ){
return '';
}
if ( strpos($st, '<') !== false ){
return '';
}
if ( strpos($st, '"') !== false ){
return '';
}
if ( strpos($st, "'") !== false ){
return '';
}
return $st;
}
|
php
|
private function sanitize($st){
$st = trim((string)$st);
if ( strpos($st, ';') !== false ){
return '';
}
if ( strpos($st, '<') !== false ){
return '';
}
if ( strpos($st, '"') !== false ){
return '';
}
if ( strpos($st, "'") !== false ){
return '';
}
return $st;
}
|
[
"private",
"function",
"sanitize",
"(",
"$",
"st",
")",
"{",
"$",
"st",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"st",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"';'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"'<'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"'\"'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"\"'\"",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"st",
";",
"}"
] |
This function is used to sanitize the strings which are given as parameters
@param string $st
@return string The the header url part to be executed
|
[
"This",
"function",
"is",
"used",
"to",
"sanitize",
"the",
"strings",
"which",
"are",
"given",
"as",
"parameters"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L222-L237
|
21,199 |
nabab/bbn
|
src/bbn/api/cloudmin.php
|
cloudmin.process_parameters
|
private function process_parameters($param){
foreach ($param as $key => $val){
//$val is an array
if (\is_array($val)){
$param[$key] = $this->process_parameters($val);
}
else {
$param[$key] = $this->sanitize($val);
}
}
//Return the processed parameters
return $param;
}
|
php
|
private function process_parameters($param){
foreach ($param as $key => $val){
//$val is an array
if (\is_array($val)){
$param[$key] = $this->process_parameters($val);
}
else {
$param[$key] = $this->sanitize($val);
}
}
//Return the processed parameters
return $param;
}
|
[
"private",
"function",
"process_parameters",
"(",
"$",
"param",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"//$val is an array",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"param",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"process_parameters",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"param",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"val",
")",
";",
"}",
"}",
"//Return the processed parameters",
"return",
"$",
"param",
";",
"}"
] |
Sanitize each parameter
@param array $param the raw parameters
@return array the processed parameters
|
[
"Sanitize",
"each",
"parameter"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L291-L303
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.