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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
227,700
|
authlete/authlete-php
|
src/Util/ValidationUtility.php
|
ValidationUtility.ensureNullOrArrayOfType
|
public static function ensureNullOrArrayOfType($name, array &$array = null, $type)
{
if (is_null($array))
{
return;
}
foreach ($array as $element)
{
if (!($element instanceof $type))
{
throw new \InvalidArgumentException("'$name' must be null or an array of $type.");
}
}
}
|
php
|
public static function ensureNullOrArrayOfType($name, array &$array = null, $type)
{
if (is_null($array))
{
return;
}
foreach ($array as $element)
{
if (!($element instanceof $type))
{
throw new \InvalidArgumentException("'$name' must be null or an array of $type.");
}
}
}
|
[
"public",
"static",
"function",
"ensureNullOrArrayOfType",
"(",
"$",
"name",
",",
"array",
"&",
"$",
"array",
"=",
"null",
",",
"$",
"type",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"array",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"array",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"element",
"instanceof",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"'$name' must be null or an array of $type.\"",
")",
";",
"}",
"}",
"}"
] |
Ensure that the given object is null or an array whose elements
are of the specified type.
@param string $name
Name of a parameter.
@param array $array
Value of a parameter.
@param string $type
The expected type of the elements in the given array.
@throws \InvalidArgumentException
`$array` is neither `null` nor a reference of an array.
Or the array has one or more elements whose type is not
the specified type.
|
[
"Ensure",
"that",
"the",
"given",
"object",
"is",
"null",
"or",
"an",
"array",
"whose",
"elements",
"are",
"of",
"the",
"specified",
"type",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/ValidationUtility.php#L296-L310
|
227,701
|
authlete/authlete-php
|
src/Util/MaxAgeValidator.php
|
MaxAgeValidator.validate
|
public function validate()
{
$maxAge = $this->maxAge;
$authTime = $this->authTime;
$currentTime = $this->currentTime;
// If no maximum authentication age is requested.
if (empty($maxAge))
{
// No need to care about the maximum authentication age.
return true;
}
if (PHP_INT_SIZE <= 4 ||
is_integer($maxAge) === false || is_integer($authTime) === false)
{
// The variables may be strings.
return $this->validateAsStrings($maxAge, $authTime, $currentTime);
}
else
{
return $this->validateAsIntegers($maxAge, $authTime, $currentTime);
}
}
|
php
|
public function validate()
{
$maxAge = $this->maxAge;
$authTime = $this->authTime;
$currentTime = $this->currentTime;
// If no maximum authentication age is requested.
if (empty($maxAge))
{
// No need to care about the maximum authentication age.
return true;
}
if (PHP_INT_SIZE <= 4 ||
is_integer($maxAge) === false || is_integer($authTime) === false)
{
// The variables may be strings.
return $this->validateAsStrings($maxAge, $authTime, $currentTime);
}
else
{
return $this->validateAsIntegers($maxAge, $authTime, $currentTime);
}
}
|
[
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"maxAge",
"=",
"$",
"this",
"->",
"maxAge",
";",
"$",
"authTime",
"=",
"$",
"this",
"->",
"authTime",
";",
"$",
"currentTime",
"=",
"$",
"this",
"->",
"currentTime",
";",
"// If no maximum authentication age is requested.",
"if",
"(",
"empty",
"(",
"$",
"maxAge",
")",
")",
"{",
"// No need to care about the maximum authentication age.",
"return",
"true",
";",
"}",
"if",
"(",
"PHP_INT_SIZE",
"<=",
"4",
"||",
"is_integer",
"(",
"$",
"maxAge",
")",
"===",
"false",
"||",
"is_integer",
"(",
"$",
"authTime",
")",
"===",
"false",
")",
"{",
"// The variables may be strings.",
"return",
"$",
"this",
"->",
"validateAsStrings",
"(",
"$",
"maxAge",
",",
"$",
"authTime",
",",
"$",
"currentTime",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"validateAsIntegers",
"(",
"$",
"maxAge",
",",
"$",
"authTime",
",",
"$",
"currentTime",
")",
";",
"}",
"}"
] |
Validate that the maximum authentication age has not passed
since the last user authentication time.
@return boolean
`true` when the maximum authentication age has not passed since the
last user authentication time. If `false` is returned, it means
re-authentication is necessary.
|
[
"Validate",
"that",
"the",
"maximum",
"authentication",
"age",
"has",
"not",
"passed",
"since",
"the",
"last",
"user",
"authentication",
"time",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/MaxAgeValidator.php#L111-L134
|
227,702
|
alhoqbani/ar-php
|
src/ArUtil/I18N/WordTag.php
|
WordTag.tagText
|
public static function tagText($str)
{
$text = array();
$words = explode(' ', $str);
$prevWord = '';
foreach ($words as $word) {
if ($word == '') {
continue;
}
if (self::isNoun($word, $prevWord)) {
$text[] = array($word, 1);
} else {
$text[] = array($word, 0);
}
$prevWord = $word;
}
return $text;
}
|
php
|
public static function tagText($str)
{
$text = array();
$words = explode(' ', $str);
$prevWord = '';
foreach ($words as $word) {
if ($word == '') {
continue;
}
if (self::isNoun($word, $prevWord)) {
$text[] = array($word, 1);
} else {
$text[] = array($word, 0);
}
$prevWord = $word;
}
return $text;
}
|
[
"public",
"static",
"function",
"tagText",
"(",
"$",
"str",
")",
"{",
"$",
"text",
"=",
"array",
"(",
")",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"str",
")",
";",
"$",
"prevWord",
"=",
"''",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"$",
"word",
"==",
"''",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"self",
"::",
"isNoun",
"(",
"$",
"word",
",",
"$",
"prevWord",
")",
")",
"{",
"$",
"text",
"[",
"]",
"=",
"array",
"(",
"$",
"word",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"text",
"[",
"]",
"=",
"array",
"(",
"$",
"word",
",",
"0",
")",
";",
"}",
"$",
"prevWord",
"=",
"$",
"word",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Tag all words in a given Arabic string if they are nouns or not
@param string $str Arabic string you want to tag all its words
@return array Two dimension array where item[i][0] represent the word i
in the given string, and item[i][1] is 1 if that word is
noun and 0 if it is not
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Tag",
"all",
"words",
"in",
"a",
"given",
"Arabic",
"string",
"if",
"they",
"are",
"nouns",
"or",
"not"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/WordTag.php#L292-L313
|
227,703
|
alhoqbani/ar-php
|
src/ArUtil/I18N/WordTag.php
|
WordTag.highlightText
|
public static function highlightText($str, $style = null)
{
$html = '';
$prevTag = 0;
$prevWord = '';
$taggedText = self::tagText($str);
foreach ($taggedText as $wordTag) {
list($word, $tag) = $wordTag;
if ($prevTag == 1) {
if (in_array($word, self::$_particlePreNouns)) {
$prevWord = $word;
continue;
}
if ($tag == 0) {
$html .= "</span> \r\n";
}
} else {
// if ($tag == 1 && !in_array($word, $this->_commonWords)) {
if ($tag == 1) {
$html .= " \r\n<span class=\"" . $style ."\">";
}
}
$html .= ' ' . $prevWord . ' ' . $word;
if ($prevWord != '') {
$prevWord = '';
}
$prevTag = $tag;
}
if ($prevTag == 1) {
$html .= "</span> \r\n";
}
return $html;
}
|
php
|
public static function highlightText($str, $style = null)
{
$html = '';
$prevTag = 0;
$prevWord = '';
$taggedText = self::tagText($str);
foreach ($taggedText as $wordTag) {
list($word, $tag) = $wordTag;
if ($prevTag == 1) {
if (in_array($word, self::$_particlePreNouns)) {
$prevWord = $word;
continue;
}
if ($tag == 0) {
$html .= "</span> \r\n";
}
} else {
// if ($tag == 1 && !in_array($word, $this->_commonWords)) {
if ($tag == 1) {
$html .= " \r\n<span class=\"" . $style ."\">";
}
}
$html .= ' ' . $prevWord . ' ' . $word;
if ($prevWord != '') {
$prevWord = '';
}
$prevTag = $tag;
}
if ($prevTag == 1) {
$html .= "</span> \r\n";
}
return $html;
}
|
[
"public",
"static",
"function",
"highlightText",
"(",
"$",
"str",
",",
"$",
"style",
"=",
"null",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"prevTag",
"=",
"0",
";",
"$",
"prevWord",
"=",
"''",
";",
"$",
"taggedText",
"=",
"self",
"::",
"tagText",
"(",
"$",
"str",
")",
";",
"foreach",
"(",
"$",
"taggedText",
"as",
"$",
"wordTag",
")",
"{",
"list",
"(",
"$",
"word",
",",
"$",
"tag",
")",
"=",
"$",
"wordTag",
";",
"if",
"(",
"$",
"prevTag",
"==",
"1",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"word",
",",
"self",
"::",
"$",
"_particlePreNouns",
")",
")",
"{",
"$",
"prevWord",
"=",
"$",
"word",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"tag",
"==",
"0",
")",
"{",
"$",
"html",
".=",
"\"</span> \\r\\n\"",
";",
"}",
"}",
"else",
"{",
"// if ($tag == 1 && !in_array($word, $this->_commonWords)) {",
"if",
"(",
"$",
"tag",
"==",
"1",
")",
"{",
"$",
"html",
".=",
"\" \\r\\n<span class=\\\"\"",
".",
"$",
"style",
".",
"\"\\\">\"",
";",
"}",
"}",
"$",
"html",
".=",
"' '",
".",
"$",
"prevWord",
".",
"' '",
".",
"$",
"word",
";",
"if",
"(",
"$",
"prevWord",
"!=",
"''",
")",
"{",
"$",
"prevWord",
"=",
"''",
";",
"}",
"$",
"prevTag",
"=",
"$",
"tag",
";",
"}",
"if",
"(",
"$",
"prevTag",
"==",
"1",
")",
"{",
"$",
"html",
".=",
"\"</span> \\r\\n\"",
";",
"}",
"return",
"$",
"html",
";",
"}"
] |
Highlighted all nouns in a given Arabic string
@param string $str Arabic string you want to highlighted
all its nouns
@param string $style Name of the CSS class you would like to apply
@return string Arabic string in HTML format where all nouns highlighted
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Highlighted",
"all",
"nouns",
"in",
"a",
"given",
"Arabic",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/WordTag.php#L325-L365
|
227,704
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Query.php
|
Query.getOrderBy
|
public function getOrderBy($arg)
{
// Check if there are phrases in $arg should handle as it is
$phrase = explode("\"", $arg);
if (count($phrase) > 2) {
// Re-init $arg variable
// (It will contain the rest of $arg except phrases).
$arg = '';
for ($i = 0; $i < count($phrase); $i++) {
if ($i % 2 == 0 && $phrase[$i] != '') {
// Re-build $arg variable after restricting phrases
$arg .= $phrase[$i];
} elseif ($i % 2 == 1 && $phrase[$i] != '') {
// Handle phrases using reqular LIKE matching in MySQL
$wordOrder[] = $this->getWordLike($phrase[$i]);
}
}
}
// Handle normal $arg using lex's and regular expresion
$words = explode(' ', $arg);
foreach ($words as $word) {
if ($word != '') {
$wordOrder[] = 'CASE WHEN ' .
$this->getWordRegExp($word) .
' THEN 1 ELSE 0 END';
}
}
$order = '((' . implode(') + (', $wordOrder) . ')) DESC';
return $order;
}
|
php
|
public function getOrderBy($arg)
{
// Check if there are phrases in $arg should handle as it is
$phrase = explode("\"", $arg);
if (count($phrase) > 2) {
// Re-init $arg variable
// (It will contain the rest of $arg except phrases).
$arg = '';
for ($i = 0; $i < count($phrase); $i++) {
if ($i % 2 == 0 && $phrase[$i] != '') {
// Re-build $arg variable after restricting phrases
$arg .= $phrase[$i];
} elseif ($i % 2 == 1 && $phrase[$i] != '') {
// Handle phrases using reqular LIKE matching in MySQL
$wordOrder[] = $this->getWordLike($phrase[$i]);
}
}
}
// Handle normal $arg using lex's and regular expresion
$words = explode(' ', $arg);
foreach ($words as $word) {
if ($word != '') {
$wordOrder[] = 'CASE WHEN ' .
$this->getWordRegExp($word) .
' THEN 1 ELSE 0 END';
}
}
$order = '((' . implode(') + (', $wordOrder) . ')) DESC';
return $order;
}
|
[
"public",
"function",
"getOrderBy",
"(",
"$",
"arg",
")",
"{",
"// Check if there are phrases in $arg should handle as it is",
"$",
"phrase",
"=",
"explode",
"(",
"\"\\\"\"",
",",
"$",
"arg",
")",
";",
"if",
"(",
"count",
"(",
"$",
"phrase",
")",
">",
"2",
")",
"{",
"// Re-init $arg variable ",
"// (It will contain the rest of $arg except phrases).",
"$",
"arg",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"phrase",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"%",
"2",
"==",
"0",
"&&",
"$",
"phrase",
"[",
"$",
"i",
"]",
"!=",
"''",
")",
"{",
"// Re-build $arg variable after restricting phrases",
"$",
"arg",
".=",
"$",
"phrase",
"[",
"$",
"i",
"]",
";",
"}",
"elseif",
"(",
"$",
"i",
"%",
"2",
"==",
"1",
"&&",
"$",
"phrase",
"[",
"$",
"i",
"]",
"!=",
"''",
")",
"{",
"// Handle phrases using reqular LIKE matching in MySQL",
"$",
"wordOrder",
"[",
"]",
"=",
"$",
"this",
"->",
"getWordLike",
"(",
"$",
"phrase",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}",
"// Handle normal $arg using lex's and regular expresion",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"arg",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"if",
"(",
"$",
"word",
"!=",
"''",
")",
"{",
"$",
"wordOrder",
"[",
"]",
"=",
"'CASE WHEN '",
".",
"$",
"this",
"->",
"getWordRegExp",
"(",
"$",
"word",
")",
".",
"' THEN 1 ELSE 0 END'",
";",
"}",
"}",
"$",
"order",
"=",
"'(('",
".",
"implode",
"(",
"') + ('",
",",
"$",
"wordOrder",
")",
".",
"')) DESC'",
";",
"return",
"$",
"order",
";",
"}"
] |
Get more relevant order by section related to the user search keywords
@param string $arg String that user search for in the database table
@return string sub SQL ORDER BY section
@author Saleh AlMatrafe <saleh@saleh.cc>
|
[
"Get",
"more",
"relevant",
"order",
"by",
"section",
"related",
"to",
"the",
"user",
"search",
"keywords"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Query.php#L418-L450
|
227,705
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Query.php
|
Query.lex
|
protected function lex($arg)
{
$arg = preg_replace($this->_lexPatterns, $this->_lexReplacements, $arg);
return $arg;
}
|
php
|
protected function lex($arg)
{
$arg = preg_replace($this->_lexPatterns, $this->_lexReplacements, $arg);
return $arg;
}
|
[
"protected",
"function",
"lex",
"(",
"$",
"arg",
")",
"{",
"$",
"arg",
"=",
"preg_replace",
"(",
"$",
"this",
"->",
"_lexPatterns",
",",
"$",
"this",
"->",
"_lexReplacements",
",",
"$",
"arg",
")",
";",
"return",
"$",
"arg",
";",
"}"
] |
This method will implement various regular expressin rules based on
pre-defined Arabic lexical rules
@param string $arg String of one word user want to search for
@return string Regular Expression format to be used in MySQL Query statement
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"This",
"method",
"will",
"implement",
"various",
"regular",
"expressin",
"rules",
"based",
"on",
"pre",
"-",
"defined",
"Arabic",
"lexical",
"rules"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Query.php#L461-L466
|
227,706
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Query.php
|
Query.allForms
|
public function allForms($arg, $array = false)
{
$wordForms = array();
$words = explode(' ', $arg);
foreach ($words as $word) {
$wordForms = array_merge($wordForms, $this->allWordForms($word));
}
if ($array) {
return $wordForms;
}
$str = implode(' ', $wordForms);
return $str;
}
|
php
|
public function allForms($arg, $array = false)
{
$wordForms = array();
$words = explode(' ', $arg);
foreach ($words as $word) {
$wordForms = array_merge($wordForms, $this->allWordForms($word));
}
if ($array) {
return $wordForms;
}
$str = implode(' ', $wordForms);
return $str;
}
|
[
"public",
"function",
"allForms",
"(",
"$",
"arg",
",",
"$",
"array",
"=",
"false",
")",
"{",
"$",
"wordForms",
"=",
"array",
"(",
")",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"arg",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"$",
"wordForms",
"=",
"array_merge",
"(",
"$",
"wordForms",
",",
"$",
"this",
"->",
"allWordForms",
"(",
"$",
"word",
")",
")",
";",
"}",
"if",
"(",
"$",
"array",
")",
"{",
"return",
"$",
"wordForms",
";",
"}",
"$",
"str",
"=",
"implode",
"(",
"' '",
",",
"$",
"wordForms",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Get most possible Arabic lexical forms of user search keywords
@param string $arg String that user search for
@param boolean $array whether to return words as a string or an array
@return string list of most possible Arabic lexical forms for given keywords
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Get",
"most",
"possible",
"Arabic",
"lexical",
"forms",
"of",
"user",
"search",
"keywords"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Query.php#L575-L591
|
227,707
|
authlete/authlete-php
|
src/Dto/Scope.php
|
Scope.setDescriptions
|
public function setDescriptions(array $descriptions = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$descriptions', $descriptions, __NAMESPACE__ . '\TaggedValue');
$this->descriptions = $descriptions;
return $this;
}
|
php
|
public function setDescriptions(array $descriptions = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$descriptions', $descriptions, __NAMESPACE__ . '\TaggedValue');
$this->descriptions = $descriptions;
return $this;
}
|
[
"public",
"function",
"setDescriptions",
"(",
"array",
"$",
"descriptions",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$descriptions'",
",",
"$",
"descriptions",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"descriptions",
"=",
"$",
"descriptions",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the localized descriptions of this scope.
@param TaggedValue[] $descriptions
The localized descriptions of this scope.
@return Scope
`$this` object.
|
[
"Set",
"the",
"localized",
"descriptions",
"of",
"this",
"scope",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Scope.php#L178-L186
|
227,708
|
authlete/authlete-php
|
src/Dto/Scope.php
|
Scope.setAttributes
|
public function setAttributes(array $attributes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$attributes', $attributes, __NAMESPACE__ . '\Pair');
$this->attributes = $attributes;
return $this;
}
|
php
|
public function setAttributes(array $attributes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$attributes', $attributes, __NAMESPACE__ . '\Pair');
$this->attributes = $attributes;
return $this;
}
|
[
"public",
"function",
"setAttributes",
"(",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$attributes'",
",",
"$",
"attributes",
",",
"__NAMESPACE__",
".",
"'\\Pair'",
")",
";",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the attributes of this scope.
@param Pair[] $attributes
The attributes of this scope.
@return Scope
`$this` object.
|
[
"Set",
"the",
"attributes",
"of",
"this",
"scope",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Scope.php#L210-L218
|
227,709
|
mayoz/parasut
|
src/Bundle/Contact.php
|
Contact.find
|
public function find($id, $payments = false, $transactions = false, $stats = false)
{
return $this->client->call("contacts/{$id}", array_filter([
'outstanding_payments' => $payments,
'past_transactions' => $transactions,
'stats' => $stats
]), 'GET');
}
|
php
|
public function find($id, $payments = false, $transactions = false, $stats = false)
{
return $this->client->call("contacts/{$id}", array_filter([
'outstanding_payments' => $payments,
'past_transactions' => $transactions,
'stats' => $stats
]), 'GET');
}
|
[
"public",
"function",
"find",
"(",
"$",
"id",
",",
"$",
"payments",
"=",
"false",
",",
"$",
"transactions",
"=",
"false",
",",
"$",
"stats",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"call",
"(",
"\"contacts/{$id}\"",
",",
"array_filter",
"(",
"[",
"'outstanding_payments'",
"=>",
"$",
"payments",
",",
"'past_transactions'",
"=>",
"$",
"transactions",
",",
"'stats'",
"=>",
"$",
"stats",
"]",
")",
",",
"'GET'",
")",
";",
"}"
] |
Retrieve a contact informations via its own id.
@param int $id
@param bool $payments
@param bool $transactions
@param bool $stats
@return array
|
[
"Retrieve",
"a",
"contact",
"informations",
"via",
"its",
"own",
"id",
"."
] |
88b45bc3f7f84da9b6028ffd7f02547d9b537506
|
https://github.com/mayoz/parasut/blob/88b45bc3f7f84da9b6028ffd7f02547d9b537506/src/Bundle/Contact.php#L63-L70
|
227,710
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Salat.php
|
Salat.setDate
|
public function setDate($m = 8, $d = 2, $y = 1975)
{
if (is_numeric($y) && $y > 0 && $y < 3000) {
$this->year = floor($y);
}
if (is_numeric($m) && $m >= 1 && $m <= 12) {
$this->month = floor($m);
}
if (is_numeric($d) && $d >= 1 && $d <= 31) {
$this->day = floor($d);
}
return $this;
}
|
php
|
public function setDate($m = 8, $d = 2, $y = 1975)
{
if (is_numeric($y) && $y > 0 && $y < 3000) {
$this->year = floor($y);
}
if (is_numeric($m) && $m >= 1 && $m <= 12) {
$this->month = floor($m);
}
if (is_numeric($d) && $d >= 1 && $d <= 31) {
$this->day = floor($d);
}
return $this;
}
|
[
"public",
"function",
"setDate",
"(",
"$",
"m",
"=",
"8",
",",
"$",
"d",
"=",
"2",
",",
"$",
"y",
"=",
"1975",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"y",
")",
"&&",
"$",
"y",
">",
"0",
"&&",
"$",
"y",
"<",
"3000",
")",
"{",
"$",
"this",
"->",
"year",
"=",
"floor",
"(",
"$",
"y",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"m",
")",
"&&",
"$",
"m",
">=",
"1",
"&&",
"$",
"m",
"<=",
"12",
")",
"{",
"$",
"this",
"->",
"month",
"=",
"floor",
"(",
"$",
"m",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"d",
")",
"&&",
"$",
"d",
">=",
"1",
"&&",
"$",
"d",
"<=",
"31",
")",
"{",
"$",
"this",
"->",
"day",
"=",
"floor",
"(",
"$",
"d",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Setting date of day for Salat calculation
@param integer $m Month of date you want to calculate Salat in
@param integer $d Day of date you want to calculate Salat in
@param integer $y Year (four digits) of date you want to calculate Salat in
@return object $this to build a fluent interface
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Setting",
"date",
"of",
"day",
"for",
"Salat",
"calculation"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Salat.php#L265-L280
|
227,711
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Salat.php
|
Salat.setLocation
|
public function setLocation($l1 = 36.20278, $l2 = 37.15861, $z = 2, $e = 0)
{
if (is_numeric($l1) && $l1 >= -180 && $l1 <= 180) {
$this->lat = $l1;
}
if (is_numeric($l2) && $l2 >= -180 && $l2 <= 180) {
$this->long = $l2;
}
if (is_numeric($z) && $z >= -12 && $z <= 12) {
$this->zone = floor($z);
}
if (is_numeric($e)) {
$this->elevation = $e;
}
return $this;
}
|
php
|
public function setLocation($l1 = 36.20278, $l2 = 37.15861, $z = 2, $e = 0)
{
if (is_numeric($l1) && $l1 >= -180 && $l1 <= 180) {
$this->lat = $l1;
}
if (is_numeric($l2) && $l2 >= -180 && $l2 <= 180) {
$this->long = $l2;
}
if (is_numeric($z) && $z >= -12 && $z <= 12) {
$this->zone = floor($z);
}
if (is_numeric($e)) {
$this->elevation = $e;
}
return $this;
}
|
[
"public",
"function",
"setLocation",
"(",
"$",
"l1",
"=",
"36.20278",
",",
"$",
"l2",
"=",
"37.15861",
",",
"$",
"z",
"=",
"2",
",",
"$",
"e",
"=",
"0",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"l1",
")",
"&&",
"$",
"l1",
">=",
"-",
"180",
"&&",
"$",
"l1",
"<=",
"180",
")",
"{",
"$",
"this",
"->",
"lat",
"=",
"$",
"l1",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"l2",
")",
"&&",
"$",
"l2",
">=",
"-",
"180",
"&&",
"$",
"l2",
"<=",
"180",
")",
"{",
"$",
"this",
"->",
"long",
"=",
"$",
"l2",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"z",
")",
"&&",
"$",
"z",
">=",
"-",
"12",
"&&",
"$",
"z",
"<=",
"12",
")",
"{",
"$",
"this",
"->",
"zone",
"=",
"floor",
"(",
"$",
"z",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"e",
")",
")",
"{",
"$",
"this",
"->",
"elevation",
"=",
"$",
"e",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Setting location information for Salat calculation
@param decimal $l1 Latitude of location you want to calculate Salat time in
@param decimal $l2 Longitude of location you want to calculate Salat time in
@param integer $z Time Zone, offset from UTC (see also Greenwich Mean Time)
@param integer $e Elevation, it is the observer's height in meters.
@return object $this to build a fluent interface
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Setting",
"location",
"information",
"for",
"Salat",
"calculation"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Salat.php#L293-L312
|
227,712
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Salat.php
|
Salat.setConf
|
public function setConf(
$sch = 'Shafi', $sunriseArc = -0.833333, $ishaArc = -17.5,
$fajrArc = -19.5, $view = 'Sunni'
) {
$sch = ucfirst($sch);
if ($sch == 'Shafi' || $sch == 'Hanafi') {
$this->school = $sch;
}
if (is_numeric($sunriseArc) && $sunriseArc >= -180 && $sunriseArc <= 180) {
$this->AB2 = $sunriseArc;
}
if (is_numeric($ishaArc) && $ishaArc >= -180 && $ishaArc <= 180) {
$this->AG2 = $ishaArc;
}
if (is_numeric($fajrArc) && $fajrArc >= -180 && $fajrArc <= 180) {
$this->AJ2 = $fajrArc;
}
if ($view == 'Sunni' || $view == 'Shia') {
$this->view = $view;
}
return $this;
}
|
php
|
public function setConf(
$sch = 'Shafi', $sunriseArc = -0.833333, $ishaArc = -17.5,
$fajrArc = -19.5, $view = 'Sunni'
) {
$sch = ucfirst($sch);
if ($sch == 'Shafi' || $sch == 'Hanafi') {
$this->school = $sch;
}
if (is_numeric($sunriseArc) && $sunriseArc >= -180 && $sunriseArc <= 180) {
$this->AB2 = $sunriseArc;
}
if (is_numeric($ishaArc) && $ishaArc >= -180 && $ishaArc <= 180) {
$this->AG2 = $ishaArc;
}
if (is_numeric($fajrArc) && $fajrArc >= -180 && $fajrArc <= 180) {
$this->AJ2 = $fajrArc;
}
if ($view == 'Sunni' || $view == 'Shia') {
$this->view = $view;
}
return $this;
}
|
[
"public",
"function",
"setConf",
"(",
"$",
"sch",
"=",
"'Shafi'",
",",
"$",
"sunriseArc",
"=",
"-",
"0.833333",
",",
"$",
"ishaArc",
"=",
"-",
"17.5",
",",
"$",
"fajrArc",
"=",
"-",
"19.5",
",",
"$",
"view",
"=",
"'Sunni'",
")",
"{",
"$",
"sch",
"=",
"ucfirst",
"(",
"$",
"sch",
")",
";",
"if",
"(",
"$",
"sch",
"==",
"'Shafi'",
"||",
"$",
"sch",
"==",
"'Hanafi'",
")",
"{",
"$",
"this",
"->",
"school",
"=",
"$",
"sch",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"sunriseArc",
")",
"&&",
"$",
"sunriseArc",
">=",
"-",
"180",
"&&",
"$",
"sunriseArc",
"<=",
"180",
")",
"{",
"$",
"this",
"->",
"AB2",
"=",
"$",
"sunriseArc",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"ishaArc",
")",
"&&",
"$",
"ishaArc",
">=",
"-",
"180",
"&&",
"$",
"ishaArc",
"<=",
"180",
")",
"{",
"$",
"this",
"->",
"AG2",
"=",
"$",
"ishaArc",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"fajrArc",
")",
"&&",
"$",
"fajrArc",
">=",
"-",
"180",
"&&",
"$",
"fajrArc",
"<=",
"180",
")",
"{",
"$",
"this",
"->",
"AJ2",
"=",
"$",
"fajrArc",
";",
"}",
"if",
"(",
"$",
"view",
"==",
"'Sunni'",
"||",
"$",
"view",
"==",
"'Shia'",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"$",
"view",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Setting rest of Salat calculation configuration
Convention Fajr Angle Isha Angle
Muslim World League -18 -17
Islamic Society of North America (ISNA) -15 -15
Egyptian General Authority of Survey -19.5 -17.5
Umm al-Qura University, Makkah -18.5
Isha 90 min after Maghrib, 120 min during Ramadan
University of Islamic Sciences, Karachi -18 -18
Institute of Geophysics, University of Tehran -17.7 -14(*)
Shia Ithna Ashari, Leva Research Institute, Qum -16 -14
(*) Isha angle is not explicitly defined in Tehran method
Fajr Angle = $fajrArc, Isha Angle = $ishaArc
- حزب العلماء في لندن لدول
أوروبا في خطوط عرض تزيد على 48
$ishaArc = -17
$fajrArc = -17
@param string $sch [Shafi|Hanafi] to define Muslims Salat
calculation method (affect Asr time)
@param decimal $sunriseArc Sun rise arc (default value is -0.833333)
@param decimal $ishaArc Isha arc (default value is -18)
@param decimal $fajrArc Fajr arc (default value is -18)
@param string $view [Sunni|Shia] to define Muslims Salat calculation
method (affect Maghrib and Midnight time)
@return object $this to build a fluent interface
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Setting",
"rest",
"of",
"Salat",
"calculation",
"configuration"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Salat.php#L354-L381
|
227,713
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Salat.php
|
Salat.getQibla
|
public function getQibla ()
{
// The geographical coordinates of the Ka'ba
$K_latitude = 21.423333;
$K_longitude = 39.823333;
$latitude = $this->lat;
$longitude = $this->long;
$numerator = sin(deg2rad($K_longitude - $longitude));
$denominator = (cos(deg2rad($latitude)) * tan(deg2rad($K_latitude))) -
(sin(deg2rad($latitude))
* cos(deg2rad($K_longitude - $longitude)));
$q = atan($numerator / $denominator);
$q = rad2deg($q);
if ($this->lat > 21.423333) {
$q += 180;
}
return $q;
}
|
php
|
public function getQibla ()
{
// The geographical coordinates of the Ka'ba
$K_latitude = 21.423333;
$K_longitude = 39.823333;
$latitude = $this->lat;
$longitude = $this->long;
$numerator = sin(deg2rad($K_longitude - $longitude));
$denominator = (cos(deg2rad($latitude)) * tan(deg2rad($K_latitude))) -
(sin(deg2rad($latitude))
* cos(deg2rad($K_longitude - $longitude)));
$q = atan($numerator / $denominator);
$q = rad2deg($q);
if ($this->lat > 21.423333) {
$q += 180;
}
return $q;
}
|
[
"public",
"function",
"getQibla",
"(",
")",
"{",
"// The geographical coordinates of the Ka'ba",
"$",
"K_latitude",
"=",
"21.423333",
";",
"$",
"K_longitude",
"=",
"39.823333",
";",
"$",
"latitude",
"=",
"$",
"this",
"->",
"lat",
";",
"$",
"longitude",
"=",
"$",
"this",
"->",
"long",
";",
"$",
"numerator",
"=",
"sin",
"(",
"deg2rad",
"(",
"$",
"K_longitude",
"-",
"$",
"longitude",
")",
")",
";",
"$",
"denominator",
"=",
"(",
"cos",
"(",
"deg2rad",
"(",
"$",
"latitude",
")",
")",
"*",
"tan",
"(",
"deg2rad",
"(",
"$",
"K_latitude",
")",
")",
")",
"-",
"(",
"sin",
"(",
"deg2rad",
"(",
"$",
"latitude",
")",
")",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"K_longitude",
"-",
"$",
"longitude",
")",
")",
")",
";",
"$",
"q",
"=",
"atan",
"(",
"$",
"numerator",
"/",
"$",
"denominator",
")",
";",
"$",
"q",
"=",
"rad2deg",
"(",
"$",
"q",
")",
";",
"if",
"(",
"$",
"this",
"->",
"lat",
">",
"21.423333",
")",
"{",
"$",
"q",
"+=",
"180",
";",
"}",
"return",
"$",
"q",
";",
"}"
] |
Determine Qibla direction using basic spherical trigonometric formula
@return float Qibla Direction (from the north direction) in degrees
@author Khaled Al-Sham'aa <khaled@ar-php.org>
@author S. Kamal Abdali <k.abdali@acm.org>
@source http://www.patriot.net/users/abdali/ftp/qibla.pdf
|
[
"Determine",
"Qibla",
"direction",
"using",
"basic",
"spherical",
"trigonometric",
"formula"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Salat.php#L603-L625
|
227,714
|
authlete/authlete-php
|
src/Dto/UserInfoResponse.php
|
UserInfoResponse.setClaims
|
public function setClaims(array $claims = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claims', $claims);
$this->claims = $claims;
return $this;
}
|
php
|
public function setClaims(array $claims = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claims', $claims);
$this->claims = $claims;
return $this;
}
|
[
"public",
"function",
"setClaims",
"(",
"array",
"$",
"claims",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$claims'",
",",
"$",
"claims",
")",
";",
"$",
"this",
"->",
"claims",
"=",
"$",
"claims",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of claims that the client application requests to be
embedded in the userinfo response.
@param string[] $claims
The list of claims that the client application requests to be
embedded in the userinfo response.
@return UserInfoResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"claims",
"that",
"the",
"client",
"application",
"requests",
"to",
"be",
"embedded",
"in",
"the",
"userinfo",
"response",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/UserInfoResponse.php#L343-L350
|
227,715
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.toString
|
public static function toString($value)
{
if (is_null($value) || is_string($value))
{
return $value;
}
if (is_bool($value))
{
return ($value ? "true" : "false");
}
return strval($value);
}
|
php
|
public static function toString($value)
{
if (is_null($value) || is_string($value))
{
return $value;
}
if (is_bool($value))
{
return ($value ? "true" : "false");
}
return strval($value);
}
|
[
"public",
"static",
"function",
"toString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"$",
"value",
"?",
"\"true\"",
":",
"\"false\"",
")",
";",
"}",
"return",
"strval",
"(",
"$",
"value",
")",
";",
"}"
] |
Get the string value of the given object.
@param mixed $value
An object.
@return string
If the given `$value` is `null` or a `string` object,
the `$value` itself is returned. Otherwise, if it is
a boolean object, `"true"` or `"false"` is returned.
In other cases, `strval($value)` is returned.
|
[
"Get",
"the",
"string",
"value",
"of",
"the",
"given",
"object",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L81-L94
|
227,716
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.parseBoolean
|
public static function parseBoolean($value)
{
if (is_null($value))
{
return false;
}
if (is_bool($value))
{
return $value;
}
if (!is_string($value))
{
throw new \InvalidArgumentException('Failed to parse as bool.');
}
if (strcasecmp('true', $value) != 0)
{
return false;
}
return true;
}
|
php
|
public static function parseBoolean($value)
{
if (is_null($value))
{
return false;
}
if (is_bool($value))
{
return $value;
}
if (!is_string($value))
{
throw new \InvalidArgumentException('Failed to parse as bool.');
}
if (strcasecmp('true', $value) != 0)
{
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"parseBoolean",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Failed to parse as bool.'",
")",
";",
"}",
"if",
"(",
"strcasecmp",
"(",
"'true'",
",",
"$",
"value",
")",
"!=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Parse the given object as boolean.
@param mixed $value
An object.
@return boolean
If the given object is `null`, `false` is returned.
Otherwise, if the type of the given object is `boolean`,
the given object itself is returned. Otherwise, if the
type of the given object is not `string`, an
`InvalidArgumentException` is thrown. Otherwise, this
method compares the given string to "true" in a
case-insensitive manner. If they match, this method
returns `true`. Otherwise, `false` is returned.
@throws \InvalidArgumentException
The given object is not `null` and the type of the
given object is neither `boolean` nor `string`.
|
[
"Parse",
"the",
"given",
"object",
"as",
"boolean",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L117-L140
|
227,717
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.parseInteger
|
public static function parseInteger($value)
{
if (is_null($value))
{
return 0;
}
if (is_integer($value))
{
return $value;
}
if (!is_string($value))
{
throw new \InvalidArgumentException('Failed to parse as an integer.');
}
return intval($value);
}
|
php
|
public static function parseInteger($value)
{
if (is_null($value))
{
return 0;
}
if (is_integer($value))
{
return $value;
}
if (!is_string($value))
{
throw new \InvalidArgumentException('Failed to parse as an integer.');
}
return intval($value);
}
|
[
"public",
"static",
"function",
"parseInteger",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"is_integer",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Failed to parse as an integer.'",
")",
";",
"}",
"return",
"intval",
"(",
"$",
"value",
")",
";",
"}"
] |
Parse the given object as integer.
@param mixed $value
An object.
@return integer
If the given object is `null`, 0 is returned. Otherwise, if
the type of the given object is `integer`, the given object
itself is returned. Otherwise, if the type of the given
object is not `string`, an `InvalidArgumentException` is
thrown. Otherwise, this method returns `intval($value)`.
@throws \InvalidArgumentException
The given object is not `null` and the type of the
given object is neither `integer` nor `string`.
|
[
"Parse",
"the",
"given",
"object",
"as",
"integer",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L160-L178
|
227,718
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.&
|
public static function &convertArray(array &$array = null, $converter, $arg = null)
{
if (is_null($array))
{
// 'return null' would generate the following warning.
//
// "Only variable references should be returned by reference"
//
// Therefore, an intermidiate object is used here.
$output = null;
return $output;
}
$output = array();
array_walk(
$array,
function ($value, $key) use ($converter, $arg, &$output)
{
if (is_null($arg))
{
$output[] = $converter($value);
}
else
{
$output[] = $converter($value, $arg);
}
}
);
return $output;
}
|
php
|
public static function &convertArray(array &$array = null, $converter, $arg = null)
{
if (is_null($array))
{
// 'return null' would generate the following warning.
//
// "Only variable references should be returned by reference"
//
// Therefore, an intermidiate object is used here.
$output = null;
return $output;
}
$output = array();
array_walk(
$array,
function ($value, $key) use ($converter, $arg, &$output)
{
if (is_null($arg))
{
$output[] = $converter($value);
}
else
{
$output[] = $converter($value, $arg);
}
}
);
return $output;
}
|
[
"public",
"static",
"function",
"&",
"convertArray",
"(",
"array",
"&",
"$",
"array",
"=",
"null",
",",
"$",
"converter",
",",
"$",
"arg",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"array",
")",
")",
"{",
"// 'return null' would generate the following warning.",
"//",
"// \"Only variable references should be returned by reference\"",
"//",
"// Therefore, an intermidiate object is used here.",
"$",
"output",
"=",
"null",
";",
"return",
"$",
"output",
";",
"}",
"$",
"output",
"=",
"array",
"(",
")",
";",
"array_walk",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"$",
"converter",
",",
"$",
"arg",
",",
"&",
"$",
"output",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"converter",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"converter",
"(",
"$",
"value",
",",
"$",
"arg",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Convert elements of an array with a given converter and generate
a new array.
@param array $array
A reference to an array.
@param callable $converter
A function that converts an element to another object. When `$arg`
is `null`, `$converter` should be a function that takes one argument
(an element). When `$arg` is not `null`, `$converter` should be a
function that takes two arguments, an element and `$arg`.
@param mixed $arg
An optional argument given to the converter.
@return array
A reference of a new array that holds converted elements.
|
[
"Convert",
"elements",
"of",
"an",
"array",
"with",
"a",
"given",
"converter",
"and",
"generate",
"a",
"new",
"array",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L272-L303
|
227,719
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.convertArrayCopyableToJson
|
public static function convertArrayCopyableToJson(ArrayCopyable $object = null, $options = 0)
{
$array = self::convertArrayCopyableToArray($object);
if (is_null($array))
{
return null;
}
return json_encode($array, $options);
}
|
php
|
public static function convertArrayCopyableToJson(ArrayCopyable $object = null, $options = 0)
{
$array = self::convertArrayCopyableToArray($object);
if (is_null($array))
{
return null;
}
return json_encode($array, $options);
}
|
[
"public",
"static",
"function",
"convertArrayCopyableToJson",
"(",
"ArrayCopyable",
"$",
"object",
"=",
"null",
",",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"array",
"=",
"self",
"::",
"convertArrayCopyableToArray",
"(",
"$",
"object",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"array",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"json_encode",
"(",
"$",
"array",
",",
"$",
"options",
")",
";",
"}"
] |
Convert an ArrayCopyable instance to a JSON string.
@param ArrayCopyable $object
An object that implements the `ArrayCopyable` interface.
`copyToArray()` method of the object will be called.
@param integer $options
Options passed `json_encode()`.
@return string
A JSON string generated from the given object.
|
[
"Convert",
"an",
"ArrayCopyable",
"instance",
"to",
"a",
"JSON",
"string",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L344-L354
|
227,720
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.convertArrayToArrayCopyable
|
public static function convertArrayToArrayCopyable(array &$array = null, $className)
{
if (is_null($array))
{
return null;
}
if (is_null($className) || !is_string($className))
{
return null;
}
$object = new $className();
$object->copyFromArray($array);
return $object;
}
|
php
|
public static function convertArrayToArrayCopyable(array &$array = null, $className)
{
if (is_null($array))
{
return null;
}
if (is_null($className) || !is_string($className))
{
return null;
}
$object = new $className();
$object->copyFromArray($array);
return $object;
}
|
[
"public",
"static",
"function",
"convertArrayToArrayCopyable",
"(",
"array",
"&",
"$",
"array",
"=",
"null",
",",
"$",
"className",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"array",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"className",
")",
"||",
"!",
"is_string",
"(",
"$",
"className",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"object",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"object",
"->",
"copyFromArray",
"(",
"$",
"array",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Convert an array to an object.
@param array $array
A reference to an array.
@param string $className
A name of a class that implements the `ArrayCopyable` interface.
An instance of the class will be created and its `copyFromArray()`
method will be called.
@return mixed
An instance of the class which is specified by the class name.
|
[
"Convert",
"an",
"array",
"to",
"an",
"object",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L371-L387
|
227,721
|
authlete/authlete-php
|
src/Util/LanguageUtility.php
|
LanguageUtility.convertJsonToArrayCopyable
|
public static function convertJsonToArrayCopyable($json, $className)
{
if (is_null($json) || !is_string($json))
{
return null;
}
$array = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
return self::convertArrayToArrayCopyable($array, $className);
}
|
php
|
public static function convertJsonToArrayCopyable($json, $className)
{
if (is_null($json) || !is_string($json))
{
return null;
}
$array = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
return self::convertArrayToArrayCopyable($array, $className);
}
|
[
"public",
"static",
"function",
"convertJsonToArrayCopyable",
"(",
"$",
"json",
",",
"$",
"className",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"json",
")",
"||",
"!",
"is_string",
"(",
"$",
"json",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"array",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
",",
"512",
",",
"JSON_BIGINT_AS_STRING",
")",
";",
"return",
"self",
"::",
"convertArrayToArrayCopyable",
"(",
"$",
"array",
",",
"$",
"className",
")",
";",
"}"
] |
Convert a JSON string to an object.
@param string $json
A JSON string.
@param string $className
A name of a class that implements the `ArrayCopyable` interface.
An instance of the class will be created and its `copyFromArray()`
method will be called.
@return mixed
An instance of the class which is specified by the class name.
|
[
"Convert",
"a",
"JSON",
"string",
"to",
"an",
"object",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/LanguageUtility.php#L404-L414
|
227,722
|
masasron/firebase-php
|
src/Client.php
|
Client.generateToken
|
public static function generateToken($secret, $object)
{
try
{
return (new TokenGenerator($secret))
->setData($object)
->create();
} catch (TokenException $e)
{
$e->getMessage();
return false;
}
}
|
php
|
public static function generateToken($secret, $object)
{
try
{
return (new TokenGenerator($secret))
->setData($object)
->create();
} catch (TokenException $e)
{
$e->getMessage();
return false;
}
}
|
[
"public",
"static",
"function",
"generateToken",
"(",
"$",
"secret",
",",
"$",
"object",
")",
"{",
"try",
"{",
"return",
"(",
"new",
"TokenGenerator",
"(",
"$",
"secret",
")",
")",
"->",
"setData",
"(",
"$",
"object",
")",
"->",
"create",
"(",
")",
";",
"}",
"catch",
"(",
"TokenException",
"$",
"e",
")",
"{",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Generate access token
@param string $secret
@param array $object
@return TokenGenerator
|
[
"Generate",
"access",
"token"
] |
e787a484a0537643207642e425ceec4adf2eb6bb
|
https://github.com/masasron/firebase-php/blob/e787a484a0537643207642e425ceec4adf2eb6bb/src/Client.php#L56-L68
|
227,723
|
masasron/firebase-php
|
src/Client.php
|
Client.get
|
public function get()
{
try
{
$ch = $this->curl('GET');
$return = curl_exec($ch);
curl_close($ch);
return json_decode($return, true);
} catch (Exception $e)
{
//...
}
return null;
}
|
php
|
public function get()
{
try
{
$ch = $this->curl('GET');
$return = curl_exec($ch);
curl_close($ch);
return json_decode($return, true);
} catch (Exception $e)
{
//...
}
return null;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"try",
"{",
"$",
"ch",
"=",
"$",
"this",
"->",
"curl",
"(",
"'GET'",
")",
";",
"$",
"return",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"json_decode",
"(",
"$",
"return",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"//...",
"}",
"return",
"null",
";",
"}"
] |
Get data from Firebase with a GET request
@return array
|
[
"Get",
"data",
"from",
"Firebase",
"with",
"a",
"GET",
"request"
] |
e787a484a0537643207642e425ceec4adf2eb6bb
|
https://github.com/masasron/firebase-php/blob/e787a484a0537643207642e425ceec4adf2eb6bb/src/Client.php#L129-L142
|
227,724
|
masasron/firebase-php
|
src/Client.php
|
Client.curl
|
private function curl($mode)
{
$url = sprintf('%s.json', $this->_host);
if ($this->_token)
{
$url = sprintf('%s?auth=%s', $url, $this->_token);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
return $ch;
}
|
php
|
private function curl($mode)
{
$url = sprintf('%s.json', $this->_host);
if ($this->_token)
{
$url = sprintf('%s?auth=%s', $url, $this->_token);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
return $ch;
}
|
[
"private",
"function",
"curl",
"(",
"$",
"mode",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s.json'",
",",
"$",
"this",
"->",
"_host",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_token",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s?auth=%s'",
",",
"$",
"url",
",",
"$",
"this",
"->",
"_token",
")",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT",
",",
"$",
"this",
"->",
"_timeout",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"$",
"this",
"->",
"_timeout",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"mode",
")",
";",
"return",
"$",
"ch",
";",
"}"
] |
Generate curl object
@param string $mode
@return curl
|
[
"Generate",
"curl",
"object"
] |
e787a484a0537643207642e425ceec4adf2eb6bb
|
https://github.com/masasron/firebase-php/blob/e787a484a0537643207642e425ceec4adf2eb6bb/src/Client.php#L150-L167
|
227,725
|
masasron/firebase-php
|
src/Client.php
|
Client.write
|
private function write($data, $method = 'PUT')
{
$jsonData = json_encode($data);
$header = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData)
);
try
{
$ch = $this->curl($method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$return = curl_exec($ch);
curl_close($ch);
return json_decode($return, true);
} catch (Exception $e)
{
//...
}
return null;
}
|
php
|
private function write($data, $method = 'PUT')
{
$jsonData = json_encode($data);
$header = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData)
);
try
{
$ch = $this->curl($method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$return = curl_exec($ch);
curl_close($ch);
return json_decode($return, true);
} catch (Exception $e)
{
//...
}
return null;
}
|
[
"private",
"function",
"write",
"(",
"$",
"data",
",",
"$",
"method",
"=",
"'PUT'",
")",
"{",
"$",
"jsonData",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"header",
"=",
"array",
"(",
"'Content-Type: application/json'",
",",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"jsonData",
")",
")",
";",
"try",
"{",
"$",
"ch",
"=",
"$",
"this",
"->",
"curl",
"(",
"$",
"method",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"header",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"jsonData",
")",
";",
"$",
"return",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"json_decode",
"(",
"$",
"return",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"//...",
"}",
"return",
"null",
";",
"}"
] |
Write data into firebase
@param mixed $data
@param string $method
@return array
|
[
"Write",
"data",
"into",
"firebase"
] |
e787a484a0537643207642e425ceec4adf2eb6bb
|
https://github.com/masasron/firebase-php/blob/e787a484a0537643207642e425ceec4adf2eb6bb/src/Client.php#L176-L196
|
227,726
|
contao-bootstrap/layout
|
src/View/Template/AbstractFilter.php
|
AbstractFilter.isTemplateNameSupported
|
protected function isTemplateNameSupported(string $templateName): bool
{
$templateNames = $this->getEnvironment()->getConfig()->get($this->templateConfigKey);
if (!is_array($templateNames)) {
return false;
}
foreach ($templateNames as $supported) {
if ($templateName === $supported) {
return true;
}
if (substr($supported, -1) === '*'
&& 0 == strcasecmp(substr($supported, 0, -1), substr($templateName, 0, (strlen($supported) - 1)))
) {
return true;
}
}
return false;
}
|
php
|
protected function isTemplateNameSupported(string $templateName): bool
{
$templateNames = $this->getEnvironment()->getConfig()->get($this->templateConfigKey);
if (!is_array($templateNames)) {
return false;
}
foreach ($templateNames as $supported) {
if ($templateName === $supported) {
return true;
}
if (substr($supported, -1) === '*'
&& 0 == strcasecmp(substr($supported, 0, -1), substr($templateName, 0, (strlen($supported) - 1)))
) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"isTemplateNameSupported",
"(",
"string",
"$",
"templateName",
")",
":",
"bool",
"{",
"$",
"templateNames",
"=",
"$",
"this",
"->",
"getEnvironment",
"(",
")",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"templateConfigKey",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"templateNames",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"templateNames",
"as",
"$",
"supported",
")",
"{",
"if",
"(",
"$",
"templateName",
"===",
"$",
"supported",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"supported",
",",
"-",
"1",
")",
"===",
"'*'",
"&&",
"0",
"==",
"strcasecmp",
"(",
"substr",
"(",
"$",
"supported",
",",
"0",
",",
"-",
"1",
")",
",",
"substr",
"(",
"$",
"templateName",
",",
"0",
",",
"(",
"strlen",
"(",
"$",
"supported",
")",
"-",
"1",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if template name is supported.
@param string $templateName Template name.
@return bool
|
[
"Check",
"if",
"template",
"name",
"is",
"supported",
"."
] |
9871809d7ed82f8c17c3f84f5944b9291620aad3
|
https://github.com/contao-bootstrap/layout/blob/9871809d7ed82f8c17c3f84f5944b9291620aad3/src/View/Template/AbstractFilter.php#L68-L89
|
227,727
|
contao-bootstrap/layout
|
src/Helper/LayoutHelper.php
|
LayoutHelper.getAttributes
|
public function getAttributes(string $sectionId, bool $inside = false): Attributes
{
$attributes = new Attributes();
if ($inside) {
$attributes->addClass('inside');
} else {
$attributes->setId($sectionId);
}
if (in_array($sectionId, array(static::FOOTER, static::HEADER))) {
$key = sprintf('bs_%sClass', $sectionId);
if ($this->layout->$key) {
$attributes->addClass($this->layout->$key);
}
} elseif (in_array($sectionId, array(static::CONTAINER, static::WRAPPER))) {
$class = $this->layout->bs_containerClass;
if ($class && $this->layout->bs_containerElement === $sectionId) {
$attributes->addClass($class);
}
} elseif (static::isGridActive()) {
$key = sprintf('%sClass', $sectionId);
if ($this->$key) {
$attributes->addClass($this->$key);
}
}
$this->addSchemaAttributes($sectionId, $inside, $attributes);
return $attributes;
}
|
php
|
public function getAttributes(string $sectionId, bool $inside = false): Attributes
{
$attributes = new Attributes();
if ($inside) {
$attributes->addClass('inside');
} else {
$attributes->setId($sectionId);
}
if (in_array($sectionId, array(static::FOOTER, static::HEADER))) {
$key = sprintf('bs_%sClass', $sectionId);
if ($this->layout->$key) {
$attributes->addClass($this->layout->$key);
}
} elseif (in_array($sectionId, array(static::CONTAINER, static::WRAPPER))) {
$class = $this->layout->bs_containerClass;
if ($class && $this->layout->bs_containerElement === $sectionId) {
$attributes->addClass($class);
}
} elseif (static::isGridActive()) {
$key = sprintf('%sClass', $sectionId);
if ($this->$key) {
$attributes->addClass($this->$key);
}
}
$this->addSchemaAttributes($sectionId, $inside, $attributes);
return $attributes;
}
|
[
"public",
"function",
"getAttributes",
"(",
"string",
"$",
"sectionId",
",",
"bool",
"$",
"inside",
"=",
"false",
")",
":",
"Attributes",
"{",
"$",
"attributes",
"=",
"new",
"Attributes",
"(",
")",
";",
"if",
"(",
"$",
"inside",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"'inside'",
")",
";",
"}",
"else",
"{",
"$",
"attributes",
"->",
"setId",
"(",
"$",
"sectionId",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"sectionId",
",",
"array",
"(",
"static",
"::",
"FOOTER",
",",
"static",
"::",
"HEADER",
")",
")",
")",
"{",
"$",
"key",
"=",
"sprintf",
"(",
"'bs_%sClass'",
",",
"$",
"sectionId",
")",
";",
"if",
"(",
"$",
"this",
"->",
"layout",
"->",
"$",
"key",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"$",
"this",
"->",
"layout",
"->",
"$",
"key",
")",
";",
"}",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"sectionId",
",",
"array",
"(",
"static",
"::",
"CONTAINER",
",",
"static",
"::",
"WRAPPER",
")",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_containerClass",
";",
"if",
"(",
"$",
"class",
"&&",
"$",
"this",
"->",
"layout",
"->",
"bs_containerElement",
"===",
"$",
"sectionId",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"$",
"class",
")",
";",
"}",
"}",
"elseif",
"(",
"static",
"::",
"isGridActive",
"(",
")",
")",
"{",
"$",
"key",
"=",
"sprintf",
"(",
"'%sClass'",
",",
"$",
"sectionId",
")",
";",
"if",
"(",
"$",
"this",
"->",
"$",
"key",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"$",
"this",
"->",
"$",
"key",
")",
";",
"}",
"}",
"$",
"this",
"->",
"addSchemaAttributes",
"(",
"$",
"sectionId",
",",
"$",
"inside",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"attributes",
";",
"}"
] |
Get attributes for a specific section.
@param string $sectionId The section id.
@param bool $inside If true the inside class is added. Otherwhise $sectionId is set as id attribute.
@return Attributes
|
[
"Get",
"attributes",
"for",
"a",
"specific",
"section",
"."
] |
9871809d7ed82f8c17c3f84f5944b9291620aad3
|
https://github.com/contao-bootstrap/layout/blob/9871809d7ed82f8c17c3f84f5944b9291620aad3/src/Helper/LayoutHelper.php#L122-L155
|
227,728
|
contao-bootstrap/layout
|
src/Helper/LayoutHelper.php
|
LayoutHelper.initialize
|
private function initialize(): void
{
if (!$this->isBootstrapLayout()) {
return;
}
switch ($this->layout->cols) {
case '2cll':
$this->leftClass = $this->layout->bs_leftClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
case '2clr':
$this->rightClass = $this->layout->bs_rightClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
case '3cl':
$this->leftClass = $this->layout->bs_leftClass;
$this->rightClass = $this->layout->bs_rightClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
default:
$this->useGrid = false;
return;
}
$this->useGrid = true;
}
|
php
|
private function initialize(): void
{
if (!$this->isBootstrapLayout()) {
return;
}
switch ($this->layout->cols) {
case '2cll':
$this->leftClass = $this->layout->bs_leftClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
case '2clr':
$this->rightClass = $this->layout->bs_rightClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
case '3cl':
$this->leftClass = $this->layout->bs_leftClass;
$this->rightClass = $this->layout->bs_rightClass;
$this->mainClass = $this->layout->bs_mainClass;
break;
default:
$this->useGrid = false;
return;
}
$this->useGrid = true;
}
|
[
"private",
"function",
"initialize",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isBootstrapLayout",
"(",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"layout",
"->",
"cols",
")",
"{",
"case",
"'2cll'",
":",
"$",
"this",
"->",
"leftClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_leftClass",
";",
"$",
"this",
"->",
"mainClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_mainClass",
";",
"break",
";",
"case",
"'2clr'",
":",
"$",
"this",
"->",
"rightClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_rightClass",
";",
"$",
"this",
"->",
"mainClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_mainClass",
";",
"break",
";",
"case",
"'3cl'",
":",
"$",
"this",
"->",
"leftClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_leftClass",
";",
"$",
"this",
"->",
"rightClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_rightClass",
";",
"$",
"this",
"->",
"mainClass",
"=",
"$",
"this",
"->",
"layout",
"->",
"bs_mainClass",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"useGrid",
"=",
"false",
";",
"return",
";",
"}",
"$",
"this",
"->",
"useGrid",
"=",
"true",
";",
"}"
] |
Initialize the helper.
@return void
|
[
"Initialize",
"the",
"helper",
"."
] |
9871809d7ed82f8c17c3f84f5944b9291620aad3
|
https://github.com/contao-bootstrap/layout/blob/9871809d7ed82f8c17c3f84f5944b9291620aad3/src/Helper/LayoutHelper.php#L172-L202
|
227,729
|
contao-bootstrap/layout
|
src/Helper/LayoutHelper.php
|
LayoutHelper.addSchemaAttributes
|
private function addSchemaAttributes(string $sectionId, bool $inside, Attributes $attributes): void
{
if ($inside) {
return;
}
switch ($sectionId) {
case static::MAIN:
$attributes->setAttribute('itemscope', true);
$attributes->setAttribute('itemtype', 'http://schema.org/WebPageElement');
$attributes->setAttribute('itemprop', 'mainContentOfPage');
break;
case static::HEADER:
$attributes->setAttribute('itemscope', true);
$attributes->setAttribute('itemtype', 'http://schema.org/WPHeader');
break;
default:
// Do nothing.
}
}
|
php
|
private function addSchemaAttributes(string $sectionId, bool $inside, Attributes $attributes): void
{
if ($inside) {
return;
}
switch ($sectionId) {
case static::MAIN:
$attributes->setAttribute('itemscope', true);
$attributes->setAttribute('itemtype', 'http://schema.org/WebPageElement');
$attributes->setAttribute('itemprop', 'mainContentOfPage');
break;
case static::HEADER:
$attributes->setAttribute('itemscope', true);
$attributes->setAttribute('itemtype', 'http://schema.org/WPHeader');
break;
default:
// Do nothing.
}
}
|
[
"private",
"function",
"addSchemaAttributes",
"(",
"string",
"$",
"sectionId",
",",
"bool",
"$",
"inside",
",",
"Attributes",
"$",
"attributes",
")",
":",
"void",
"{",
"if",
"(",
"$",
"inside",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"$",
"sectionId",
")",
"{",
"case",
"static",
"::",
"MAIN",
":",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'itemscope'",
",",
"true",
")",
";",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'itemtype'",
",",
"'http://schema.org/WebPageElement'",
")",
";",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'itemprop'",
",",
"'mainContentOfPage'",
")",
";",
"break",
";",
"case",
"static",
"::",
"HEADER",
":",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'itemscope'",
",",
"true",
")",
";",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'itemtype'",
",",
"'http://schema.org/WPHeader'",
")",
";",
"break",
";",
"default",
":",
"// Do nothing.",
"}",
"}"
] |
Add the schema attributes.
@param string $sectionId Section id.
@param bool $inside If true no schema attributes are added.
@param Attributes $attributes Section attributes.
@return void
|
[
"Add",
"the",
"schema",
"attributes",
"."
] |
9871809d7ed82f8c17c3f84f5944b9291620aad3
|
https://github.com/contao-bootstrap/layout/blob/9871809d7ed82f8c17c3f84f5944b9291620aad3/src/Helper/LayoutHelper.php#L213-L234
|
227,730
|
Bubelbub/SmartHome-PHP
|
Request/SetActuatorStatesRequest.php
|
SetActuatorStatesRequest.addRoomTemperatureActuatorState
|
public function addRoomTemperatureActuatorState($logicalDeviceId, $pointTemperature, $mode)
{
if((int) $pointTemperature < 6) { $pointTemperature = 6; }
if((int) $pointTemperature > 30) { $pointTemperature = 30; }
if(!preg_match('#^[0-9]+(\.[05]+)?$#i', $pointTemperature))
{
throw new \Exception('The parameter "PointTemperature" should be a value like "6.0" "6.5" "12" "12.5" ..."');
}
$logicalDeviceState = $this->actuatorStates->addChild('LogicalDeviceState');
$logicalDeviceState->addAttribute('xmlns:xsi:type', 'RoomTemperatureActuatorState');
$logicalDeviceState->addAttribute('LID', $logicalDeviceId);
$logicalDeviceState->addAttribute('PtTmp', $pointTemperature);
$logicalDeviceState->addAttribute('OpnMd', ucfirst(strtolower($mode)));
$logicalDeviceState->addAttribute('WRAc', 'false');
}
|
php
|
public function addRoomTemperatureActuatorState($logicalDeviceId, $pointTemperature, $mode)
{
if((int) $pointTemperature < 6) { $pointTemperature = 6; }
if((int) $pointTemperature > 30) { $pointTemperature = 30; }
if(!preg_match('#^[0-9]+(\.[05]+)?$#i', $pointTemperature))
{
throw new \Exception('The parameter "PointTemperature" should be a value like "6.0" "6.5" "12" "12.5" ..."');
}
$logicalDeviceState = $this->actuatorStates->addChild('LogicalDeviceState');
$logicalDeviceState->addAttribute('xmlns:xsi:type', 'RoomTemperatureActuatorState');
$logicalDeviceState->addAttribute('LID', $logicalDeviceId);
$logicalDeviceState->addAttribute('PtTmp', $pointTemperature);
$logicalDeviceState->addAttribute('OpnMd', ucfirst(strtolower($mode)));
$logicalDeviceState->addAttribute('WRAc', 'false');
}
|
[
"public",
"function",
"addRoomTemperatureActuatorState",
"(",
"$",
"logicalDeviceId",
",",
"$",
"pointTemperature",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"pointTemperature",
"<",
"6",
")",
"{",
"$",
"pointTemperature",
"=",
"6",
";",
"}",
"if",
"(",
"(",
"int",
")",
"$",
"pointTemperature",
">",
"30",
")",
"{",
"$",
"pointTemperature",
"=",
"30",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'#^[0-9]+(\\.[05]+)?$#i'",
",",
"$",
"pointTemperature",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The parameter \"PointTemperature\" should be a value like \"6.0\" \"6.5\" \"12\" \"12.5\" ...\"'",
")",
";",
"}",
"$",
"logicalDeviceState",
"=",
"$",
"this",
"->",
"actuatorStates",
"->",
"addChild",
"(",
"'LogicalDeviceState'",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'xmlns:xsi:type'",
",",
"'RoomTemperatureActuatorState'",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'LID'",
",",
"$",
"logicalDeviceId",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'PtTmp'",
",",
"$",
"pointTemperature",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'OpnMd'",
",",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"mode",
")",
")",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'WRAc'",
",",
"'false'",
")",
";",
"}"
] |
Sets the temperature and mode for heaters
@param string $logicalDeviceId the logical device id
@param string|float $pointTemperature the temperature to set
@param string $mode the mode of temperature actuator (Auto|Manu)
|
[
"Sets",
"the",
"temperature",
"and",
"mode",
"for",
"heaters"
] |
fccde832d00ff4ede0497774bd17432bfbf8e390
|
https://github.com/Bubelbub/SmartHome-PHP/blob/fccde832d00ff4ede0497774bd17432bfbf8e390/Request/SetActuatorStatesRequest.php#L58-L73
|
227,731
|
Bubelbub/SmartHome-PHP
|
Request/SetActuatorStatesRequest.php
|
SetActuatorStatesRequest.addRollerShutter
|
public function addRollerShutter($logicalDeviceId, $shutterLevel)
{
$logicalDeviceState = $this->actuatorStates->addChild('LogicalDeviceState');
$logicalDeviceState->addAttribute('xmlns:xsi:type', 'RollerShutterActuatorState');
$logicalDeviceState->addAttribute('LID', $logicalDeviceId);
$logicalDeviceState->addChild('ShutterLevel', $shutterLevel);
}
|
php
|
public function addRollerShutter($logicalDeviceId, $shutterLevel)
{
$logicalDeviceState = $this->actuatorStates->addChild('LogicalDeviceState');
$logicalDeviceState->addAttribute('xmlns:xsi:type', 'RollerShutterActuatorState');
$logicalDeviceState->addAttribute('LID', $logicalDeviceId);
$logicalDeviceState->addChild('ShutterLevel', $shutterLevel);
}
|
[
"public",
"function",
"addRollerShutter",
"(",
"$",
"logicalDeviceId",
",",
"$",
"shutterLevel",
")",
"{",
"$",
"logicalDeviceState",
"=",
"$",
"this",
"->",
"actuatorStates",
"->",
"addChild",
"(",
"'LogicalDeviceState'",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'xmlns:xsi:type'",
",",
"'RollerShutterActuatorState'",
")",
";",
"$",
"logicalDeviceState",
"->",
"addAttribute",
"(",
"'LID'",
",",
"$",
"logicalDeviceId",
")",
";",
"$",
"logicalDeviceState",
"->",
"addChild",
"(",
"'ShutterLevel'",
",",
"$",
"shutterLevel",
")",
";",
"}"
] |
Set the shutter level of shutters
@param string $logicalDeviceId the logical device id
@param integer $shutterLevel the new shutter level of the device in percent (0 - 100)
|
[
"Set",
"the",
"shutter",
"level",
"of",
"shutters"
] |
fccde832d00ff4ede0497774bd17432bfbf8e390
|
https://github.com/Bubelbub/SmartHome-PHP/blob/fccde832d00ff4ede0497774bd17432bfbf8e390/Request/SetActuatorStatesRequest.php#L114-L120
|
227,732
|
pagekit/razr
|
src/Engine.php
|
Engine.getDirective
|
public function getDirective($name)
{
if (!$this->initialized) {
$this->initialize();
}
return isset($this->directives[$name]) ? $this->directives[$name] : null;
}
|
php
|
public function getDirective($name)
{
if (!$this->initialized) {
$this->initialize();
}
return isset($this->directives[$name]) ? $this->directives[$name] : null;
}
|
[
"public",
"function",
"getDirective",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"initialized",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"directives",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"directives",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Gets a directives.
@param string $name
@return Directive
|
[
"Gets",
"a",
"directives",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L124-L131
|
227,733
|
pagekit/razr
|
src/Engine.php
|
Engine.addDirective
|
public function addDirective(DirectiveInterface $directive)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add directive "%s" as they have already been initialized.', $directive->getName()));
}
$directive->setEngine($this);
$this->directives[$directive->getName()] = $directive;
}
|
php
|
public function addDirective(DirectiveInterface $directive)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add directive "%s" as they have already been initialized.', $directive->getName()));
}
$directive->setEngine($this);
$this->directives[$directive->getName()] = $directive;
}
|
[
"public",
"function",
"addDirective",
"(",
"DirectiveInterface",
"$",
"directive",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to add directive \"%s\" as they have already been initialized.'",
",",
"$",
"directive",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"directive",
"->",
"setEngine",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"directives",
"[",
"$",
"directive",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"directive",
";",
"}"
] |
Adds a directive.
@param DirectiveInterface $directive
@throws Exception\RuntimeException
|
[
"Adds",
"a",
"directive",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L153-L162
|
227,734
|
pagekit/razr
|
src/Engine.php
|
Engine.getFunction
|
public function getFunction($name)
{
if (!$this->initialized) {
$this->initialize();
}
return isset($this->functions[$name]) ? $this->functions[$name] : null;
}
|
php
|
public function getFunction($name)
{
if (!$this->initialized) {
$this->initialize();
}
return isset($this->functions[$name]) ? $this->functions[$name] : null;
}
|
[
"public",
"function",
"getFunction",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"initialized",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"functions",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"functions",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Gets a function.
@param string $name
@return callable
|
[
"Gets",
"a",
"function",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L170-L177
|
227,735
|
pagekit/razr
|
src/Engine.php
|
Engine.addFunction
|
public function addFunction($name, $function)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add function "%s" as they have already been initialized.', $name));
}
$this->functions[$name] = $function;
}
|
php
|
public function addFunction($name, $function)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add function "%s" as they have already been initialized.', $name));
}
$this->functions[$name] = $function;
}
|
[
"public",
"function",
"addFunction",
"(",
"$",
"name",
",",
"$",
"function",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to add function \"%s\" as they have already been initialized.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"functions",
"[",
"$",
"name",
"]",
"=",
"$",
"function",
";",
"}"
] |
Adds a function.
@param string $name
@param callable $function
@throws RuntimeException
|
[
"Adds",
"a",
"function",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L200-L207
|
227,736
|
pagekit/razr
|
src/Engine.php
|
Engine.addExtension
|
public function addExtension(ExtensionInterface $extension)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add extension "%s" as they have already been initialized.', $extension->getName()));
}
$this->extensions[$extension->getName()] = $extension;
}
|
php
|
public function addExtension(ExtensionInterface $extension)
{
if ($this->initialized) {
throw new RuntimeException(sprintf('Unable to add extension "%s" as they have already been initialized.', $extension->getName()));
}
$this->extensions[$extension->getName()] = $extension;
}
|
[
"public",
"function",
"addExtension",
"(",
"ExtensionInterface",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to add extension \"%s\" as they have already been initialized.'",
",",
"$",
"extension",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"extensions",
"[",
"$",
"extension",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"extension",
";",
"}"
] |
Adds an extension.
@param ExtensionInterface $extension
@throws Exception\RuntimeException
|
[
"Adds",
"an",
"extension",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L236-L243
|
227,737
|
pagekit/razr
|
src/Engine.php
|
Engine.getAttribute
|
public function getAttribute($object, $name, array $args = array(), $type = self::ANY_CALL)
{
// array
if ($type == self::ANY_CALL || $type == self::ARRAY_CALL) {
$key = is_bool($name) || is_float($name) ? (int) $name : $name;
if ((is_array($object) && array_key_exists($key, $object)) || ($object instanceof \ArrayAccess && isset($object[$key]))) {
return $object[$key];
}
if ($type == self::ARRAY_CALL) {
return null;
}
}
// object
if (!is_object($object)) {
return null;
}
// property
if ($type == self::ANY_CALL && isset($object->$name)) {
return $object->$name;
}
// method
$call = false;
$name = (string) $name;
$item = strtolower($name);
$class = get_class($object);
if (!isset(self::$classes[$class])) {
self::$classes[$class] = array_change_key_case(array_flip(get_class_methods($object)));
}
if (!isset(self::$classes[$class][$item])) {
if (isset(self::$classes[$class]["get$item"])) {
$name = "get$name";
} elseif (isset(self::$classes[$class]["is$item"])) {
$name = "is$name";
} elseif (isset(self::$classes[$class]["__call"])) {
$call = true;
} else {
return null;
}
}
try {
return call_user_func_array(array($object, $name), $args);
} catch (\BadMethodCallException $e) {
if (!$call) throw $e;
}
}
|
php
|
public function getAttribute($object, $name, array $args = array(), $type = self::ANY_CALL)
{
// array
if ($type == self::ANY_CALL || $type == self::ARRAY_CALL) {
$key = is_bool($name) || is_float($name) ? (int) $name : $name;
if ((is_array($object) && array_key_exists($key, $object)) || ($object instanceof \ArrayAccess && isset($object[$key]))) {
return $object[$key];
}
if ($type == self::ARRAY_CALL) {
return null;
}
}
// object
if (!is_object($object)) {
return null;
}
// property
if ($type == self::ANY_CALL && isset($object->$name)) {
return $object->$name;
}
// method
$call = false;
$name = (string) $name;
$item = strtolower($name);
$class = get_class($object);
if (!isset(self::$classes[$class])) {
self::$classes[$class] = array_change_key_case(array_flip(get_class_methods($object)));
}
if (!isset(self::$classes[$class][$item])) {
if (isset(self::$classes[$class]["get$item"])) {
$name = "get$name";
} elseif (isset(self::$classes[$class]["is$item"])) {
$name = "is$name";
} elseif (isset(self::$classes[$class]["__call"])) {
$call = true;
} else {
return null;
}
}
try {
return call_user_func_array(array($object, $name), $args);
} catch (\BadMethodCallException $e) {
if (!$call) throw $e;
}
}
|
[
"public",
"function",
"getAttribute",
"(",
"$",
"object",
",",
"$",
"name",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
",",
"$",
"type",
"=",
"self",
"::",
"ANY_CALL",
")",
"{",
"// array",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"ANY_CALL",
"||",
"$",
"type",
"==",
"self",
"::",
"ARRAY_CALL",
")",
"{",
"$",
"key",
"=",
"is_bool",
"(",
"$",
"name",
")",
"||",
"is_float",
"(",
"$",
"name",
")",
"?",
"(",
"int",
")",
"$",
"name",
":",
"$",
"name",
";",
"if",
"(",
"(",
"is_array",
"(",
"$",
"object",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"object",
")",
")",
"||",
"(",
"$",
"object",
"instanceof",
"\\",
"ArrayAccess",
"&&",
"isset",
"(",
"$",
"object",
"[",
"$",
"key",
"]",
")",
")",
")",
"{",
"return",
"$",
"object",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"ARRAY_CALL",
")",
"{",
"return",
"null",
";",
"}",
"}",
"// object",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"return",
"null",
";",
"}",
"// property",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"ANY_CALL",
"&&",
"isset",
"(",
"$",
"object",
"->",
"$",
"name",
")",
")",
"{",
"return",
"$",
"object",
"->",
"$",
"name",
";",
"}",
"// method",
"$",
"call",
"=",
"false",
";",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"$",
"item",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
")",
")",
"{",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
"=",
"array_change_key_case",
"(",
"array_flip",
"(",
"get_class_methods",
"(",
"$",
"object",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
"[",
"$",
"item",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
"[",
"\"get$item\"",
"]",
")",
")",
"{",
"$",
"name",
"=",
"\"get$name\"",
";",
"}",
"elseif",
"(",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
"[",
"\"is$item\"",
"]",
")",
")",
"{",
"$",
"name",
"=",
"\"is$name\"",
";",
"}",
"elseif",
"(",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"class",
"]",
"[",
"\"__call\"",
"]",
")",
")",
"{",
"$",
"call",
"=",
"true",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"try",
"{",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"object",
",",
"$",
"name",
")",
",",
"$",
"args",
")",
";",
"}",
"catch",
"(",
"\\",
"BadMethodCallException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"call",
")",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Gets an attribute value from an array or object.
@param mixed $object
@param mixed $name
@param array $args
@param string $type
@throws \BadMethodCallException
@throws \Exception
@return mixed
|
[
"Gets",
"an",
"attribute",
"value",
"from",
"an",
"array",
"or",
"object",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L256-L309
|
227,738
|
pagekit/razr
|
src/Engine.php
|
Engine.escape
|
public function escape($value)
{
if (is_numeric($value)) {
return $value;
}
return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) : $value;
}
|
php
|
public function escape($value)
{
if (is_numeric($value)) {
return $value;
}
return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) : $value;
}
|
[
"public",
"function",
"escape",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"is_string",
"(",
"$",
"value",
")",
"?",
"htmlspecialchars",
"(",
"$",
"value",
",",
"ENT_QUOTES",
"|",
"ENT_SUBSTITUTE",
",",
"$",
"this",
"->",
"charset",
",",
"false",
")",
":",
"$",
"value",
";",
"}"
] |
Escapes a html entities in a string.
@param mixed $value
@return string
|
[
"Escapes",
"a",
"html",
"entities",
"in",
"a",
"string",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L339-L346
|
227,739
|
pagekit/razr
|
src/Engine.php
|
Engine.compile
|
protected function compile($source, $filename = null)
{
$tokens = $this->lexer->tokenize($source, $filename);
$source = $this->parser->parse($tokens, $filename);
return $source;
}
|
php
|
protected function compile($source, $filename = null)
{
$tokens = $this->lexer->tokenize($source, $filename);
$source = $this->parser->parse($tokens, $filename);
return $source;
}
|
[
"protected",
"function",
"compile",
"(",
"$",
"source",
",",
"$",
"filename",
"=",
"null",
")",
"{",
"$",
"tokens",
"=",
"$",
"this",
"->",
"lexer",
"->",
"tokenize",
"(",
"$",
"source",
",",
"$",
"filename",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"tokens",
",",
"$",
"filename",
")",
";",
"return",
"$",
"source",
";",
"}"
] |
Compiles a template.
@param string $source
@param string $filename
@return string
|
[
"Compiles",
"a",
"template",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L418-L424
|
227,740
|
pagekit/razr
|
src/Engine.php
|
Engine.initialize
|
protected function initialize()
{
foreach ($this->extensions as $extension) {
$extension->initialize($this);
}
$this->initialized = true;
}
|
php
|
protected function initialize()
{
foreach ($this->extensions as $extension) {
$extension->initialize($this);
}
$this->initialized = true;
}
|
[
"protected",
"function",
"initialize",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"extensions",
"as",
"$",
"extension",
")",
"{",
"$",
"extension",
"->",
"initialize",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"initialized",
"=",
"true",
";",
"}"
] |
Initializes the extensions.
@return void
|
[
"Initializes",
"the",
"extensions",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L467-L474
|
227,741
|
pagekit/razr
|
src/Engine.php
|
Engine.writeCacheFile
|
protected function writeCacheFile($file, $content)
{
$dir = dirname($file);
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new RuntimeException("Unable to create the cache directory ($dir).");
}
} elseif (!is_writable($dir)) {
throw new RuntimeException("Unable to write in the cache directory ($dir).");
}
if (!file_put_contents($file, $content)) {
throw new RuntimeException("Failed to write cache file ($file).");
}
}
|
php
|
protected function writeCacheFile($file, $content)
{
$dir = dirname($file);
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new RuntimeException("Unable to create the cache directory ($dir).");
}
} elseif (!is_writable($dir)) {
throw new RuntimeException("Unable to write in the cache directory ($dir).");
}
if (!file_put_contents($file, $content)) {
throw new RuntimeException("Failed to write cache file ($file).");
}
}
|
[
"protected",
"function",
"writeCacheFile",
"(",
"$",
"file",
",",
"$",
"content",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
"&&",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to create the cache directory ($dir).\"",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"is_writable",
"(",
"$",
"dir",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to write in the cache directory ($dir).\"",
")",
";",
"}",
"if",
"(",
"!",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"content",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to write cache file ($file).\"",
")",
";",
"}",
"}"
] |
Writes cache file
@param string $file
@param string $content
@throws RuntimeException
|
[
"Writes",
"cache",
"file"
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Engine.php#L483-L498
|
227,742
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Hiero.php
|
Hiero.setLanguage
|
public function setLanguage($value)
{
$value = strtolower($value);
if ($value == 'hiero' || $value == 'phoenician') {
$this->_language = $value;
}
return $this;
}
|
php
|
public function setLanguage($value)
{
$value = strtolower($value);
if ($value == 'hiero' || $value == 'phoenician') {
$this->_language = $value;
}
return $this;
}
|
[
"public",
"function",
"setLanguage",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"==",
"'hiero'",
"||",
"$",
"value",
"==",
"'phoenician'",
")",
"{",
"$",
"this",
"->",
"_language",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the output language
@param string $value Output language (Hiero or Phoenician)
@return object $this to build a fluent interface
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Set",
"the",
"output",
"language"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Hiero.php#L115-L124
|
227,743
|
contao-bootstrap/layout
|
src/Listener/Hook/PageTemplateListener.php
|
PageTemplateListener.onParseTemplate
|
public function onParseTemplate(Template $template): void
{
if (strpos($template->getName(), 'fe_') !== 0) {
return;
}
$template->bootstrapEnvironment = $this->environment;
}
|
php
|
public function onParseTemplate(Template $template): void
{
if (strpos($template->getName(), 'fe_') !== 0) {
return;
}
$template->bootstrapEnvironment = $this->environment;
}
|
[
"public",
"function",
"onParseTemplate",
"(",
"Template",
"$",
"template",
")",
":",
"void",
"{",
"if",
"(",
"strpos",
"(",
"$",
"template",
"->",
"getName",
"(",
")",
",",
"'fe_'",
")",
"!==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"template",
"->",
"bootstrapEnvironment",
"=",
"$",
"this",
"->",
"environment",
";",
"}"
] |
Handle the parse template hook.
@param Template $template The template being parsed.
@return void
|
[
"Handle",
"the",
"parse",
"template",
"hook",
"."
] |
9871809d7ed82f8c17c3f84f5944b9291620aad3
|
https://github.com/contao-bootstrap/layout/blob/9871809d7ed82f8c17c3f84f5944b9291620aad3/src/Listener/Hook/PageTemplateListener.php#L49-L56
|
227,744
|
Vinelab/api-manager
|
src/Vinelab/Api/ResponseHandler.php
|
ResponseHandler.respond
|
public function respond(
array $data,
$total = null,
$page = null,
$per_page = null,
$status = 200,
$headers = [],
$options = 0
) {
$response = [
'status' => $status,
];
if (!is_null($total)) {
$response['total'] = $total;
}
if (!is_null($page)) {
$response['page'] = $page;
}
if (!is_null($per_page)) {
$response['per_page'] = $per_page;
}
$response['data'] = $data;
return $this->responder->respond($response, $status, $headers, $options);
}
|
php
|
public function respond(
array $data,
$total = null,
$page = null,
$per_page = null,
$status = 200,
$headers = [],
$options = 0
) {
$response = [
'status' => $status,
];
if (!is_null($total)) {
$response['total'] = $total;
}
if (!is_null($page)) {
$response['page'] = $page;
}
if (!is_null($per_page)) {
$response['per_page'] = $per_page;
}
$response['data'] = $data;
return $this->responder->respond($response, $status, $headers, $options);
}
|
[
"public",
"function",
"respond",
"(",
"array",
"$",
"data",
",",
"$",
"total",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
",",
"$",
"status",
"=",
"200",
",",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"response",
"=",
"[",
"'status'",
"=>",
"$",
"status",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"total",
")",
")",
"{",
"$",
"response",
"[",
"'total'",
"]",
"=",
"$",
"total",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"page",
")",
")",
"{",
"$",
"response",
"[",
"'page'",
"]",
"=",
"$",
"page",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"per_page",
")",
")",
"{",
"$",
"response",
"[",
"'per_page'",
"]",
"=",
"$",
"per_page",
";",
"}",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"data",
";",
"return",
"$",
"this",
"->",
"responder",
"->",
"respond",
"(",
"$",
"response",
",",
"$",
"status",
",",
"$",
"headers",
",",
"$",
"options",
")",
";",
"}"
] |
Format a response into an elegant api manager response.
@param array $data
@param null $total
@param null $page
@param null $per_page
@param int $status
@param array $headers
@param int $options
@internal param $arguments
@return \Illuminate\Http\JsonResponse
|
[
"Format",
"a",
"response",
"into",
"an",
"elegant",
"api",
"manager",
"response",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/ResponseHandler.php#L39-L63
|
227,745
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Transliteration.php
|
Transliteration.en2ar
|
public static function en2ar($string, $locale='en_US')
{
// setlocale(LC_ALL, $locale);
$string = iconv("UTF-8", "ASCII//TRANSLIT", $string);
$string = preg_replace('/[^\w\s]/', '', $string);
$string = strtolower($string);
$words = explode(' ', $string);
$string = '';
foreach ($words as $word) {
$word = preg_replace(
self::$_en2arPregSearch,
self::$_en2arPregReplace, $word
);
$word = str_replace(
self::$_en2arStrSearch,
self::$_en2arStrReplace,
$word
);
$string .= ' ' . $word;
}
return $string;
}
|
php
|
public static function en2ar($string, $locale='en_US')
{
// setlocale(LC_ALL, $locale);
$string = iconv("UTF-8", "ASCII//TRANSLIT", $string);
$string = preg_replace('/[^\w\s]/', '', $string);
$string = strtolower($string);
$words = explode(' ', $string);
$string = '';
foreach ($words as $word) {
$word = preg_replace(
self::$_en2arPregSearch,
self::$_en2arPregReplace, $word
);
$word = str_replace(
self::$_en2arStrSearch,
self::$_en2arStrReplace,
$word
);
$string .= ' ' . $word;
}
return $string;
}
|
[
"public",
"static",
"function",
"en2ar",
"(",
"$",
"string",
",",
"$",
"locale",
"=",
"'en_US'",
")",
"{",
"// setlocale(LC_ALL, $locale);",
"$",
"string",
"=",
"iconv",
"(",
"\"UTF-8\"",
",",
"\"ASCII//TRANSLIT\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/[^\\w\\s]/'",
",",
"''",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"strtolower",
"(",
"$",
"string",
")",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"''",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"$",
"word",
"=",
"preg_replace",
"(",
"self",
"::",
"$",
"_en2arPregSearch",
",",
"self",
"::",
"$",
"_en2arPregReplace",
",",
"$",
"word",
")",
";",
"$",
"word",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"_en2arStrSearch",
",",
"self",
"::",
"$",
"_en2arStrReplace",
",",
"$",
"word",
")",
";",
"$",
"string",
".=",
"' '",
".",
"$",
"word",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Transliterate English string into Arabic by render them in the
orthography of the Arabic language
@param string $string English string you want to transliterate
@param string $locale Locale information (e.g. 'en_GB' or 'de_DE')
@return String Out of vocabulary English string in Arabic characters
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Transliterate",
"English",
"string",
"into",
"Arabic",
"by",
"render",
"them",
"in",
"the",
"orthography",
"of",
"the",
"Arabic",
"language"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Transliteration.php#L187-L212
|
227,746
|
pagekit/razr
|
src/Lexer.php
|
Lexer.tokenize
|
public function tokenize($code, $filename = null)
{
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$encoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
$this->code = str_replace(array("\r\n", "\r"), "\n", $code);
$this->source = '';
$this->filename = $filename;
$this->cursor = 0;
$this->lineno = 1;
$this->end = strlen($this->code);
$this->tokens = array();
$this->state = self::STATE_DATA;
$this->states = array();
$this->brackets = array();
$this->position = -1;
preg_match_all(self::REGEX_CHAR, $this->code, $this->positions, PREG_OFFSET_CAPTURE);
while ($this->cursor < $this->end) {
switch ($this->state) {
case self::STATE_DATA:
$this->lexData();
break;
case self::STATE_OUTPUT:
$this->lexOutput();
break;
case self::STATE_DIRECTIVE:
$this->lexDirective();
break;
}
}
if ($this->state != self::STATE_DATA) {
$this->addCode(' ?>');
$this->popState();
}
if (!empty($this->brackets)) {
list($expect, $lineno) = array_pop($this->brackets);
throw new SyntaxErrorException(sprintf('Unclosed "%s" at line %d in file %s', $expect, $lineno, $this->filename));
}
if (isset($encoding)) {
mb_internal_encoding($encoding);
}
return new TokenStream(token_get_all($this->source));
}
|
php
|
public function tokenize($code, $filename = null)
{
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$encoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
$this->code = str_replace(array("\r\n", "\r"), "\n", $code);
$this->source = '';
$this->filename = $filename;
$this->cursor = 0;
$this->lineno = 1;
$this->end = strlen($this->code);
$this->tokens = array();
$this->state = self::STATE_DATA;
$this->states = array();
$this->brackets = array();
$this->position = -1;
preg_match_all(self::REGEX_CHAR, $this->code, $this->positions, PREG_OFFSET_CAPTURE);
while ($this->cursor < $this->end) {
switch ($this->state) {
case self::STATE_DATA:
$this->lexData();
break;
case self::STATE_OUTPUT:
$this->lexOutput();
break;
case self::STATE_DIRECTIVE:
$this->lexDirective();
break;
}
}
if ($this->state != self::STATE_DATA) {
$this->addCode(' ?>');
$this->popState();
}
if (!empty($this->brackets)) {
list($expect, $lineno) = array_pop($this->brackets);
throw new SyntaxErrorException(sprintf('Unclosed "%s" at line %d in file %s', $expect, $lineno, $this->filename));
}
if (isset($encoding)) {
mb_internal_encoding($encoding);
}
return new TokenStream(token_get_all($this->source));
}
|
[
"public",
"function",
"tokenize",
"(",
"$",
"code",
",",
"$",
"filename",
"=",
"null",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_internal_encoding'",
")",
"&&",
"(",
"(",
"int",
")",
"ini_get",
"(",
"'mbstring.func_overload'",
")",
")",
"&",
"2",
")",
"{",
"$",
"encoding",
"=",
"mb_internal_encoding",
"(",
")",
";",
"mb_internal_encoding",
"(",
"'ASCII'",
")",
";",
"}",
"$",
"this",
"->",
"code",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\\n\"",
",",
"$",
"code",
")",
";",
"$",
"this",
"->",
"source",
"=",
"''",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"filename",
";",
"$",
"this",
"->",
"cursor",
"=",
"0",
";",
"$",
"this",
"->",
"lineno",
"=",
"1",
";",
"$",
"this",
"->",
"end",
"=",
"strlen",
"(",
"$",
"this",
"->",
"code",
")",
";",
"$",
"this",
"->",
"tokens",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_DATA",
";",
"$",
"this",
"->",
"states",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"brackets",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"position",
"=",
"-",
"1",
";",
"preg_match_all",
"(",
"self",
"::",
"REGEX_CHAR",
",",
"$",
"this",
"->",
"code",
",",
"$",
"this",
"->",
"positions",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"while",
"(",
"$",
"this",
"->",
"cursor",
"<",
"$",
"this",
"->",
"end",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"state",
")",
"{",
"case",
"self",
"::",
"STATE_DATA",
":",
"$",
"this",
"->",
"lexData",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"STATE_OUTPUT",
":",
"$",
"this",
"->",
"lexOutput",
"(",
")",
";",
"break",
";",
"case",
"self",
"::",
"STATE_DIRECTIVE",
":",
"$",
"this",
"->",
"lexDirective",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"state",
"!=",
"self",
"::",
"STATE_DATA",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"' ?>'",
")",
";",
"$",
"this",
"->",
"popState",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"brackets",
")",
")",
"{",
"list",
"(",
"$",
"expect",
",",
"$",
"lineno",
")",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"brackets",
")",
";",
"throw",
"new",
"SyntaxErrorException",
"(",
"sprintf",
"(",
"'Unclosed \"%s\" at line %d in file %s'",
",",
"$",
"expect",
",",
"$",
"lineno",
",",
"$",
"this",
"->",
"filename",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"encoding",
")",
")",
"{",
"mb_internal_encoding",
"(",
"$",
"encoding",
")",
";",
"}",
"return",
"new",
"TokenStream",
"(",
"token_get_all",
"(",
"$",
"this",
"->",
"source",
")",
")",
";",
"}"
] |
Gets the token stream from a template.
@param string $code
@param string $filename
@throws SyntaxErrorException
@return TokenStream
|
[
"Gets",
"the",
"token",
"stream",
"from",
"a",
"template",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L49-L101
|
227,747
|
pagekit/razr
|
src/Lexer.php
|
Lexer.lexData
|
protected function lexData()
{
if ($this->position == count($this->positions[0]) - 1) {
$this->addCode(substr($this->code, $this->cursor));
$this->cursor = $this->end;
return;
}
$position = $this->positions[0][++$this->position];
while ($position[1] < $this->cursor) {
if ($this->position == count($this->positions[0]) - 1) {
return;
}
$position = $this->positions[0][++$this->position];
}
$this->addCode($text = substr($this->code, $this->cursor, $position[1] - $this->cursor));
$this->moveCursor($text);
$this->cursor++;
if (preg_match(self::REGEX_START, $this->code, $match, null, $this->cursor)) {
if (isset($match[1])) {
$this->addCode('<?php /* DIRECTIVE */');
$this->pushState(self::STATE_DIRECTIVE);
$this->addCode($match[1]);
$this->moveCursor($match[1]);
if (isset($match[2])) {
$this->moveCursor(rtrim($match[2], '('));
$this->lexExpression();
}
} else {
$this->addCode('<?php /* OUTPUT */');
$this->pushState(self::STATE_OUTPUT);
$this->lexExpression();
}
}
}
|
php
|
protected function lexData()
{
if ($this->position == count($this->positions[0]) - 1) {
$this->addCode(substr($this->code, $this->cursor));
$this->cursor = $this->end;
return;
}
$position = $this->positions[0][++$this->position];
while ($position[1] < $this->cursor) {
if ($this->position == count($this->positions[0]) - 1) {
return;
}
$position = $this->positions[0][++$this->position];
}
$this->addCode($text = substr($this->code, $this->cursor, $position[1] - $this->cursor));
$this->moveCursor($text);
$this->cursor++;
if (preg_match(self::REGEX_START, $this->code, $match, null, $this->cursor)) {
if (isset($match[1])) {
$this->addCode('<?php /* DIRECTIVE */');
$this->pushState(self::STATE_DIRECTIVE);
$this->addCode($match[1]);
$this->moveCursor($match[1]);
if (isset($match[2])) {
$this->moveCursor(rtrim($match[2], '('));
$this->lexExpression();
}
} else {
$this->addCode('<?php /* OUTPUT */');
$this->pushState(self::STATE_OUTPUT);
$this->lexExpression();
}
}
}
|
[
"protected",
"function",
"lexData",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"position",
"==",
"count",
"(",
"$",
"this",
"->",
"positions",
"[",
"0",
"]",
")",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"substr",
"(",
"$",
"this",
"->",
"code",
",",
"$",
"this",
"->",
"cursor",
")",
")",
";",
"$",
"this",
"->",
"cursor",
"=",
"$",
"this",
"->",
"end",
";",
"return",
";",
"}",
"$",
"position",
"=",
"$",
"this",
"->",
"positions",
"[",
"0",
"]",
"[",
"++",
"$",
"this",
"->",
"position",
"]",
";",
"while",
"(",
"$",
"position",
"[",
"1",
"]",
"<",
"$",
"this",
"->",
"cursor",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"position",
"==",
"count",
"(",
"$",
"this",
"->",
"positions",
"[",
"0",
"]",
")",
"-",
"1",
")",
"{",
"return",
";",
"}",
"$",
"position",
"=",
"$",
"this",
"->",
"positions",
"[",
"0",
"]",
"[",
"++",
"$",
"this",
"->",
"position",
"]",
";",
"}",
"$",
"this",
"->",
"addCode",
"(",
"$",
"text",
"=",
"substr",
"(",
"$",
"this",
"->",
"code",
",",
"$",
"this",
"->",
"cursor",
",",
"$",
"position",
"[",
"1",
"]",
"-",
"$",
"this",
"->",
"cursor",
")",
")",
";",
"$",
"this",
"->",
"moveCursor",
"(",
"$",
"text",
")",
";",
"$",
"this",
"->",
"cursor",
"++",
";",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"REGEX_START",
",",
"$",
"this",
"->",
"code",
",",
"$",
"match",
",",
"null",
",",
"$",
"this",
"->",
"cursor",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"'<?php /* DIRECTIVE */'",
")",
";",
"$",
"this",
"->",
"pushState",
"(",
"self",
"::",
"STATE_DIRECTIVE",
")",
";",
"$",
"this",
"->",
"addCode",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"this",
"->",
"moveCursor",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"2",
"]",
")",
")",
"{",
"$",
"this",
"->",
"moveCursor",
"(",
"rtrim",
"(",
"$",
"match",
"[",
"2",
"]",
",",
"'('",
")",
")",
";",
"$",
"this",
"->",
"lexExpression",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addCode",
"(",
"'<?php /* OUTPUT */'",
")",
";",
"$",
"this",
"->",
"pushState",
"(",
"self",
"::",
"STATE_OUTPUT",
")",
";",
"$",
"this",
"->",
"lexExpression",
"(",
")",
";",
"}",
"}",
"}"
] |
Lex data.
|
[
"Lex",
"data",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L106-L148
|
227,748
|
pagekit/razr
|
src/Lexer.php
|
Lexer.lexOutput
|
protected function lexOutput()
{
if (empty($this->brackets)) {
$this->addCode(' ?>');
$this->popState();
} else {
$this->lexExpression();
}
}
|
php
|
protected function lexOutput()
{
if (empty($this->brackets)) {
$this->addCode(' ?>');
$this->popState();
} else {
$this->lexExpression();
}
}
|
[
"protected",
"function",
"lexOutput",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"brackets",
")",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"' ?>'",
")",
";",
"$",
"this",
"->",
"popState",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"lexExpression",
"(",
")",
";",
"}",
"}"
] |
Lex output.
|
[
"Lex",
"output",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L153-L161
|
227,749
|
pagekit/razr
|
src/Lexer.php
|
Lexer.lexDirective
|
protected function lexDirective()
{
if (empty($this->brackets)) {
$this->addCode(' ?>');
$this->popState();
} else {
$this->lexExpression();
}
}
|
php
|
protected function lexDirective()
{
if (empty($this->brackets)) {
$this->addCode(' ?>');
$this->popState();
} else {
$this->lexExpression();
}
}
|
[
"protected",
"function",
"lexDirective",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"brackets",
")",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"' ?>'",
")",
";",
"$",
"this",
"->",
"popState",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"lexExpression",
"(",
")",
";",
"}",
"}"
] |
Lex directive.
|
[
"Lex",
"directive",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L166-L174
|
227,750
|
pagekit/razr
|
src/Lexer.php
|
Lexer.lexExpression
|
protected function lexExpression()
{
if (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
$this->addCode($match[0]);
$this->moveCursor($match[0]);
}
if (strpos('([{', $this->code[$this->cursor]) !== false) {
$this->brackets[] = array($this->code[$this->cursor], $this->lineno);
} elseif (strpos(')]}', $this->code[$this->cursor]) !== false) {
if (empty($this->brackets)) {
throw new SyntaxErrorException(sprintf('Unexpected "%s" at line %d in file %s', $this->code[$this->cursor], $this->lineno, $this->filename));
}
list($expect, $lineno) = array_pop($this->brackets);
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
throw new SyntaxErrorException(sprintf('Unclosed "%s" at line %d in file %s', $expect, $lineno, $this->filename));
}
}
$this->addCode($this->code[$this->cursor++]);
}
|
php
|
protected function lexExpression()
{
if (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
$this->addCode($match[0]);
$this->moveCursor($match[0]);
}
if (strpos('([{', $this->code[$this->cursor]) !== false) {
$this->brackets[] = array($this->code[$this->cursor], $this->lineno);
} elseif (strpos(')]}', $this->code[$this->cursor]) !== false) {
if (empty($this->brackets)) {
throw new SyntaxErrorException(sprintf('Unexpected "%s" at line %d in file %s', $this->code[$this->cursor], $this->lineno, $this->filename));
}
list($expect, $lineno) = array_pop($this->brackets);
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
throw new SyntaxErrorException(sprintf('Unclosed "%s" at line %d in file %s', $expect, $lineno, $this->filename));
}
}
$this->addCode($this->code[$this->cursor++]);
}
|
[
"protected",
"function",
"lexExpression",
"(",
")",
"{",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"REGEX_STRING",
",",
"$",
"this",
"->",
"code",
",",
"$",
"match",
",",
"null",
",",
"$",
"this",
"->",
"cursor",
")",
")",
"{",
"$",
"this",
"->",
"addCode",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"moveCursor",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"'([{'",
",",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"]",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"brackets",
"[",
"]",
"=",
"array",
"(",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"]",
",",
"$",
"this",
"->",
"lineno",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"')]}'",
",",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"]",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"brackets",
")",
")",
"{",
"throw",
"new",
"SyntaxErrorException",
"(",
"sprintf",
"(",
"'Unexpected \"%s\" at line %d in file %s'",
",",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"]",
",",
"$",
"this",
"->",
"lineno",
",",
"$",
"this",
"->",
"filename",
")",
")",
";",
"}",
"list",
"(",
"$",
"expect",
",",
"$",
"lineno",
")",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"brackets",
")",
";",
"if",
"(",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"]",
"!=",
"strtr",
"(",
"$",
"expect",
",",
"'([{'",
",",
"')]}'",
")",
")",
"{",
"throw",
"new",
"SyntaxErrorException",
"(",
"sprintf",
"(",
"'Unclosed \"%s\" at line %d in file %s'",
",",
"$",
"expect",
",",
"$",
"lineno",
",",
"$",
"this",
"->",
"filename",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"addCode",
"(",
"$",
"this",
"->",
"code",
"[",
"$",
"this",
"->",
"cursor",
"++",
"]",
")",
";",
"}"
] |
Lex expression.
|
[
"Lex",
"expression",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L179-L202
|
227,751
|
pagekit/razr
|
src/Lexer.php
|
Lexer.popState
|
protected function popState()
{
if (count($this->states) === 0) {
throw new RuntimeException('Cannot pop state without a previous state');
}
$this->state = array_pop($this->states);
}
|
php
|
protected function popState()
{
if (count($this->states) === 0) {
throw new RuntimeException('Cannot pop state without a previous state');
}
$this->state = array_pop($this->states);
}
|
[
"protected",
"function",
"popState",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"states",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Cannot pop state without a previous state'",
")",
";",
"}",
"$",
"this",
"->",
"state",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"states",
")",
";",
"}"
] |
Pops the last state off the state stack.
|
[
"Pops",
"the",
"last",
"state",
"off",
"the",
"state",
"stack",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Lexer.php#L239-L246
|
227,752
|
Bubelbub/SmartHome-PHP
|
Request/BaseRequest.php
|
BaseRequest.setResponse
|
private function setResponse($response)
{
$xml = new \SimpleXMLElement('<BaseResponse />');
try
{
$xml = new \SimpleXMLElement($response);
}
catch(\Exception $ex){}
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->response = $xml;
}
|
php
|
private function setResponse($response)
{
$xml = new \SimpleXMLElement('<BaseResponse />');
try
{
$xml = new \SimpleXMLElement($response);
}
catch(\Exception $ex){}
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->response = $xml;
}
|
[
"private",
"function",
"setResponse",
"(",
"$",
"response",
")",
"{",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"'<BaseResponse />'",
")",
";",
"try",
"{",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"}",
"$",
"xml",
"->",
"registerXPathNamespace",
"(",
"'xsi'",
",",
"'http://www.w3.org/2001/XMLSchema-instance'",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"xml",
";",
"}"
] |
Set the last response of an request
@param string $response the response of shc
|
[
"Set",
"the",
"last",
"response",
"of",
"an",
"request"
] |
fccde832d00ff4ede0497774bd17432bfbf8e390
|
https://github.com/Bubelbub/SmartHome-PHP/blob/fccde832d00ff4ede0497774bd17432bfbf8e390/Request/BaseRequest.php#L154-L164
|
227,753
|
slince/smartqq
|
src/Request/PollMessagesRequest.php
|
PollMessagesRequest.parseContents
|
protected static function parseContents($contents)
{
//正文字体
$fontParameters = $contents[0][1];
$font = new Font(
$fontParameters['name'],
$fontParameters['color'],
$fontParameters['size'],
$fontParameters['style']
);
unset($contents[0]);
$contentString = implode('', array_map(function ($content) {
if ($content && is_array($content) && 'face' === $content[0]) { //处理表情
$faceText = Content::searchFaceText($content[1]);
return $faceText ? '['.$faceText.']' : '';
} else {
return (string) $content;
}
}, $contents));
return new Content($contentString, $font);
}
|
php
|
protected static function parseContents($contents)
{
//正文字体
$fontParameters = $contents[0][1];
$font = new Font(
$fontParameters['name'],
$fontParameters['color'],
$fontParameters['size'],
$fontParameters['style']
);
unset($contents[0]);
$contentString = implode('', array_map(function ($content) {
if ($content && is_array($content) && 'face' === $content[0]) { //处理表情
$faceText = Content::searchFaceText($content[1]);
return $faceText ? '['.$faceText.']' : '';
} else {
return (string) $content;
}
}, $contents));
return new Content($contentString, $font);
}
|
[
"protected",
"static",
"function",
"parseContents",
"(",
"$",
"contents",
")",
"{",
"//正文字体",
"$",
"fontParameters",
"=",
"$",
"contents",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"font",
"=",
"new",
"Font",
"(",
"$",
"fontParameters",
"[",
"'name'",
"]",
",",
"$",
"fontParameters",
"[",
"'color'",
"]",
",",
"$",
"fontParameters",
"[",
"'size'",
"]",
",",
"$",
"fontParameters",
"[",
"'style'",
"]",
")",
";",
"unset",
"(",
"$",
"contents",
"[",
"0",
"]",
")",
";",
"$",
"contentString",
"=",
"implode",
"(",
"''",
",",
"array_map",
"(",
"function",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"&&",
"is_array",
"(",
"$",
"content",
")",
"&&",
"'face'",
"===",
"$",
"content",
"[",
"0",
"]",
")",
"{",
"//处理表情",
"$",
"faceText",
"=",
"Content",
"::",
"searchFaceText",
"(",
"$",
"content",
"[",
"1",
"]",
")",
";",
"return",
"$",
"faceText",
"?",
"'['",
".",
"$",
"faceText",
".",
"']'",
":",
"''",
";",
"}",
"else",
"{",
"return",
"(",
"string",
")",
"$",
"content",
";",
"}",
"}",
",",
"$",
"contents",
")",
")",
";",
"return",
"new",
"Content",
"(",
"$",
"contentString",
",",
"$",
"font",
")",
";",
"}"
] |
Parse Contents.
@param array $contents
@return Content
|
[
"Parse",
"Contents",
"."
] |
06ad056d47f2324f81e7118b47cc492529325252
|
https://github.com/slince/smartqq/blob/06ad056d47f2324f81e7118b47cc492529325252/src/Request/PollMessagesRequest.php#L121-L143
|
227,754
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseAgainCommand.php
|
DatabaseAgainCommand.doAgain
|
protected function doAgain(Migrator $migrator, $group)
{
// retreive installed versions
$installed_migrations = $migrator->installedLatestMigrations();
$installed_version = data_get($installed_migrations, $group.'.version', Migrator::VERSION_NULL);
$definition_versions = $migrator->migrationVersionsByDesc($group);
if (!$this->checkInstalledVersion($installed_version, $definition_versions)) {
return;
}
// remove migration log
$definition_latest_version = array_get(array_keys($definition_versions), 0, Migrator::VERSION_NULL);
if ($migrator->compareMigrationVersion($installed_version, $definition_latest_version) >= 0) {
$this->line("<info>Remove log [$group/$installed_version]</info>");
$migrator->removeMigrationLog($group, $installed_version);
}
// downgrade & upgrade
foreach ($definition_versions as $version => $class) {
$this->infoDowngrade($group, $version, $class);
$migrator->doDowngrade($group, $version, $class);
$this->infoUpgrade($group, $version, $class);
$migrator->doUpgrade($group, $version, $class);
break;
}
}
|
php
|
protected function doAgain(Migrator $migrator, $group)
{
// retreive installed versions
$installed_migrations = $migrator->installedLatestMigrations();
$installed_version = data_get($installed_migrations, $group.'.version', Migrator::VERSION_NULL);
$definition_versions = $migrator->migrationVersionsByDesc($group);
if (!$this->checkInstalledVersion($installed_version, $definition_versions)) {
return;
}
// remove migration log
$definition_latest_version = array_get(array_keys($definition_versions), 0, Migrator::VERSION_NULL);
if ($migrator->compareMigrationVersion($installed_version, $definition_latest_version) >= 0) {
$this->line("<info>Remove log [$group/$installed_version]</info>");
$migrator->removeMigrationLog($group, $installed_version);
}
// downgrade & upgrade
foreach ($definition_versions as $version => $class) {
$this->infoDowngrade($group, $version, $class);
$migrator->doDowngrade($group, $version, $class);
$this->infoUpgrade($group, $version, $class);
$migrator->doUpgrade($group, $version, $class);
break;
}
}
|
[
"protected",
"function",
"doAgain",
"(",
"Migrator",
"$",
"migrator",
",",
"$",
"group",
")",
"{",
"// retreive installed versions",
"$",
"installed_migrations",
"=",
"$",
"migrator",
"->",
"installedLatestMigrations",
"(",
")",
";",
"$",
"installed_version",
"=",
"data_get",
"(",
"$",
"installed_migrations",
",",
"$",
"group",
".",
"'.version'",
",",
"Migrator",
"::",
"VERSION_NULL",
")",
";",
"$",
"definition_versions",
"=",
"$",
"migrator",
"->",
"migrationVersionsByDesc",
"(",
"$",
"group",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"checkInstalledVersion",
"(",
"$",
"installed_version",
",",
"$",
"definition_versions",
")",
")",
"{",
"return",
";",
"}",
"// remove migration log",
"$",
"definition_latest_version",
"=",
"array_get",
"(",
"array_keys",
"(",
"$",
"definition_versions",
")",
",",
"0",
",",
"Migrator",
"::",
"VERSION_NULL",
")",
";",
"if",
"(",
"$",
"migrator",
"->",
"compareMigrationVersion",
"(",
"$",
"installed_version",
",",
"$",
"definition_latest_version",
")",
">=",
"0",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"<info>Remove log [$group/$installed_version]</info>\"",
")",
";",
"$",
"migrator",
"->",
"removeMigrationLog",
"(",
"$",
"group",
",",
"$",
"installed_version",
")",
";",
"}",
"// downgrade & upgrade",
"foreach",
"(",
"$",
"definition_versions",
"as",
"$",
"version",
"=>",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"infoDowngrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"$",
"migrator",
"->",
"doDowngrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"$",
"this",
"->",
"infoUpgrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"$",
"migrator",
"->",
"doUpgrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"break",
";",
"}",
"}"
] |
Execute rollback and upgrade one version.
@param \Jumilla\Versionia\Laravel\Migrator $migrator
@param string $group
|
[
"Execute",
"rollback",
"and",
"upgrade",
"one",
"version",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseAgainCommand.php#L70-L102
|
227,755
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseAgainCommand.php
|
DatabaseAgainCommand.checkInstalledVersion
|
protected function checkInstalledVersion($installed_version, array $definition_versions)
{
if ($installed_version === null) {
$this->error('Nothing installed version.');
$this->line('Please run <comment>database:upgrade<comment>.');
return false;
}
$index = array_search($installed_version, array_keys($definition_versions));
if ($index === false) {
$versions = json_encode(array_keys($definition_versions));
$this->error("Installed version '{$installed_version}' was not found in definition {$versions}.");
return false;
}
if ($index >= 2) {
$this->error("Installed version '$installed_version' was older.");
$this->line('Please run <comment>database:upgrade<comment>.');
return false;
}
return true;
}
|
php
|
protected function checkInstalledVersion($installed_version, array $definition_versions)
{
if ($installed_version === null) {
$this->error('Nothing installed version.');
$this->line('Please run <comment>database:upgrade<comment>.');
return false;
}
$index = array_search($installed_version, array_keys($definition_versions));
if ($index === false) {
$versions = json_encode(array_keys($definition_versions));
$this->error("Installed version '{$installed_version}' was not found in definition {$versions}.");
return false;
}
if ($index >= 2) {
$this->error("Installed version '$installed_version' was older.");
$this->line('Please run <comment>database:upgrade<comment>.');
return false;
}
return true;
}
|
[
"protected",
"function",
"checkInstalledVersion",
"(",
"$",
"installed_version",
",",
"array",
"$",
"definition_versions",
")",
"{",
"if",
"(",
"$",
"installed_version",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Nothing installed version.'",
")",
";",
"$",
"this",
"->",
"line",
"(",
"'Please run <comment>database:upgrade<comment>.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"index",
"=",
"array_search",
"(",
"$",
"installed_version",
",",
"array_keys",
"(",
"$",
"definition_versions",
")",
")",
";",
"if",
"(",
"$",
"index",
"===",
"false",
")",
"{",
"$",
"versions",
"=",
"json_encode",
"(",
"array_keys",
"(",
"$",
"definition_versions",
")",
")",
";",
"$",
"this",
"->",
"error",
"(",
"\"Installed version '{$installed_version}' was not found in definition {$versions}.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"index",
">=",
"2",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"\"Installed version '$installed_version' was older.\"",
")",
";",
"$",
"this",
"->",
"line",
"(",
"'Please run <comment>database:upgrade<comment>.'",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check installed version.
@param string $installed_version
@param array $definition_versions
@return bool
|
[
"Check",
"installed",
"version",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseAgainCommand.php#L112-L138
|
227,756
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.compress
|
public static function compress($str)
{
$str = iconv('utf-8', 'cp1256', $str);
$bits = self::str2bits($str);
$hex = self::bits2hex($bits);
$bin = pack('h*', $hex);
return $bin;
}
|
php
|
public static function compress($str)
{
$str = iconv('utf-8', 'cp1256', $str);
$bits = self::str2bits($str);
$hex = self::bits2hex($bits);
$bin = pack('h*', $hex);
return $bin;
}
|
[
"public",
"static",
"function",
"compress",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"iconv",
"(",
"'utf-8'",
",",
"'cp1256'",
",",
"$",
"str",
")",
";",
"$",
"bits",
"=",
"self",
"::",
"str2bits",
"(",
"$",
"str",
")",
";",
"$",
"hex",
"=",
"self",
"::",
"bits2hex",
"(",
"$",
"bits",
")",
";",
"$",
"bin",
"=",
"pack",
"(",
"'h*'",
",",
"$",
"hex",
")",
";",
"return",
"$",
"bin",
";",
"}"
] |
Compress the given string using the Huffman-like coding
@param string $str The text to compress
@return binary The compressed string in binary format
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Compress",
"the",
"given",
"string",
"using",
"the",
"Huffman",
"-",
"like",
"coding"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L196-L205
|
227,757
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.decompress
|
public static function decompress($bin)
{
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
$str = self::bits2str($bits);
$str = iconv('cp1256', 'utf-8', $str);
return $str;
}
|
php
|
public static function decompress($bin)
{
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
$str = self::bits2str($bits);
$str = iconv('cp1256', 'utf-8', $str);
return $str;
}
|
[
"public",
"static",
"function",
"decompress",
"(",
"$",
"bin",
")",
"{",
"$",
"temp",
"=",
"unpack",
"(",
"'h*'",
",",
"$",
"bin",
")",
";",
"$",
"bytes",
"=",
"$",
"temp",
"[",
"1",
"]",
";",
"$",
"bits",
"=",
"self",
"::",
"hex2bits",
"(",
"$",
"bytes",
")",
";",
"$",
"str",
"=",
"self",
"::",
"bits2str",
"(",
"$",
"bits",
")",
";",
"$",
"str",
"=",
"iconv",
"(",
"'cp1256'",
",",
"'utf-8'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Uncompress a compressed string
@param binary $bin The text compressed by compress().
@return string The original uncompressed string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Uncompress",
"a",
"compressed",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L215-L225
|
227,758
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.search
|
public static function search($bin, $word)
{
$word = iconv('utf-8', 'cp1256', $word);
$wBits = self::str2bits($word);
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
if (strpos($bits, $wBits)) {
return true;
} else {
return false;
}
}
|
php
|
public static function search($bin, $word)
{
$word = iconv('utf-8', 'cp1256', $word);
$wBits = self::str2bits($word);
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
if (strpos($bits, $wBits)) {
return true;
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"search",
"(",
"$",
"bin",
",",
"$",
"word",
")",
"{",
"$",
"word",
"=",
"iconv",
"(",
"'utf-8'",
",",
"'cp1256'",
",",
"$",
"word",
")",
";",
"$",
"wBits",
"=",
"self",
"::",
"str2bits",
"(",
"$",
"word",
")",
";",
"$",
"temp",
"=",
"unpack",
"(",
"'h*'",
",",
"$",
"bin",
")",
";",
"$",
"bytes",
"=",
"$",
"temp",
"[",
"1",
"]",
";",
"$",
"bits",
"=",
"self",
"::",
"hex2bits",
"(",
"$",
"bytes",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"bits",
",",
"$",
"wBits",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Search a compressed string for a given word
@param binary $bin Compressed binary string
@param string $word The string you looking for
@return boolean True if found and False if not found
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Search",
"a",
"compressed",
"string",
"for",
"a",
"given",
"word"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L236-L250
|
227,759
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.length
|
public static function length($bin)
{
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
$count = 0;
$i = 0;
while (isset($bits[$i])) {
$count++;
if ($bits[$i] == 1) {
$i += 9;
} else {
$i += 4;
}
}
return $count;
}
|
php
|
public static function length($bin)
{
$temp = unpack('h*', $bin);
$bytes = $temp[1];
$bits = self::hex2bits($bytes);
$count = 0;
$i = 0;
while (isset($bits[$i])) {
$count++;
if ($bits[$i] == 1) {
$i += 9;
} else {
$i += 4;
}
}
return $count;
}
|
[
"public",
"static",
"function",
"length",
"(",
"$",
"bin",
")",
"{",
"$",
"temp",
"=",
"unpack",
"(",
"'h*'",
",",
"$",
"bin",
")",
";",
"$",
"bytes",
"=",
"$",
"temp",
"[",
"1",
"]",
";",
"$",
"bits",
"=",
"self",
"::",
"hex2bits",
"(",
"$",
"bytes",
")",
";",
"$",
"count",
"=",
"0",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"isset",
"(",
"$",
"bits",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"count",
"++",
";",
"if",
"(",
"$",
"bits",
"[",
"$",
"i",
"]",
"==",
"1",
")",
"{",
"$",
"i",
"+=",
"9",
";",
"}",
"else",
"{",
"$",
"i",
"+=",
"4",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] |
Retrieve the original string length
@param binary $bin Compressed binary string
@return integer Original string length
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Retrieve",
"the",
"original",
"string",
"length"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L260-L279
|
227,760
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.str2bits
|
protected static function str2bits($str)
{
$bits = '';
$total = strlen($str);
$i = -1;
while (++$i < $total) {
$char = $str[$i];
$pos = strpos(self::$_encode, $char);
if ($pos !== false) {
$bits .= substr(self::$_binary, $pos*5, 4);
} else {
$int = ord($char);
$bits .= '1'.substr(self::$_bin, (int)($int/16)*5, 4);
$bits .= substr(self::$_bin, ($int%16)*5, 4);
}
}
// Complete nibbel
$add = strlen($bits) % 4;
$bits .= str_repeat('0', $add);
return $bits;
}
|
php
|
protected static function str2bits($str)
{
$bits = '';
$total = strlen($str);
$i = -1;
while (++$i < $total) {
$char = $str[$i];
$pos = strpos(self::$_encode, $char);
if ($pos !== false) {
$bits .= substr(self::$_binary, $pos*5, 4);
} else {
$int = ord($char);
$bits .= '1'.substr(self::$_bin, (int)($int/16)*5, 4);
$bits .= substr(self::$_bin, ($int%16)*5, 4);
}
}
// Complete nibbel
$add = strlen($bits) % 4;
$bits .= str_repeat('0', $add);
return $bits;
}
|
[
"protected",
"static",
"function",
"str2bits",
"(",
"$",
"str",
")",
"{",
"$",
"bits",
"=",
"''",
";",
"$",
"total",
"=",
"strlen",
"(",
"$",
"str",
")",
";",
"$",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"$",
"i",
"<",
"$",
"total",
")",
"{",
"$",
"char",
"=",
"$",
"str",
"[",
"$",
"i",
"]",
";",
"$",
"pos",
"=",
"strpos",
"(",
"self",
"::",
"$",
"_encode",
",",
"$",
"char",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"$",
"bits",
".=",
"substr",
"(",
"self",
"::",
"$",
"_binary",
",",
"$",
"pos",
"*",
"5",
",",
"4",
")",
";",
"}",
"else",
"{",
"$",
"int",
"=",
"ord",
"(",
"$",
"char",
")",
";",
"$",
"bits",
".=",
"'1'",
".",
"substr",
"(",
"self",
"::",
"$",
"_bin",
",",
"(",
"int",
")",
"(",
"$",
"int",
"/",
"16",
")",
"*",
"5",
",",
"4",
")",
";",
"$",
"bits",
".=",
"substr",
"(",
"self",
"::",
"$",
"_bin",
",",
"(",
"$",
"int",
"%",
"16",
")",
"*",
"5",
",",
"4",
")",
";",
"}",
"}",
"// Complete nibbel",
"$",
"add",
"=",
"strlen",
"(",
"$",
"bits",
")",
"%",
"4",
";",
"$",
"bits",
".=",
"str_repeat",
"(",
"'0'",
",",
"$",
"add",
")",
";",
"return",
"$",
"bits",
";",
"}"
] |
Convert textual string into binary string
@param string $str The textual string to convert
@return binary The binary representation of textual string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"textual",
"string",
"into",
"binary",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L289-L313
|
227,761
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.bits2str
|
protected static function bits2str($bits)
{
$str = '';
while ($bits) {
$flag = substr($bits, 0, 1);
$bits = substr($bits, 1);
if ($flag == 1) {
$byte = substr($bits, 0, 8);
$bits = substr($bits, 8);
if ($bits || strlen($code) == 8) {
$int = base_convert($byte, 2, 10);
$char = chr($int);
$str .= $char;
}
} else {
$code = substr($bits, 0, 3);
$bits = substr($bits, 3);
if ($bits || strlen($code) == 3) {
$pos = strpos(self::$_binary, "0$code|");
$str .= substr(self::$_encode, $pos/5, 1);
}
}
}
return $str;
}
|
php
|
protected static function bits2str($bits)
{
$str = '';
while ($bits) {
$flag = substr($bits, 0, 1);
$bits = substr($bits, 1);
if ($flag == 1) {
$byte = substr($bits, 0, 8);
$bits = substr($bits, 8);
if ($bits || strlen($code) == 8) {
$int = base_convert($byte, 2, 10);
$char = chr($int);
$str .= $char;
}
} else {
$code = substr($bits, 0, 3);
$bits = substr($bits, 3);
if ($bits || strlen($code) == 3) {
$pos = strpos(self::$_binary, "0$code|");
$str .= substr(self::$_encode, $pos/5, 1);
}
}
}
return $str;
}
|
[
"protected",
"static",
"function",
"bits2str",
"(",
"$",
"bits",
")",
"{",
"$",
"str",
"=",
"''",
";",
"while",
"(",
"$",
"bits",
")",
"{",
"$",
"flag",
"=",
"substr",
"(",
"$",
"bits",
",",
"0",
",",
"1",
")",
";",
"$",
"bits",
"=",
"substr",
"(",
"$",
"bits",
",",
"1",
")",
";",
"if",
"(",
"$",
"flag",
"==",
"1",
")",
"{",
"$",
"byte",
"=",
"substr",
"(",
"$",
"bits",
",",
"0",
",",
"8",
")",
";",
"$",
"bits",
"=",
"substr",
"(",
"$",
"bits",
",",
"8",
")",
";",
"if",
"(",
"$",
"bits",
"||",
"strlen",
"(",
"$",
"code",
")",
"==",
"8",
")",
"{",
"$",
"int",
"=",
"base_convert",
"(",
"$",
"byte",
",",
"2",
",",
"10",
")",
";",
"$",
"char",
"=",
"chr",
"(",
"$",
"int",
")",
";",
"$",
"str",
".=",
"$",
"char",
";",
"}",
"}",
"else",
"{",
"$",
"code",
"=",
"substr",
"(",
"$",
"bits",
",",
"0",
",",
"3",
")",
";",
"$",
"bits",
"=",
"substr",
"(",
"$",
"bits",
",",
"3",
")",
";",
"if",
"(",
"$",
"bits",
"||",
"strlen",
"(",
"$",
"code",
")",
"==",
"3",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"self",
"::",
"$",
"_binary",
",",
"\"0$code|\"",
")",
";",
"$",
"str",
".=",
"substr",
"(",
"self",
"::",
"$",
"_encode",
",",
"$",
"pos",
"/",
"5",
",",
"1",
")",
";",
"}",
"}",
"}",
"return",
"$",
"str",
";",
"}"
] |
Convert binary string into textual string
@param binary $bits The binary string to convert
@return string The textual representation of binary string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"binary",
"string",
"into",
"textual",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L323-L351
|
227,762
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.bits2hex
|
protected static function bits2hex($bits)
{
$hex = '';
$total = strlen($bits) / 4;
for ($i = 0; $i < $total; $i++) {
$nibbel = substr($bits, $i*4, 4);
$pos = strpos(self::$_bin, $nibbel);
$hex .= substr(self::$_hex, $pos/5, 1);
}
return $hex;
}
|
php
|
protected static function bits2hex($bits)
{
$hex = '';
$total = strlen($bits) / 4;
for ($i = 0; $i < $total; $i++) {
$nibbel = substr($bits, $i*4, 4);
$pos = strpos(self::$_bin, $nibbel);
$hex .= substr(self::$_hex, $pos/5, 1);
}
return $hex;
}
|
[
"protected",
"static",
"function",
"bits2hex",
"(",
"$",
"bits",
")",
"{",
"$",
"hex",
"=",
"''",
";",
"$",
"total",
"=",
"strlen",
"(",
"$",
"bits",
")",
"/",
"4",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"total",
";",
"$",
"i",
"++",
")",
"{",
"$",
"nibbel",
"=",
"substr",
"(",
"$",
"bits",
",",
"$",
"i",
"*",
"4",
",",
"4",
")",
";",
"$",
"pos",
"=",
"strpos",
"(",
"self",
"::",
"$",
"_bin",
",",
"$",
"nibbel",
")",
";",
"$",
"hex",
".=",
"substr",
"(",
"self",
"::",
"$",
"_hex",
",",
"$",
"pos",
"/",
"5",
",",
"1",
")",
";",
"}",
"return",
"$",
"hex",
";",
"}"
] |
Convert binary string into hexadecimal string
@param binary $bits The binary string to convert
@return hexadecimal The hexadecimal representation of binary string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"binary",
"string",
"into",
"hexadecimal",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L361-L374
|
227,763
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CompressStr.php
|
CompressStr.hex2bits
|
protected static function hex2bits($hex)
{
$bits = '';
$total = strlen($hex);
for ($i = 0; $i < $total; $i++) {
$pos = strpos(self::$_hex, $hex[$i]);
$bits .= substr(self::$_bin, $pos*5, 4);
}
return $bits;
}
|
php
|
protected static function hex2bits($hex)
{
$bits = '';
$total = strlen($hex);
for ($i = 0; $i < $total; $i++) {
$pos = strpos(self::$_hex, $hex[$i]);
$bits .= substr(self::$_bin, $pos*5, 4);
}
return $bits;
}
|
[
"protected",
"static",
"function",
"hex2bits",
"(",
"$",
"hex",
")",
"{",
"$",
"bits",
"=",
"''",
";",
"$",
"total",
"=",
"strlen",
"(",
"$",
"hex",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"total",
";",
"$",
"i",
"++",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"self",
"::",
"$",
"_hex",
",",
"$",
"hex",
"[",
"$",
"i",
"]",
")",
";",
"$",
"bits",
".=",
"substr",
"(",
"self",
"::",
"$",
"_bin",
",",
"$",
"pos",
"*",
"5",
",",
"4",
")",
";",
"}",
"return",
"$",
"bits",
";",
"}"
] |
Convert hexadecimal string into binary string
@param hexadecimal $hex The hexadezimal string to convert
@return binary The binary representation of hexadecimal string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"hexadecimal",
"string",
"into",
"binary",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CompressStr.php#L384-L395
|
227,764
|
mayoz/parasut
|
src/Bundle/Sale.php
|
Sale.get
|
public function get($page = 1, $limit = 25, $lastSynch = null)
{
return $this->client->call("sales_invoices", [
'page' => $page,
'per_page' => $limit,
'last_synch' => $lastSynch,
], 'GET');
}
|
php
|
public function get($page = 1, $limit = 25, $lastSynch = null)
{
return $this->client->call("sales_invoices", [
'page' => $page,
'per_page' => $limit,
'last_synch' => $lastSynch,
], 'GET');
}
|
[
"public",
"function",
"get",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"limit",
"=",
"25",
",",
"$",
"lastSynch",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"call",
"(",
"\"sales_invoices\"",
",",
"[",
"'page'",
"=>",
"$",
"page",
",",
"'per_page'",
"=>",
"$",
"limit",
",",
"'last_synch'",
"=>",
"$",
"lastSynch",
",",
"]",
",",
"'GET'",
")",
";",
"}"
] |
Retrieve all sales invoices with pagination.
@param int $page
@param int $limit
@param string|null $lastSynch
@return array
|
[
"Retrieve",
"all",
"sales",
"invoices",
"with",
"pagination",
"."
] |
88b45bc3f7f84da9b6028ffd7f02547d9b537506
|
https://github.com/mayoz/parasut/blob/88b45bc3f7f84da9b6028ffd7f02547d9b537506/src/Bundle/Sale.php#L34-L41
|
227,765
|
TimeToogo/RapidRoute
|
src/RouteParser.php
|
RouteParser.parse
|
public function parse($pattern, array $conditions)
{
if (strlen($pattern) > 1 && $pattern[0] !== '/') {
throw new InvalidRoutePatternException(sprintf(
'Invalid route pattern: non-root route must be prefixed with \'/\', \'%s\' given',
$pattern
));
}
$segments = [];
$patternSegments = explode('/', $pattern);
array_shift($patternSegments);
foreach ($patternSegments as $key => $patternSegment) {
if ($this->matchRouteParameters($pattern, $patternSegment, $conditions, $matches, $names)) {
$regex = $this->compileSegmentRegex($matches, $conditions);
$segments[] = new ParameterSegment($names, $regex);
} else {
$segments[] = new StaticSegment($patternSegment);
}
}
return $segments;
}
|
php
|
public function parse($pattern, array $conditions)
{
if (strlen($pattern) > 1 && $pattern[0] !== '/') {
throw new InvalidRoutePatternException(sprintf(
'Invalid route pattern: non-root route must be prefixed with \'/\', \'%s\' given',
$pattern
));
}
$segments = [];
$patternSegments = explode('/', $pattern);
array_shift($patternSegments);
foreach ($patternSegments as $key => $patternSegment) {
if ($this->matchRouteParameters($pattern, $patternSegment, $conditions, $matches, $names)) {
$regex = $this->compileSegmentRegex($matches, $conditions);
$segments[] = new ParameterSegment($names, $regex);
} else {
$segments[] = new StaticSegment($patternSegment);
}
}
return $segments;
}
|
[
"public",
"function",
"parse",
"(",
"$",
"pattern",
",",
"array",
"$",
"conditions",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"pattern",
")",
">",
"1",
"&&",
"$",
"pattern",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"throw",
"new",
"InvalidRoutePatternException",
"(",
"sprintf",
"(",
"'Invalid route pattern: non-root route must be prefixed with \\'/\\', \\'%s\\' given'",
",",
"$",
"pattern",
")",
")",
";",
"}",
"$",
"segments",
"=",
"[",
"]",
";",
"$",
"patternSegments",
"=",
"explode",
"(",
"'/'",
",",
"$",
"pattern",
")",
";",
"array_shift",
"(",
"$",
"patternSegments",
")",
";",
"foreach",
"(",
"$",
"patternSegments",
"as",
"$",
"key",
"=>",
"$",
"patternSegment",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchRouteParameters",
"(",
"$",
"pattern",
",",
"$",
"patternSegment",
",",
"$",
"conditions",
",",
"$",
"matches",
",",
"$",
"names",
")",
")",
"{",
"$",
"regex",
"=",
"$",
"this",
"->",
"compileSegmentRegex",
"(",
"$",
"matches",
",",
"$",
"conditions",
")",
";",
"$",
"segments",
"[",
"]",
"=",
"new",
"ParameterSegment",
"(",
"$",
"names",
",",
"$",
"regex",
")",
";",
"}",
"else",
"{",
"$",
"segments",
"[",
"]",
"=",
"new",
"StaticSegment",
"(",
"$",
"patternSegment",
")",
";",
"}",
"}",
"return",
"$",
"segments",
";",
"}"
] |
Parses the supplied route pattern into an array of route segments.
Example:
$pattern = 'user/{id}/delete'
$conditions = ['id' => '[0-9]+']
Should return:
[
StaticSegment{ $value => 'user' },
ParameterSegment{ $name => 'id', $match => '[0-9]+' },
StaticSegment{ $value => 'delete' },
]
@param string $pattern
@param string[] $conditions
@return RouteSegments\RouteSegment[]
@throws InvalidRoutePatternException
|
[
"Parses",
"the",
"supplied",
"route",
"pattern",
"into",
"an",
"array",
"of",
"route",
"segments",
"."
] |
5ef2c90a1ab5f02565c4a22bc0bf979c98f15292
|
https://github.com/TimeToogo/RapidRoute/blob/5ef2c90a1ab5f02565c4a22bc0bf979c98f15292/src/RouteParser.php#L38-L63
|
227,766
|
middlewares/https
|
src/Https.php
|
Https.mustRedirect
|
private function mustRedirect(ServerRequestInterface $request): bool
{
if ($this->redirect === false) {
return false;
}
return !$this->checkHttpsForward || (
$request->getHeaderLine('X-Forwarded-Proto') !== 'https' &&
$request->getHeaderLine('X-Forwarded-Port') !== '443'
);
}
|
php
|
private function mustRedirect(ServerRequestInterface $request): bool
{
if ($this->redirect === false) {
return false;
}
return !$this->checkHttpsForward || (
$request->getHeaderLine('X-Forwarded-Proto') !== 'https' &&
$request->getHeaderLine('X-Forwarded-Port') !== '443'
);
}
|
[
"private",
"function",
"mustRedirect",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"redirect",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"checkHttpsForward",
"||",
"(",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'X-Forwarded-Proto'",
")",
"!==",
"'https'",
"&&",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'X-Forwarded-Port'",
")",
"!==",
"'443'",
")",
";",
"}"
] |
Check whether the request must be redirected or not.
|
[
"Check",
"whether",
"the",
"request",
"must",
"be",
"redirected",
"or",
"not",
"."
] |
9157e9929f88a06c8d4dd338b12bc775a329698d
|
https://github.com/middlewares/https/blob/9157e9929f88a06c8d4dd338b12bc775a329698d/src/Https.php#L149-L159
|
227,767
|
alhoqbani/ar-php
|
src/ArUtil/Time/ArDateTime.php
|
ArDateTime.arCreateFromFormat
|
public static function arCreateFromFormat($format, $date, $tz = null, $correction = null)
{
$arDate = self::parseDateFormat($format, $date);
return self::arCreate($arDate['arYear'], $arDate['arMonth'], $arDate['arDay'], $arDate['hour'],
$arDate['minute'],
$arDate['second'],
$tz, $correction);
}
|
php
|
public static function arCreateFromFormat($format, $date, $tz = null, $correction = null)
{
$arDate = self::parseDateFormat($format, $date);
return self::arCreate($arDate['arYear'], $arDate['arMonth'], $arDate['arDay'], $arDate['hour'],
$arDate['minute'],
$arDate['second'],
$tz, $correction);
}
|
[
"public",
"static",
"function",
"arCreateFromFormat",
"(",
"$",
"format",
",",
"$",
"date",
",",
"$",
"tz",
"=",
"null",
",",
"$",
"correction",
"=",
"null",
")",
"{",
"$",
"arDate",
"=",
"self",
"::",
"parseDateFormat",
"(",
"$",
"format",
",",
"$",
"date",
")",
";",
"return",
"self",
"::",
"arCreate",
"(",
"$",
"arDate",
"[",
"'arYear'",
"]",
",",
"$",
"arDate",
"[",
"'arMonth'",
"]",
",",
"$",
"arDate",
"[",
"'arDay'",
"]",
",",
"$",
"arDate",
"[",
"'hour'",
"]",
",",
"$",
"arDate",
"[",
"'minute'",
"]",
",",
"$",
"arDate",
"[",
"'second'",
"]",
",",
"$",
"tz",
",",
"$",
"correction",
")",
";",
"}"
] |
Create new instance from Hijri date in the format provided.
@param string $format
@param string $date
@param \DateTimeZone|string|null $tz
@param int|null $correction Date conversion factor (+1, +2, -1, -2)
@return \ArUtil\Time\ArDateTime
|
[
"Create",
"new",
"instance",
"from",
"Hijri",
"date",
"in",
"the",
"format",
"provided",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/Time/ArDateTime.php#L131-L139
|
227,768
|
alhoqbani/ar-php
|
src/ArUtil/Time/ArDateTime.php
|
ArDateTime.setTodayHijriDate
|
private function setTodayHijriDate()
{
$today = $this->convertTodayToHijri();
$this->arYear = (int)$today['arYear'];
$this->arMonth = (int)$today['arMonth'];
$this->arDay = (int)$today['arDay'];
}
|
php
|
private function setTodayHijriDate()
{
$today = $this->convertTodayToHijri();
$this->arYear = (int)$today['arYear'];
$this->arMonth = (int)$today['arMonth'];
$this->arDay = (int)$today['arDay'];
}
|
[
"private",
"function",
"setTodayHijriDate",
"(",
")",
"{",
"$",
"today",
"=",
"$",
"this",
"->",
"convertTodayToHijri",
"(",
")",
";",
"$",
"this",
"->",
"arYear",
"=",
"(",
"int",
")",
"$",
"today",
"[",
"'arYear'",
"]",
";",
"$",
"this",
"->",
"arMonth",
"=",
"(",
"int",
")",
"$",
"today",
"[",
"'arMonth'",
"]",
";",
"$",
"this",
"->",
"arDay",
"=",
"(",
"int",
")",
"$",
"today",
"[",
"'arDay'",
"]",
";",
"}"
] |
Set the instance Hijri date for today.
|
[
"Set",
"the",
"instance",
"Hijri",
"date",
"for",
"today",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/Time/ArDateTime.php#L247-L253
|
227,769
|
alhoqbani/ar-php
|
src/ArUtil/Time/ArDateTime.php
|
ArDateTime.hijriToTimestamp
|
protected function hijriToTimestamp(
$arYear, $arMonth, $arDay, $hour = null, $minute = null, $second = null, $correction = 0
) {
$hour = isset($hour) ? $hour : date('H');
$minute = isset($minute) ? $minute : date('i');
$second = isset($second) ? $second : date('s');
return (new Mktime())->mktime($hour, $minute, $second, $arMonth, $arDay, $arYear,
$correction);
}
|
php
|
protected function hijriToTimestamp(
$arYear, $arMonth, $arDay, $hour = null, $minute = null, $second = null, $correction = 0
) {
$hour = isset($hour) ? $hour : date('H');
$minute = isset($minute) ? $minute : date('i');
$second = isset($second) ? $second : date('s');
return (new Mktime())->mktime($hour, $minute, $second, $arMonth, $arDay, $arYear,
$correction);
}
|
[
"protected",
"function",
"hijriToTimestamp",
"(",
"$",
"arYear",
",",
"$",
"arMonth",
",",
"$",
"arDay",
",",
"$",
"hour",
"=",
"null",
",",
"$",
"minute",
"=",
"null",
",",
"$",
"second",
"=",
"null",
",",
"$",
"correction",
"=",
"0",
")",
"{",
"$",
"hour",
"=",
"isset",
"(",
"$",
"hour",
")",
"?",
"$",
"hour",
":",
"date",
"(",
"'H'",
")",
";",
"$",
"minute",
"=",
"isset",
"(",
"$",
"minute",
")",
"?",
"$",
"minute",
":",
"date",
"(",
"'i'",
")",
";",
"$",
"second",
"=",
"isset",
"(",
"$",
"second",
")",
"?",
"$",
"second",
":",
"date",
"(",
"'s'",
")",
";",
"return",
"(",
"new",
"Mktime",
"(",
")",
")",
"->",
"mktime",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
",",
"$",
"arMonth",
",",
"$",
"arDay",
",",
"$",
"arYear",
",",
"$",
"correction",
")",
";",
"}"
] |
Convert given Hijri date to Gregorian Date in timestamp
@param int|null $arYear Hijri year Ex: 1430
@param int|null $arMonth Hijri month Ex: 10
@param int|null $arDay Hijri Day date Ex: 01
@param int|null $hour
@param int|null $minute
@param int|null $second
@param int|null $correction Date conversion factor (+1, +2, -1, -2)
@return int Timestamp for Converted date
|
[
"Convert",
"given",
"Hijri",
"date",
"to",
"Gregorian",
"Date",
"in",
"timestamp"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/Time/ArDateTime.php#L268-L277
|
227,770
|
alhoqbani/ar-php
|
src/ArUtil/Time/ArDateTime.php
|
ArDateTime.convertTodayToHijri
|
private function convertTodayToHijri()
{
list($arYear, $arMonth, $arDay) = (new Date())->hjConvert(date('Y'), date('m'), date('d'));
return [
'arYear' => $arYear,
'arMonth' => $arMonth,
'arDay' => $arDay,
];
}
|
php
|
private function convertTodayToHijri()
{
list($arYear, $arMonth, $arDay) = (new Date())->hjConvert(date('Y'), date('m'), date('d'));
return [
'arYear' => $arYear,
'arMonth' => $arMonth,
'arDay' => $arDay,
];
}
|
[
"private",
"function",
"convertTodayToHijri",
"(",
")",
"{",
"list",
"(",
"$",
"arYear",
",",
"$",
"arMonth",
",",
"$",
"arDay",
")",
"=",
"(",
"new",
"Date",
"(",
")",
")",
"->",
"hjConvert",
"(",
"date",
"(",
"'Y'",
")",
",",
"date",
"(",
"'m'",
")",
",",
"date",
"(",
"'d'",
")",
")",
";",
"return",
"[",
"'arYear'",
"=>",
"$",
"arYear",
",",
"'arMonth'",
"=>",
"$",
"arMonth",
",",
"'arDay'",
"=>",
"$",
"arDay",
",",
"]",
";",
"}"
] |
Convert Toady's Gregorian date to Hijri date.
@return array The hijri date.
|
[
"Convert",
"Toady",
"s",
"Gregorian",
"date",
"to",
"Hijri",
"date",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/Time/ArDateTime.php#L284-L293
|
227,771
|
alhoqbani/ar-php
|
src/ArUtil/Time/ArDateTime.php
|
ArDateTime.updateHijriDate
|
private function updateHijriDate($arYear, $arMonth, $arDay)
{
$this->arYear = $arYear;
$this->arMonth = $arMonth;
$this->arDay = $arDay;
}
|
php
|
private function updateHijriDate($arYear, $arMonth, $arDay)
{
$this->arYear = $arYear;
$this->arMonth = $arMonth;
$this->arDay = $arDay;
}
|
[
"private",
"function",
"updateHijriDate",
"(",
"$",
"arYear",
",",
"$",
"arMonth",
",",
"$",
"arDay",
")",
"{",
"$",
"this",
"->",
"arYear",
"=",
"$",
"arYear",
";",
"$",
"this",
"->",
"arMonth",
"=",
"$",
"arMonth",
";",
"$",
"this",
"->",
"arDay",
"=",
"$",
"arDay",
";",
"}"
] |
Update the instance Hijri Date, used by static create methods.
@param int|null $arYear Hijri year
@param int|null $arMonth Hijri month
@param int|null $arDay Hijri Day date
|
[
"Update",
"the",
"instance",
"Hijri",
"Date",
"used",
"by",
"static",
"create",
"methods",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/Time/ArDateTime.php#L302-L307
|
227,772
|
RichWeber/yii2-twitter
|
Twitter.php
|
Twitter.getTwitterTokened
|
public function getTwitterTokened($token,$secret)
{
return new TwitterOAuth($this->consumer_key, $this->consumer_secret, $token,$secret);
}
|
php
|
public function getTwitterTokened($token,$secret)
{
return new TwitterOAuth($this->consumer_key, $this->consumer_secret, $token,$secret);
}
|
[
"public",
"function",
"getTwitterTokened",
"(",
"$",
"token",
",",
"$",
"secret",
")",
"{",
"return",
"new",
"TwitterOAuth",
"(",
"$",
"this",
"->",
"consumer_key",
",",
"$",
"this",
"->",
"consumer_secret",
",",
"$",
"token",
",",
"$",
"secret",
")",
";",
"}"
] |
Use this for after we have a token and a secret for the use.
(you must save these in order for them to be usefull
|
[
"Use",
"this",
"for",
"after",
"we",
"have",
"a",
"token",
"and",
"a",
"secret",
"for",
"the",
"use",
".",
"(",
"you",
"must",
"save",
"these",
"in",
"order",
"for",
"them",
"to",
"be",
"usefull"
] |
69e0391c0a82026cea9c2bf414e5116b9f391170
|
https://github.com/RichWeber/yii2-twitter/blob/69e0391c0a82026cea9c2bf414e5116b9f391170/Twitter.php#L52-L55
|
227,773
|
RichWeber/yii2-twitter
|
TwitterOAuth.php
|
TwitterOAuth.getAccessToken
|
function getAccessToken($oauth_verifier = FALSE)
{
$parameters = [];
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
|
php
|
function getAccessToken($oauth_verifier = FALSE)
{
$parameters = [];
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
|
[
"function",
"getAccessToken",
"(",
"$",
"oauth_verifier",
"=",
"FALSE",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"oauth_verifier",
")",
")",
"{",
"$",
"parameters",
"[",
"'oauth_verifier'",
"]",
"=",
"$",
"oauth_verifier",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"oAuthRequest",
"(",
"$",
"this",
"->",
"accessTokenURL",
"(",
")",
",",
"'GET'",
",",
"$",
"parameters",
")",
";",
"$",
"token",
"=",
"OAuthUtil",
"::",
"parse_parameters",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"token",
"=",
"new",
"OAuthConsumer",
"(",
"$",
"token",
"[",
"'oauth_token'",
"]",
",",
"$",
"token",
"[",
"'oauth_token_secret'",
"]",
")",
";",
"return",
"$",
"token",
";",
"}"
] |
Exchange request token and secret for an access token and
secret, to sign API calls.
@returns array("oauth_token" => "the-access-token",
"oauth_token_secret" => "the-access-secret",
"user_id" => "9436992",
"screen_name" => "abraham")
|
[
"Exchange",
"request",
"token",
"and",
"secret",
"for",
"an",
"access",
"token",
"and",
"secret",
"to",
"sign",
"API",
"calls",
"."
] |
69e0391c0a82026cea9c2bf414e5116b9f391170
|
https://github.com/RichWeber/yii2-twitter/blob/69e0391c0a82026cea9c2bf414e5116b9f391170/TwitterOAuth.php#L153-L163
|
227,774
|
RichWeber/yii2-twitter
|
TwitterOAuth.php
|
TwitterOAuth.getHeader
|
function getHeader($ch, $header)
{
$i = strpos($header, ':');
if (!empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
|
php
|
function getHeader($ch, $header)
{
$i = strpos($header, ':');
if (!empty($i)) {
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
$value = trim(substr($header, $i + 2));
$this->http_header[$key] = $value;
}
return strlen($header);
}
|
[
"function",
"getHeader",
"(",
"$",
"ch",
",",
"$",
"header",
")",
"{",
"$",
"i",
"=",
"strpos",
"(",
"$",
"header",
",",
"':'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"i",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"strtolower",
"(",
"substr",
"(",
"$",
"header",
",",
"0",
",",
"$",
"i",
")",
")",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"substr",
"(",
"$",
"header",
",",
"$",
"i",
"+",
"2",
")",
")",
";",
"$",
"this",
"->",
"http_header",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"strlen",
"(",
"$",
"header",
")",
";",
"}"
] |
Get the header info to store.
|
[
"Get",
"the",
"header",
"info",
"to",
"store",
"."
] |
69e0391c0a82026cea9c2bf414e5116b9f391170
|
https://github.com/RichWeber/yii2-twitter/blob/69e0391c0a82026cea9c2bf414e5116b9f391170/TwitterOAuth.php#L283-L292
|
227,775
|
alhoqbani/ar-php
|
src/ArUtil/I18N/AutoSummarize.php
|
AutoSummarize.loadExtra
|
public function loadExtra()
{
$extra_words = file(__DIR__ . '/data/ar-extra-stopwords.txt');
$extra_words = array_map('trim', $extra_words);
$this->_commonWords = array_merge($this->_commonWords, $extra_words);
}
|
php
|
public function loadExtra()
{
$extra_words = file(__DIR__ . '/data/ar-extra-stopwords.txt');
$extra_words = array_map('trim', $extra_words);
$this->_commonWords = array_merge($this->_commonWords, $extra_words);
}
|
[
"public",
"function",
"loadExtra",
"(",
")",
"{",
"$",
"extra_words",
"=",
"file",
"(",
"__DIR__",
".",
"'/data/ar-extra-stopwords.txt'",
")",
";",
"$",
"extra_words",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"extra_words",
")",
";",
"$",
"this",
"->",
"_commonWords",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_commonWords",
",",
"$",
"extra_words",
")",
";",
"}"
] |
Load enhanced Arabic stop words list
@return void
|
[
"Load",
"enhanced",
"Arabic",
"stop",
"words",
"list"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/AutoSummarize.php#L186-L191
|
227,776
|
alhoqbani/ar-php
|
src/ArUtil/I18N/AutoSummarize.php
|
AutoSummarize.minAcceptedRank
|
protected function minAcceptedRank($str, $arr, $int, $max)
{
$len = array();
foreach ($str as $line) {
$len[] = mb_strlen($line);
}
rsort($arr, SORT_NUMERIC);
$totalChars = 0;
for ($i=0; $i<=$int; $i++) {
if (!isset($arr[$i])) {
$minRank = 0;
break;
}
$totalChars += $len[$i];
if ($totalChars >= $max) {
$minRank = $arr[$i];
break;
}
$minRank = $arr[$i];
}
return $minRank;
}
|
php
|
protected function minAcceptedRank($str, $arr, $int, $max)
{
$len = array();
foreach ($str as $line) {
$len[] = mb_strlen($line);
}
rsort($arr, SORT_NUMERIC);
$totalChars = 0;
for ($i=0; $i<=$int; $i++) {
if (!isset($arr[$i])) {
$minRank = 0;
break;
}
$totalChars += $len[$i];
if ($totalChars >= $max) {
$minRank = $arr[$i];
break;
}
$minRank = $arr[$i];
}
return $minRank;
}
|
[
"protected",
"function",
"minAcceptedRank",
"(",
"$",
"str",
",",
"$",
"arr",
",",
"$",
"int",
",",
"$",
"max",
")",
"{",
"$",
"len",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"str",
"as",
"$",
"line",
")",
"{",
"$",
"len",
"[",
"]",
"=",
"mb_strlen",
"(",
"$",
"line",
")",
";",
"}",
"rsort",
"(",
"$",
"arr",
",",
"SORT_NUMERIC",
")",
";",
"$",
"totalChars",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"$",
"int",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"arr",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"minRank",
"=",
"0",
";",
"break",
";",
"}",
"$",
"totalChars",
"+=",
"$",
"len",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"totalChars",
">=",
"$",
"max",
")",
"{",
"$",
"minRank",
"=",
"$",
"arr",
"[",
"$",
"i",
"]",
";",
"break",
";",
"}",
"$",
"minRank",
"=",
"$",
"arr",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"minRank",
";",
"}"
] |
Calculate minimum rank for sentences which will be including in the summary
@param array $str Document sentences
@param array $arr Sentences ranks
@param integer $int Number of sentences you need to include in your summary
@param integer $max Maximum number of characters accepted in your summary
@return integer Minimum accepted sentence rank (sentences with rank more
than this will be listed in the document summary)
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Calculate",
"minimum",
"rank",
"for",
"sentences",
"which",
"will",
"be",
"including",
"in",
"the",
"summary"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/AutoSummarize.php#L630-L660
|
227,777
|
TimeToogo/RapidRoute
|
src/Compilation/Matchers/CompoundMatcher.php
|
CompoundMatcher.getMatchHash
|
protected function getMatchHash()
{
$hashes = [];
foreach($this->matchers as $matcher) {
$hashes[] = $matcher->getHash();
}
return implode('::', $hashes);
}
|
php
|
protected function getMatchHash()
{
$hashes = [];
foreach($this->matchers as $matcher) {
$hashes[] = $matcher->getHash();
}
return implode('::', $hashes);
}
|
[
"protected",
"function",
"getMatchHash",
"(",
")",
"{",
"$",
"hashes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"matchers",
"as",
"$",
"matcher",
")",
"{",
"$",
"hashes",
"[",
"]",
"=",
"$",
"matcher",
"->",
"getHash",
"(",
")",
";",
"}",
"return",
"implode",
"(",
"'::'",
",",
"$",
"hashes",
")",
";",
"}"
] |
Returns a unique hash for the matching criteria of the segment.
@return string
|
[
"Returns",
"a",
"unique",
"hash",
"for",
"the",
"matching",
"criteria",
"of",
"the",
"segment",
"."
] |
5ef2c90a1ab5f02565c4a22bc0bf979c98f15292
|
https://github.com/TimeToogo/RapidRoute/blob/5ef2c90a1ab5f02565c4a22bc0bf979c98f15292/src/Compilation/Matchers/CompoundMatcher.php#L69-L78
|
227,778
|
PendoNL/laravel-fontawesome
|
src/LaravelFontAwesome.php
|
LaravelFontAwesome.buildAttributes
|
protected function buildAttributes($options, $classes)
{
$attributes = [];
$attributes[] = 'class="'.$classes.'"';
unset($options['class']);
if (is_array($options)) {
foreach ($options as $attribute => $value) {
$attributes[] = $this->createAttribute($attribute, $value);
}
}
return (count($attributes) > 0) ? implode(' ', $attributes) : '';
}
|
php
|
protected function buildAttributes($options, $classes)
{
$attributes = [];
$attributes[] = 'class="'.$classes.'"';
unset($options['class']);
if (is_array($options)) {
foreach ($options as $attribute => $value) {
$attributes[] = $this->createAttribute($attribute, $value);
}
}
return (count($attributes) > 0) ? implode(' ', $attributes) : '';
}
|
[
"protected",
"function",
"buildAttributes",
"(",
"$",
"options",
",",
"$",
"classes",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"attributes",
"[",
"]",
"=",
"'class=\"'",
".",
"$",
"classes",
".",
"'\"'",
";",
"unset",
"(",
"$",
"options",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"$",
"attributes",
"[",
"]",
"=",
"$",
"this",
"->",
"createAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"(",
"count",
"(",
"$",
"attributes",
")",
">",
"0",
")",
"?",
"implode",
"(",
"' '",
",",
"$",
"attributes",
")",
":",
"''",
";",
"}"
] |
Build the attribute list to add to the icon we are about to generate.
@param $options
@param $classes
@return string
|
[
"Build",
"the",
"attribute",
"list",
"to",
"add",
"to",
"the",
"icon",
"we",
"are",
"about",
"to",
"generate",
"."
] |
13fe35b146ebd157d2e881ef2e18fdfaacfa71c1
|
https://github.com/PendoNL/laravel-fontawesome/blob/13fe35b146ebd157d2e881ef2e18fdfaacfa71c1/src/LaravelFontAwesome.php#L79-L93
|
227,779
|
authlete/authlete-php
|
src/Dto/AuthorizationResponse.php
|
AuthorizationResponse.setScopes
|
public function setScopes(array $scopes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$scopes', $scopes, __NAMESPACE__ . '\Scope');
$this->scopes = $scopes;
return $this;
}
|
php
|
public function setScopes(array $scopes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$scopes', $scopes, __NAMESPACE__ . '\Scope');
$this->scopes = $scopes;
return $this;
}
|
[
"public",
"function",
"setScopes",
"(",
"array",
"$",
"scopes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$scopes'",
",",
"$",
"scopes",
",",
"__NAMESPACE__",
".",
"'\\Scope'",
")",
";",
"$",
"this",
"->",
"scopes",
"=",
"$",
"scopes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the scopes which the client application requested by the `scope`
request parameter.
@param Scope[] $scopes
The scopes requested by the client application.
@return AuthorizationResponse
`$this` object.
|
[
"Set",
"the",
"scopes",
"which",
"the",
"client",
"application",
"requested",
"by",
"the",
"scope",
"request",
"parameter",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/AuthorizationResponse.php#L889-L897
|
227,780
|
authlete/authlete-php
|
src/Dto/AuthorizationResponse.php
|
AuthorizationResponse.setUiLocales
|
public function setUiLocales(array $uiLocales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$uiLocales', $uiLocales);
$this->uiLocales = $uiLocales;
return $this;
}
|
php
|
public function setUiLocales(array $uiLocales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$uiLocales', $uiLocales);
$this->uiLocales = $uiLocales;
return $this;
}
|
[
"public",
"function",
"setUiLocales",
"(",
"array",
"$",
"uiLocales",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$uiLocales'",
",",
"$",
"uiLocales",
")",
";",
"$",
"this",
"->",
"uiLocales",
"=",
"$",
"uiLocales",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of preferred languages and scripts for the user interface.
@param string[] $uiLocales
The list of preferred languages and scripts for the user interface.
@return AuthorizationResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"preferred",
"languages",
"and",
"scripts",
"for",
"the",
"user",
"interface",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/AuthorizationResponse.php#L926-L933
|
227,781
|
authlete/authlete-php
|
src/Dto/AuthorizationResponse.php
|
AuthorizationResponse.setClaimsLocales
|
public function setClaimsLocales(array $claimsLocales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claimsLocales', $claimsLocales);
$this->claimsLocales = $claimsLocales;
return $this;
}
|
php
|
public function setClaimsLocales(array $claimsLocales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claimsLocales', $claimsLocales);
$this->claimsLocales = $claimsLocales;
return $this;
}
|
[
"public",
"function",
"setClaimsLocales",
"(",
"array",
"$",
"claimsLocales",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$claimsLocales'",
",",
"$",
"claimsLocales",
")",
";",
"$",
"this",
"->",
"claimsLocales",
"=",
"$",
"claimsLocales",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of preferred languages and scripts for claim values
contained in an ID token.
@param string[] $claimsLocales
The list of preferred languages and scripts for claim values.
@return AuthorizationResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"preferred",
"languages",
"and",
"scripts",
"for",
"claim",
"values",
"contained",
"in",
"an",
"ID",
"token",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/AuthorizationResponse.php#L964-L971
|
227,782
|
authlete/authlete-php
|
src/Dto/AuthorizationResponse.php
|
AuthorizationResponse.setPrompts
|
public function setPrompts(array $prompts = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$prompts', $prompts, '\Authlete\Types\Prompt');
$this->prompts = $prompts;
return $this;
}
|
php
|
public function setPrompts(array $prompts = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$prompts', $prompts, '\Authlete\Types\Prompt');
$this->prompts = $prompts;
return $this;
}
|
[
"public",
"function",
"setPrompts",
"(",
"array",
"$",
"prompts",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$prompts'",
",",
"$",
"prompts",
",",
"'\\Authlete\\Types\\Prompt'",
")",
";",
"$",
"this",
"->",
"prompts",
"=",
"$",
"prompts",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of prompts contained in the authorization request.
@param Prompt[] $prompts
The list of prompts requested by the client application.
@return AuthorizationResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"prompts",
"contained",
"in",
"the",
"authorization",
"request",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/AuthorizationResponse.php#L1202-L1210
|
227,783
|
mayoz/parasut
|
src/Bundle/Expense.php
|
Expense.monthly
|
public function monthly($year, $month, $page = 1, $limit = 25)
{
return $this->client->call("expenses/in_month/{$year}/{$month}", [
'page' => $page,
'per_page' => $limit
], 'GET');
}
|
php
|
public function monthly($year, $month, $page = 1, $limit = 25)
{
return $this->client->call("expenses/in_month/{$year}/{$month}", [
'page' => $page,
'per_page' => $limit
], 'GET');
}
|
[
"public",
"function",
"monthly",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"page",
"=",
"1",
",",
"$",
"limit",
"=",
"25",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"call",
"(",
"\"expenses/in_month/{$year}/{$month}\"",
",",
"[",
"'page'",
"=>",
"$",
"page",
",",
"'per_page'",
"=>",
"$",
"limit",
"]",
",",
"'GET'",
")",
";",
"}"
] |
Retrieve all expenses by pagination with spesific month of the year.
@param int $year
@param int $month
@param int $page
@param int $limit
@return array
|
[
"Retrieve",
"all",
"expenses",
"by",
"pagination",
"with",
"spesific",
"month",
"of",
"the",
"year",
"."
] |
88b45bc3f7f84da9b6028ffd7f02547d9b537506
|
https://github.com/mayoz/parasut/blob/88b45bc3f7f84da9b6028ffd7f02547d9b537506/src/Bundle/Expense.php#L50-L56
|
227,784
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.stripTashkeel
|
public function stripTashkeel($text)
{
$tashkeel = array(
$this->_chars['FATHATAN'],
$this->_chars['DAMMATAN'],
$this->_chars['KASRATAN'],
$this->_chars['FATHA'],
$this->_chars['DAMMA'],
$this->_chars['KASRA'],
$this->_chars['SUKUN'],
$this->_chars['SHADDA']
);
return str_replace($tashkeel, "", $text);
}
|
php
|
public function stripTashkeel($text)
{
$tashkeel = array(
$this->_chars['FATHATAN'],
$this->_chars['DAMMATAN'],
$this->_chars['KASRATAN'],
$this->_chars['FATHA'],
$this->_chars['DAMMA'],
$this->_chars['KASRA'],
$this->_chars['SUKUN'],
$this->_chars['SHADDA']
);
return str_replace($tashkeel, "", $text);
}
|
[
"public",
"function",
"stripTashkeel",
"(",
"$",
"text",
")",
"{",
"$",
"tashkeel",
"=",
"array",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'FATHATAN'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'DAMMATAN'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'KASRATAN'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'FATHA'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'DAMMA'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'KASRA'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'SUKUN'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'SHADDA'",
"]",
")",
";",
"return",
"str_replace",
"(",
"$",
"tashkeel",
",",
"\"\"",
",",
"$",
"text",
")",
";",
"}"
] |
Strip all tashkeel characters from an Arabic text.
@param string $text The text to be stripped.
@return string the stripped text.
@author Djihed Afifi <djihed@gmail.com>
|
[
"Strip",
"all",
"tashkeel",
"characters",
"from",
"an",
"Arabic",
"text",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L143-L156
|
227,785
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.normaliseHamza
|
public function normaliseHamza($text)
{
$replace = array(
$this->_chars['WAW_HAMZA'] => $this->_chars['WAW'],
$this->_chars['YEH_HAMZA'] => $this->_chars['YEH'],
);
$alephs = array(
$this->_chars['ALEF_MADDA'],
$this->_chars['ALEF_HAMZA_ABOVE'],
$this->_chars['ALEF_HAMZA_BELOW'],
$this->_chars['HAMZA_ABOVE'],
$this->_chars['HAMZA_BELOW']
);
$text = str_replace(array_keys($replace), array_values($replace), $text);
$text = str_replace($alephs, $this->_chars['ALEF'], $text);
return $text;
}
|
php
|
public function normaliseHamza($text)
{
$replace = array(
$this->_chars['WAW_HAMZA'] => $this->_chars['WAW'],
$this->_chars['YEH_HAMZA'] => $this->_chars['YEH'],
);
$alephs = array(
$this->_chars['ALEF_MADDA'],
$this->_chars['ALEF_HAMZA_ABOVE'],
$this->_chars['ALEF_HAMZA_BELOW'],
$this->_chars['HAMZA_ABOVE'],
$this->_chars['HAMZA_BELOW']
);
$text = str_replace(array_keys($replace), array_values($replace), $text);
$text = str_replace($alephs, $this->_chars['ALEF'], $text);
return $text;
}
|
[
"public",
"function",
"normaliseHamza",
"(",
"$",
"text",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'WAW_HAMZA'",
"]",
"=>",
"$",
"this",
"->",
"_chars",
"[",
"'WAW'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'YEH_HAMZA'",
"]",
"=>",
"$",
"this",
"->",
"_chars",
"[",
"'YEH'",
"]",
",",
")",
";",
"$",
"alephs",
"=",
"array",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'ALEF_MADDA'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'ALEF_HAMZA_ABOVE'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'ALEF_HAMZA_BELOW'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'HAMZA_ABOVE'",
"]",
",",
"$",
"this",
"->",
"_chars",
"[",
"'HAMZA_BELOW'",
"]",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"alephs",
",",
"$",
"this",
"->",
"_chars",
"[",
"'ALEF'",
"]",
",",
"$",
"text",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Normalise all Hamza characters to their corresponding aleph
character in an Arabic text.
@param string $text The text to be normalised.
@return string the normalised text.
@author Djihed Afifi <djihed@gmail.com>
|
[
"Normalise",
"all",
"Hamza",
"characters",
"to",
"their",
"corresponding",
"aleph",
"character",
"in",
"an",
"Arabic",
"text",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L167-L184
|
227,786
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.normaliseLamaleph
|
public function normaliseLamaleph ($text)
{
$text = str_replace(
$this->_chars['LAM_ALEPH'],
$simple_LAM_ALEPH,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_HAMZA_ABOVE'],
$simple_LAM_ALEPH_HAMZA_ABOVE,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_HAMZA_BELOW'],
$simple_LAM_ALEPH_HAMZA_BELOW,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_MADDA_ABOVE'],
$simple_LAM_ALEPH_MADDA_ABOVE,
$text
);
return $text;
}
|
php
|
public function normaliseLamaleph ($text)
{
$text = str_replace(
$this->_chars['LAM_ALEPH'],
$simple_LAM_ALEPH,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_HAMZA_ABOVE'],
$simple_LAM_ALEPH_HAMZA_ABOVE,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_HAMZA_BELOW'],
$simple_LAM_ALEPH_HAMZA_BELOW,
$text
);
$text = str_replace(
$this->_chars['LAM_ALEPH_MADDA_ABOVE'],
$simple_LAM_ALEPH_MADDA_ABOVE,
$text
);
return $text;
}
|
[
"public",
"function",
"normaliseLamaleph",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'LAM_ALEPH'",
"]",
",",
"$",
"simple_LAM_ALEPH",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'LAM_ALEPH_HAMZA_ABOVE'",
"]",
",",
"$",
"simple_LAM_ALEPH_HAMZA_ABOVE",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'LAM_ALEPH_HAMZA_BELOW'",
"]",
",",
"$",
"simple_LAM_ALEPH_HAMZA_BELOW",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"_chars",
"[",
"'LAM_ALEPH_MADDA_ABOVE'",
"]",
",",
"$",
"simple_LAM_ALEPH_MADDA_ABOVE",
",",
"$",
"text",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Unicode uses some special characters where the lamaleph and any
hamza above them are combined into one code point. Some input
system use them. This function expands these characters.
@param string $text The text to be normalised.
@return string the normalised text.
@author Djihed Afifi <djihed@gmail.com>
|
[
"Unicode",
"uses",
"some",
"special",
"characters",
"where",
"the",
"lamaleph",
"and",
"any",
"hamza",
"above",
"them",
"are",
"combined",
"into",
"one",
"code",
"point",
".",
"Some",
"input",
"system",
"use",
"them",
".",
"This",
"function",
"expands",
"these",
"characters",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L196-L219
|
227,787
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.normalise
|
public function normalise($text)
{
$text = $this->stripTashkeel($text);
$text = $this->stripTatweel($text);
$text = $this->normaliseHamza($text);
// $text = $this->normaliseLamaleph($text);
return $text;
}
|
php
|
public function normalise($text)
{
$text = $this->stripTashkeel($text);
$text = $this->stripTatweel($text);
$text = $this->normaliseHamza($text);
// $text = $this->normaliseLamaleph($text);
return $text;
}
|
[
"public",
"function",
"normalise",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"stripTashkeel",
"(",
"$",
"text",
")",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"stripTatweel",
"(",
"$",
"text",
")",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"normaliseHamza",
"(",
"$",
"text",
")",
";",
"// $text = $this->normaliseLamaleph($text);",
"return",
"$",
"text",
";",
"}"
] |
Takes a string, it applies the various filters in this class
to return a unicode normalised string suitable for activities
such as searching, indexing, etc.
@param string $text the text to be normalised.
@return string the result normalised string.
@author Djihed Afifi <djihed@gmail.com>
|
[
"Takes",
"a",
"string",
"it",
"applies",
"the",
"various",
"filters",
"in",
"this",
"class",
"to",
"return",
"a",
"unicode",
"normalised",
"string",
"suitable",
"for",
"activities",
"such",
"as",
"searching",
"indexing",
"etc",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L244-L252
|
227,788
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.utf8Strrev
|
public function utf8Strrev($str, $reverse_numbers = false)
{
preg_match_all('/./us', $str, $ar);
if ($reverse_numbers) {
return join('', array_reverse($ar[0]));
} else {
$temp = array();
foreach ($ar[0] as $value) {
if (is_numeric($value) && !empty($temp[0]) && is_numeric($temp[0])) {
foreach ($temp as $key => $value2) {
if (is_numeric($value2)) {
$pos = ($key + 1);
} else {
break;
}
}
$temp2 = array_splice($temp, $pos);
$temp = array_merge($temp, array($value), $temp2);
} else {
array_unshift($temp, $value);
}
}
return implode('', $temp);
}
}
|
php
|
public function utf8Strrev($str, $reverse_numbers = false)
{
preg_match_all('/./us', $str, $ar);
if ($reverse_numbers) {
return join('', array_reverse($ar[0]));
} else {
$temp = array();
foreach ($ar[0] as $value) {
if (is_numeric($value) && !empty($temp[0]) && is_numeric($temp[0])) {
foreach ($temp as $key => $value2) {
if (is_numeric($value2)) {
$pos = ($key + 1);
} else {
break;
}
}
$temp2 = array_splice($temp, $pos);
$temp = array_merge($temp, array($value), $temp2);
} else {
array_unshift($temp, $value);
}
}
return implode('', $temp);
}
}
|
[
"public",
"function",
"utf8Strrev",
"(",
"$",
"str",
",",
"$",
"reverse_numbers",
"=",
"false",
")",
"{",
"preg_match_all",
"(",
"'/./us'",
",",
"$",
"str",
",",
"$",
"ar",
")",
";",
"if",
"(",
"$",
"reverse_numbers",
")",
"{",
"return",
"join",
"(",
"''",
",",
"array_reverse",
"(",
"$",
"ar",
"[",
"0",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"temp",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"ar",
"[",
"0",
"]",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
"&&",
"!",
"empty",
"(",
"$",
"temp",
"[",
"0",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"temp",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"temp",
"as",
"$",
"key",
"=>",
"$",
"value2",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value2",
")",
")",
"{",
"$",
"pos",
"=",
"(",
"$",
"key",
"+",
"1",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"$",
"temp2",
"=",
"array_splice",
"(",
"$",
"temp",
",",
"$",
"pos",
")",
";",
"$",
"temp",
"=",
"array_merge",
"(",
"$",
"temp",
",",
"array",
"(",
"$",
"value",
")",
",",
"$",
"temp2",
")",
";",
"}",
"else",
"{",
"array_unshift",
"(",
"$",
"temp",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"''",
",",
"$",
"temp",
")",
";",
"}",
"}"
] |
Take a UTF8 string and reverse it.
@param string $str the string to be reversed.
@param boolean $reverse_numbers whether to reverse numbers.
@return string The reversed string.
|
[
"Take",
"a",
"UTF8",
"string",
"and",
"reverse",
"it",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L287-L311
|
227,789
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Normalise.php
|
Normalise.charName
|
public function charName($archar)
{
$key = array_search($archar, $this->_chars);
$name = $this->_charArNames["$key"];
return $name;
}
|
php
|
public function charName($archar)
{
$key = array_search($archar, $this->_chars);
$name = $this->_charArNames["$key"];
return $name;
}
|
[
"public",
"function",
"charName",
"(",
"$",
"archar",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"archar",
",",
"$",
"this",
"->",
"_chars",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"_charArNames",
"[",
"\"$key\"",
"]",
";",
"return",
"$",
"name",
";",
"}"
] |
Return Arabic letter name in arabic.
@param string $archar Arabic unicode char
@return string Arabic letter name in arabic
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Return",
"Arabic",
"letter",
"name",
"in",
"arabic",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Normalise.php#L619-L626
|
227,790
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Glyphs.php
|
Glyphs.a4MaxChars
|
public function a4MaxChars($font)
{
$x = 381.6 - 31.57 * $font + 1.182 * pow($font, 2) - 0.02052 *
pow($font, 3) + 0.0001342 * pow($font, 4);
return floor($x - 2);
}
|
php
|
public function a4MaxChars($font)
{
$x = 381.6 - 31.57 * $font + 1.182 * pow($font, 2) - 0.02052 *
pow($font, 3) + 0.0001342 * pow($font, 4);
return floor($x - 2);
}
|
[
"public",
"function",
"a4MaxChars",
"(",
"$",
"font",
")",
"{",
"$",
"x",
"=",
"381.6",
"-",
"31.57",
"*",
"$",
"font",
"+",
"1.182",
"*",
"pow",
"(",
"$",
"font",
",",
"2",
")",
"-",
"0.02052",
"*",
"pow",
"(",
"$",
"font",
",",
"3",
")",
"+",
"0.0001342",
"*",
"pow",
"(",
"$",
"font",
",",
"4",
")",
";",
"return",
"floor",
"(",
"$",
"x",
"-",
"2",
")",
";",
"}"
] |
Regression analysis calculate roughly the max number of character fit in
one A4 page line for a given font size.
@param integer $font Font size
@return integer Maximum number of characters per line
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Regression",
"analysis",
"calculate",
"roughly",
"the",
"max",
"number",
"of",
"character",
"fit",
"in",
"one",
"A4",
"page",
"line",
"for",
"a",
"given",
"font",
"size",
"."
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Glyphs.php#L320-L325
|
227,791
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Glyphs.php
|
Glyphs.a4Lines
|
public function a4Lines($str, $font)
{
$str = str_replace(array("\r\n", "\n", "\r"), "\n", $str);
$lines = 0;
$chars = 0;
$words = explode(' ', $str);
$w_count = count($words);
$max_chars = $this->a4MaxChars($font);
for ($i = 0; $i < $w_count; $i++) {
$w_len = mb_strlen($words[$i]) + 1;
if ($chars + $w_len < $max_chars) {
if (mb_strpos($words[$i], "\n") !== false) {
$words_nl = explode("\n", $words[$i]);
$nl_num = count($words_nl) - 1;
for ($j = 1; $j < $nl_num; $j++) {
$lines++;
}
$chars = mb_strlen($words_nl[$nl_num]) + 1;
} else {
$chars += $w_len;
}
} else {
$lines++;
$chars = $w_len;
}
}
$lines++;
return $lines;
}
|
php
|
public function a4Lines($str, $font)
{
$str = str_replace(array("\r\n", "\n", "\r"), "\n", $str);
$lines = 0;
$chars = 0;
$words = explode(' ', $str);
$w_count = count($words);
$max_chars = $this->a4MaxChars($font);
for ($i = 0; $i < $w_count; $i++) {
$w_len = mb_strlen($words[$i]) + 1;
if ($chars + $w_len < $max_chars) {
if (mb_strpos($words[$i], "\n") !== false) {
$words_nl = explode("\n", $words[$i]);
$nl_num = count($words_nl) - 1;
for ($j = 1; $j < $nl_num; $j++) {
$lines++;
}
$chars = mb_strlen($words_nl[$nl_num]) + 1;
} else {
$chars += $w_len;
}
} else {
$lines++;
$chars = $w_len;
}
}
$lines++;
return $lines;
}
|
[
"public",
"function",
"a4Lines",
"(",
"$",
"str",
",",
"$",
"font",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\\n\"",
",",
"$",
"str",
")",
";",
"$",
"lines",
"=",
"0",
";",
"$",
"chars",
"=",
"0",
";",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"str",
")",
";",
"$",
"w_count",
"=",
"count",
"(",
"$",
"words",
")",
";",
"$",
"max_chars",
"=",
"$",
"this",
"->",
"a4MaxChars",
"(",
"$",
"font",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"w_count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"w_len",
"=",
"mb_strlen",
"(",
"$",
"words",
"[",
"$",
"i",
"]",
")",
"+",
"1",
";",
"if",
"(",
"$",
"chars",
"+",
"$",
"w_len",
"<",
"$",
"max_chars",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"words",
"[",
"$",
"i",
"]",
",",
"\"\\n\"",
")",
"!==",
"false",
")",
"{",
"$",
"words_nl",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"words",
"[",
"$",
"i",
"]",
")",
";",
"$",
"nl_num",
"=",
"count",
"(",
"$",
"words_nl",
")",
"-",
"1",
";",
"for",
"(",
"$",
"j",
"=",
"1",
";",
"$",
"j",
"<",
"$",
"nl_num",
";",
"$",
"j",
"++",
")",
"{",
"$",
"lines",
"++",
";",
"}",
"$",
"chars",
"=",
"mb_strlen",
"(",
"$",
"words_nl",
"[",
"$",
"nl_num",
"]",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"chars",
"+=",
"$",
"w_len",
";",
"}",
"}",
"else",
"{",
"$",
"lines",
"++",
";",
"$",
"chars",
"=",
"$",
"w_len",
";",
"}",
"}",
"$",
"lines",
"++",
";",
"return",
"$",
"lines",
";",
"}"
] |
Calculate the lines number of given Arabic text and font size that will
fit in A4 page size
@param string $str Arabic string you would like to split it into lines
@param integer $font Font size
@return integer Number of lines for a given Arabic string in A4 page size
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Calculate",
"the",
"lines",
"number",
"of",
"given",
"Arabic",
"text",
"and",
"font",
"size",
"that",
"will",
"fit",
"in",
"A4",
"page",
"size"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Glyphs.php#L337-L371
|
227,792
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Glyphs.php
|
Glyphs.decodeEntities2
|
protected function decodeEntities2(
$prefix, $codepoint, $original, &$table, &$exclude
) {
// Named entity
if (!$prefix) {
if (isset($table[$original])) {
return $table[$original];
} else {
return $original;
}
}
// Hexadecimal numerical entity
if ($prefix == '#x') {
$codepoint = base_convert($codepoint, 16, 10);
}
// Encode codepoint as UTF-8 bytes
if ($codepoint < 0x80) {
$str = chr($codepoint);
} elseif ($codepoint < 0x800) {
$str = chr(0xC0 | ($codepoint >> 6)) .
chr(0x80 | ($codepoint & 0x3F));
} elseif ($codepoint < 0x10000) {
$str = chr(0xE0 | ($codepoint >> 12)) .
chr(0x80 | (($codepoint >> 6) & 0x3F)) .
chr(0x80 | ($codepoint & 0x3F));
} elseif ($codepoint < 0x200000) {
$str = chr(0xF0 | ($codepoint >> 18)) .
chr(0x80 | (($codepoint >> 12) & 0x3F)) .
chr(0x80 | (($codepoint >> 6) & 0x3F)) .
chr(0x80 | ($codepoint & 0x3F));
}
// Check for excluded characters
if (in_array($str, $exclude)) {
return $original;
} else {
return $str;
}
}
|
php
|
protected function decodeEntities2(
$prefix, $codepoint, $original, &$table, &$exclude
) {
// Named entity
if (!$prefix) {
if (isset($table[$original])) {
return $table[$original];
} else {
return $original;
}
}
// Hexadecimal numerical entity
if ($prefix == '#x') {
$codepoint = base_convert($codepoint, 16, 10);
}
// Encode codepoint as UTF-8 bytes
if ($codepoint < 0x80) {
$str = chr($codepoint);
} elseif ($codepoint < 0x800) {
$str = chr(0xC0 | ($codepoint >> 6)) .
chr(0x80 | ($codepoint & 0x3F));
} elseif ($codepoint < 0x10000) {
$str = chr(0xE0 | ($codepoint >> 12)) .
chr(0x80 | (($codepoint >> 6) & 0x3F)) .
chr(0x80 | ($codepoint & 0x3F));
} elseif ($codepoint < 0x200000) {
$str = chr(0xF0 | ($codepoint >> 18)) .
chr(0x80 | (($codepoint >> 12) & 0x3F)) .
chr(0x80 | (($codepoint >> 6) & 0x3F)) .
chr(0x80 | ($codepoint & 0x3F));
}
// Check for excluded characters
if (in_array($str, $exclude)) {
return $original;
} else {
return $str;
}
}
|
[
"protected",
"function",
"decodeEntities2",
"(",
"$",
"prefix",
",",
"$",
"codepoint",
",",
"$",
"original",
",",
"&",
"$",
"table",
",",
"&",
"$",
"exclude",
")",
"{",
"// Named entity",
"if",
"(",
"!",
"$",
"prefix",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"$",
"original",
"]",
")",
")",
"{",
"return",
"$",
"table",
"[",
"$",
"original",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"original",
";",
"}",
"}",
"// Hexadecimal numerical entity",
"if",
"(",
"$",
"prefix",
"==",
"'#x'",
")",
"{",
"$",
"codepoint",
"=",
"base_convert",
"(",
"$",
"codepoint",
",",
"16",
",",
"10",
")",
";",
"}",
"// Encode codepoint as UTF-8 bytes",
"if",
"(",
"$",
"codepoint",
"<",
"0x80",
")",
"{",
"$",
"str",
"=",
"chr",
"(",
"$",
"codepoint",
")",
";",
"}",
"elseif",
"(",
"$",
"codepoint",
"<",
"0x800",
")",
"{",
"$",
"str",
"=",
"chr",
"(",
"0xC0",
"|",
"(",
"$",
"codepoint",
">>",
"6",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"$",
"codepoint",
"&",
"0x3F",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"codepoint",
"<",
"0x10000",
")",
"{",
"$",
"str",
"=",
"chr",
"(",
"0xE0",
"|",
"(",
"$",
"codepoint",
">>",
"12",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"(",
"$",
"codepoint",
">>",
"6",
")",
"&",
"0x3F",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"$",
"codepoint",
"&",
"0x3F",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"codepoint",
"<",
"0x200000",
")",
"{",
"$",
"str",
"=",
"chr",
"(",
"0xF0",
"|",
"(",
"$",
"codepoint",
">>",
"18",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"(",
"$",
"codepoint",
">>",
"12",
")",
"&",
"0x3F",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"(",
"$",
"codepoint",
">>",
"6",
")",
"&",
"0x3F",
")",
")",
".",
"chr",
"(",
"0x80",
"|",
"(",
"$",
"codepoint",
"&",
"0x3F",
")",
")",
";",
"}",
"// Check for excluded characters",
"if",
"(",
"in_array",
"(",
"$",
"str",
",",
"$",
"exclude",
")",
")",
"{",
"return",
"$",
"original",
";",
"}",
"else",
"{",
"return",
"$",
"str",
";",
"}",
"}"
] |
Helper function for decodeEntities
@param string $prefix Prefix
@param string $codepoint Codepoint
@param string $original Original
@param array &$table Store named entities in a table
@param array &$exclude An array of characters which should not be decoded
@return string
|
[
"Helper",
"function",
"for",
"decodeEntities"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Glyphs.php#L616-L656
|
227,793
|
concrete5/doctrine-xml
|
src/Utilities.php
|
Utilities.stringToDOMDocument
|
public static function stringToDOMDocument($xml, $filename = '')
{
$preUseInternalErrors = libxml_use_internal_errors(true);
try {
libxml_clear_errors();
$doc = new DOMDocument();
if (@$doc->loadXML($xml) === false) {
throw new Exception(empty($filename) ? 'Failed to parse xml' : ('Failed to load file '.$filename));
}
} catch (Exception $x) {
libxml_use_internal_errors($preUseInternalErrors);
libxml_clear_errors();
throw $x;
}
libxml_use_internal_errors($preUseInternalErrors);
return $doc;
}
|
php
|
public static function stringToDOMDocument($xml, $filename = '')
{
$preUseInternalErrors = libxml_use_internal_errors(true);
try {
libxml_clear_errors();
$doc = new DOMDocument();
if (@$doc->loadXML($xml) === false) {
throw new Exception(empty($filename) ? 'Failed to parse xml' : ('Failed to load file '.$filename));
}
} catch (Exception $x) {
libxml_use_internal_errors($preUseInternalErrors);
libxml_clear_errors();
throw $x;
}
libxml_use_internal_errors($preUseInternalErrors);
return $doc;
}
|
[
"public",
"static",
"function",
"stringToDOMDocument",
"(",
"$",
"xml",
",",
"$",
"filename",
"=",
"''",
")",
"{",
"$",
"preUseInternalErrors",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"try",
"{",
"libxml_clear_errors",
"(",
")",
";",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"if",
"(",
"@",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"xml",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"empty",
"(",
"$",
"filename",
")",
"?",
"'Failed to parse xml'",
":",
"(",
"'Failed to load file '",
".",
"$",
"filename",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"x",
")",
"{",
"libxml_use_internal_errors",
"(",
"$",
"preUseInternalErrors",
")",
";",
"libxml_clear_errors",
"(",
")",
";",
"throw",
"$",
"x",
";",
"}",
"libxml_use_internal_errors",
"(",
"$",
"preUseInternalErrors",
")",
";",
"return",
"$",
"doc",
";",
"}"
] |
Convert a string containing xml code to a DOMDocument.
@param string $xml The xml code
@param string $filename The name of the file from which the xml code has been read from
@return DOMDocument
|
[
"Convert",
"a",
"string",
"containing",
"xml",
"code",
"to",
"a",
"DOMDocument",
"."
] |
03f1209d42477070a58d29e5af15688b96c66b56
|
https://github.com/concrete5/doctrine-xml/blob/03f1209d42477070a58d29e5af15688b96c66b56/src/Utilities.php#L20-L37
|
227,794
|
concrete5/doctrine-xml
|
src/Utilities.php
|
Utilities.explainLibXmlErrors
|
public static function explainLibXmlErrors($filename = '')
{
$errors = libxml_get_errors();
$result = array();
if (empty($errors)) {
$result[] = 'Unknown libxml error';
} else {
foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
$level = 'Warning';
break;
case LIBXML_ERR_ERROR:
$level = 'Error';
break;
case LIBXML_ERR_FATAL:
$level = 'Fatal error';
break;
default:
$level = 'Unknown error';
break;
}
$description = $level.' '.trim($error->message);
if (!empty($filename)) {
$description .= "\n File: $filename";
}
$description .= "\n Line: {$error->line}";
$description .= "\n Code: {$error->code}";
$result[] = $description;
}
}
return $result;
}
|
php
|
public static function explainLibXmlErrors($filename = '')
{
$errors = libxml_get_errors();
$result = array();
if (empty($errors)) {
$result[] = 'Unknown libxml error';
} else {
foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
$level = 'Warning';
break;
case LIBXML_ERR_ERROR:
$level = 'Error';
break;
case LIBXML_ERR_FATAL:
$level = 'Fatal error';
break;
default:
$level = 'Unknown error';
break;
}
$description = $level.' '.trim($error->message);
if (!empty($filename)) {
$description .= "\n File: $filename";
}
$description .= "\n Line: {$error->line}";
$description .= "\n Code: {$error->code}";
$result[] = $description;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"explainLibXmlErrors",
"(",
"$",
"filename",
"=",
"''",
")",
"{",
"$",
"errors",
"=",
"libxml_get_errors",
"(",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'Unknown libxml error'",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"switch",
"(",
"$",
"error",
"->",
"level",
")",
"{",
"case",
"LIBXML_ERR_WARNING",
":",
"$",
"level",
"=",
"'Warning'",
";",
"break",
";",
"case",
"LIBXML_ERR_ERROR",
":",
"$",
"level",
"=",
"'Error'",
";",
"break",
";",
"case",
"LIBXML_ERR_FATAL",
":",
"$",
"level",
"=",
"'Fatal error'",
";",
"break",
";",
"default",
":",
"$",
"level",
"=",
"'Unknown error'",
";",
"break",
";",
"}",
"$",
"description",
"=",
"$",
"level",
".",
"' '",
".",
"trim",
"(",
"$",
"error",
"->",
"message",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"description",
".=",
"\"\\n File: $filename\"",
";",
"}",
"$",
"description",
".=",
"\"\\n Line: {$error->line}\"",
";",
"$",
"description",
".=",
"\"\\n Code: {$error->code}\"",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"description",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Explain the libxml errors encountered.
@param string $filename The name of the file to which the errors are related.
@return string[]
|
[
"Explain",
"the",
"libxml",
"errors",
"encountered",
"."
] |
03f1209d42477070a58d29e5af15688b96c66b56
|
https://github.com/concrete5/doctrine-xml/blob/03f1209d42477070a58d29e5af15688b96c66b56/src/Utilities.php#L45-L78
|
227,795
|
movim/moxl
|
src/Moxl/Xec/Handler.php
|
Handler.handle
|
static public function handle($child)
{
$_instances = 'empty';
$id = '';
$element = '';
// Id verification in the returned stanza
if(in_array($child->getName(), ['iq', 'presence', 'message'])) {
$id = (string)$child->attributes()->id;
}
$sess = Session::start();
if(
($id != '' &&
$sess->get($id) == false) ||
$id == ''
) {
Utils::log("Handler : Memory instance not found for {$id}");
Utils::log('Handler : Not an XMPP ACK');
Handler::handleNode($child);
foreach($child->children() as $s1) {
Handler::handleNode($s1, $child);
foreach($s1->children() as $s2) {
Handler::handleNode($s2, $child);
}
}
} elseif(
$id != '' &&
$sess->get($id) != false
) {
// We search an existent instance
Utils::log("Handler : Memory instance found for {$id}");
$instance = $sess->get($id);
$action = unserialize($instance->object);
$error = false;
// Handle specific query error
if($child->query->error)
$error = $child->query->error;
elseif($child->error)
$error = $child->error;
// XMPP returned an error
if($error) {
$errors = $error->children();
$errorid = Handler::formatError($errors->getName());
$message = false;
if($error->text)
$message = (string)$error->text;
Utils::log('Handler : '.get_class($action).' '.$id.' - '.$errorid);
/* If the action has defined a special handler
* for this error
*/
if(method_exists($action, $errorid)) {
$action->method($errorid);
$action->$errorid($errorid, $message);
}
// We also call a global error handler
if(method_exists($action, 'error')) {
Utils::log('Handler : Global error - '.$id.' - '.$errorid);
$action->method('error');
$action->error($errorid, $message);
}
} else {
// We launch the object handle
$action->method('handle');
$action->handle($child);
}
// We clean the object from the cache
$sess->remove($id);
}
}
|
php
|
static public function handle($child)
{
$_instances = 'empty';
$id = '';
$element = '';
// Id verification in the returned stanza
if(in_array($child->getName(), ['iq', 'presence', 'message'])) {
$id = (string)$child->attributes()->id;
}
$sess = Session::start();
if(
($id != '' &&
$sess->get($id) == false) ||
$id == ''
) {
Utils::log("Handler : Memory instance not found for {$id}");
Utils::log('Handler : Not an XMPP ACK');
Handler::handleNode($child);
foreach($child->children() as $s1) {
Handler::handleNode($s1, $child);
foreach($s1->children() as $s2) {
Handler::handleNode($s2, $child);
}
}
} elseif(
$id != '' &&
$sess->get($id) != false
) {
// We search an existent instance
Utils::log("Handler : Memory instance found for {$id}");
$instance = $sess->get($id);
$action = unserialize($instance->object);
$error = false;
// Handle specific query error
if($child->query->error)
$error = $child->query->error;
elseif($child->error)
$error = $child->error;
// XMPP returned an error
if($error) {
$errors = $error->children();
$errorid = Handler::formatError($errors->getName());
$message = false;
if($error->text)
$message = (string)$error->text;
Utils::log('Handler : '.get_class($action).' '.$id.' - '.$errorid);
/* If the action has defined a special handler
* for this error
*/
if(method_exists($action, $errorid)) {
$action->method($errorid);
$action->$errorid($errorid, $message);
}
// We also call a global error handler
if(method_exists($action, 'error')) {
Utils::log('Handler : Global error - '.$id.' - '.$errorid);
$action->method('error');
$action->error($errorid, $message);
}
} else {
// We launch the object handle
$action->method('handle');
$action->handle($child);
}
// We clean the object from the cache
$sess->remove($id);
}
}
|
[
"static",
"public",
"function",
"handle",
"(",
"$",
"child",
")",
"{",
"$",
"_instances",
"=",
"'empty'",
";",
"$",
"id",
"=",
"''",
";",
"$",
"element",
"=",
"''",
";",
"// Id verification in the returned stanza",
"if",
"(",
"in_array",
"(",
"$",
"child",
"->",
"getName",
"(",
")",
",",
"[",
"'iq'",
",",
"'presence'",
",",
"'message'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"child",
"->",
"attributes",
"(",
")",
"->",
"id",
";",
"}",
"$",
"sess",
"=",
"Session",
"::",
"start",
"(",
")",
";",
"if",
"(",
"(",
"$",
"id",
"!=",
"''",
"&&",
"$",
"sess",
"->",
"get",
"(",
"$",
"id",
")",
"==",
"false",
")",
"||",
"$",
"id",
"==",
"''",
")",
"{",
"Utils",
"::",
"log",
"(",
"\"Handler : Memory instance not found for {$id}\"",
")",
";",
"Utils",
"::",
"log",
"(",
"'Handler : Not an XMPP ACK'",
")",
";",
"Handler",
"::",
"handleNode",
"(",
"$",
"child",
")",
";",
"foreach",
"(",
"$",
"child",
"->",
"children",
"(",
")",
"as",
"$",
"s1",
")",
"{",
"Handler",
"::",
"handleNode",
"(",
"$",
"s1",
",",
"$",
"child",
")",
";",
"foreach",
"(",
"$",
"s1",
"->",
"children",
"(",
")",
"as",
"$",
"s2",
")",
"{",
"Handler",
"::",
"handleNode",
"(",
"$",
"s2",
",",
"$",
"child",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"id",
"!=",
"''",
"&&",
"$",
"sess",
"->",
"get",
"(",
"$",
"id",
")",
"!=",
"false",
")",
"{",
"// We search an existent instance",
"Utils",
"::",
"log",
"(",
"\"Handler : Memory instance found for {$id}\"",
")",
";",
"$",
"instance",
"=",
"$",
"sess",
"->",
"get",
"(",
"$",
"id",
")",
";",
"$",
"action",
"=",
"unserialize",
"(",
"$",
"instance",
"->",
"object",
")",
";",
"$",
"error",
"=",
"false",
";",
"// Handle specific query error",
"if",
"(",
"$",
"child",
"->",
"query",
"->",
"error",
")",
"$",
"error",
"=",
"$",
"child",
"->",
"query",
"->",
"error",
";",
"elseif",
"(",
"$",
"child",
"->",
"error",
")",
"$",
"error",
"=",
"$",
"child",
"->",
"error",
";",
"// XMPP returned an error",
"if",
"(",
"$",
"error",
")",
"{",
"$",
"errors",
"=",
"$",
"error",
"->",
"children",
"(",
")",
";",
"$",
"errorid",
"=",
"Handler",
"::",
"formatError",
"(",
"$",
"errors",
"->",
"getName",
"(",
")",
")",
";",
"$",
"message",
"=",
"false",
";",
"if",
"(",
"$",
"error",
"->",
"text",
")",
"$",
"message",
"=",
"(",
"string",
")",
"$",
"error",
"->",
"text",
";",
"Utils",
"::",
"log",
"(",
"'Handler : '",
".",
"get_class",
"(",
"$",
"action",
")",
".",
"' '",
".",
"$",
"id",
".",
"' - '",
".",
"$",
"errorid",
")",
";",
"/* If the action has defined a special handler\n * for this error\n */",
"if",
"(",
"method_exists",
"(",
"$",
"action",
",",
"$",
"errorid",
")",
")",
"{",
"$",
"action",
"->",
"method",
"(",
"$",
"errorid",
")",
";",
"$",
"action",
"->",
"$",
"errorid",
"(",
"$",
"errorid",
",",
"$",
"message",
")",
";",
"}",
"// We also call a global error handler",
"if",
"(",
"method_exists",
"(",
"$",
"action",
",",
"'error'",
")",
")",
"{",
"Utils",
"::",
"log",
"(",
"'Handler : Global error - '",
".",
"$",
"id",
".",
"' - '",
".",
"$",
"errorid",
")",
";",
"$",
"action",
"->",
"method",
"(",
"'error'",
")",
";",
"$",
"action",
"->",
"error",
"(",
"$",
"errorid",
",",
"$",
"message",
")",
";",
"}",
"}",
"else",
"{",
"// We launch the object handle",
"$",
"action",
"->",
"method",
"(",
"'handle'",
")",
";",
"$",
"action",
"->",
"handle",
"(",
"$",
"child",
")",
";",
"}",
"// We clean the object from the cache",
"$",
"sess",
"->",
"remove",
"(",
"$",
"id",
")",
";",
"}",
"}"
] |
Constructor of class Handler.
@return void
|
[
"Constructor",
"of",
"class",
"Handler",
"."
] |
bfe3e1d83ef3bbbd270150f2f1164e8a662ef716
|
https://github.com/movim/moxl/blob/bfe3e1d83ef3bbbd270150f2f1164e8a662ef716/src/Moxl/Xec/Handler.php#L41-L123
|
227,796
|
gorriecoe/silverstripe-embed
|
src/extensions/Embeddable.php
|
Embeddable.setEmbedClass
|
public function setEmbedClass($class)
{
$classes = ($class) ? explode(' ', $class) : [];
foreach ($classes as $key => $value) {
$this->classes[$value] = $value;
}
return $this->owner;
}
|
php
|
public function setEmbedClass($class)
{
$classes = ($class) ? explode(' ', $class) : [];
foreach ($classes as $key => $value) {
$this->classes[$value] = $value;
}
return $this->owner;
}
|
[
"public",
"function",
"setEmbedClass",
"(",
"$",
"class",
")",
"{",
"$",
"classes",
"=",
"(",
"$",
"class",
")",
"?",
"explode",
"(",
"' '",
",",
"$",
"class",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"classes",
"[",
"$",
"value",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"owner",
";",
"}"
] |
Set CSS classes for templates
@param string $class CSS classes.
@return DataObject Owner
|
[
"Set",
"CSS",
"classes",
"for",
"templates"
] |
757d10a5bc906cc9bdcf2c8278dfc07fa06c2335
|
https://github.com/gorriecoe/silverstripe-embed/blob/757d10a5bc906cc9bdcf2c8278dfc07fa06c2335/src/extensions/Embeddable.php#L258-L265
|
227,797
|
gorriecoe/silverstripe-embed
|
src/extensions/Embeddable.php
|
Embeddable.getEmbed
|
public function getEmbed()
{
$owner = $this->owner;
$title = $owner->EmbedTitle;
$class = $owner->EmbedClass;
$type = $owner->EmbedType;
$template = $this->template;
$embedHTML = $owner->EmbedHTML;
$sourceURL = $owner->EmbedSourceURL;
$templates = [];
if ($type) {
$templates[] = $template . '_' . $type;
}
$templates[] = $template;
if (SSViewer::hasTemplate($templates)) {
return $owner->renderWith($templates);
}
switch ($type) {
case 'video':
case 'rich':
$html = HTMLTag::create($embedHTML, 'div');
break;
case 'link':
$html = HTMLTag::create($title, 'a')->setAttribute('href', $sourceURL);
break;
case 'photo':
$html = HTMLTag::create($sourceURL, 'img')->setAttribute([
'width' => $this->Width,
'height' => $this->Height,
'alt' => $title
]);
break;
}
return $html->setClass($class);
}
|
php
|
public function getEmbed()
{
$owner = $this->owner;
$title = $owner->EmbedTitle;
$class = $owner->EmbedClass;
$type = $owner->EmbedType;
$template = $this->template;
$embedHTML = $owner->EmbedHTML;
$sourceURL = $owner->EmbedSourceURL;
$templates = [];
if ($type) {
$templates[] = $template . '_' . $type;
}
$templates[] = $template;
if (SSViewer::hasTemplate($templates)) {
return $owner->renderWith($templates);
}
switch ($type) {
case 'video':
case 'rich':
$html = HTMLTag::create($embedHTML, 'div');
break;
case 'link':
$html = HTMLTag::create($title, 'a')->setAttribute('href', $sourceURL);
break;
case 'photo':
$html = HTMLTag::create($sourceURL, 'img')->setAttribute([
'width' => $this->Width,
'height' => $this->Height,
'alt' => $title
]);
break;
}
return $html->setClass($class);
}
|
[
"public",
"function",
"getEmbed",
"(",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"title",
"=",
"$",
"owner",
"->",
"EmbedTitle",
";",
"$",
"class",
"=",
"$",
"owner",
"->",
"EmbedClass",
";",
"$",
"type",
"=",
"$",
"owner",
"->",
"EmbedType",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"template",
";",
"$",
"embedHTML",
"=",
"$",
"owner",
"->",
"EmbedHTML",
";",
"$",
"sourceURL",
"=",
"$",
"owner",
"->",
"EmbedSourceURL",
";",
"$",
"templates",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"templates",
"[",
"]",
"=",
"$",
"template",
".",
"'_'",
".",
"$",
"type",
";",
"}",
"$",
"templates",
"[",
"]",
"=",
"$",
"template",
";",
"if",
"(",
"SSViewer",
"::",
"hasTemplate",
"(",
"$",
"templates",
")",
")",
"{",
"return",
"$",
"owner",
"->",
"renderWith",
"(",
"$",
"templates",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'video'",
":",
"case",
"'rich'",
":",
"$",
"html",
"=",
"HTMLTag",
"::",
"create",
"(",
"$",
"embedHTML",
",",
"'div'",
")",
";",
"break",
";",
"case",
"'link'",
":",
"$",
"html",
"=",
"HTMLTag",
"::",
"create",
"(",
"$",
"title",
",",
"'a'",
")",
"->",
"setAttribute",
"(",
"'href'",
",",
"$",
"sourceURL",
")",
";",
"break",
";",
"case",
"'photo'",
":",
"$",
"html",
"=",
"HTMLTag",
"::",
"create",
"(",
"$",
"sourceURL",
",",
"'img'",
")",
"->",
"setAttribute",
"(",
"[",
"'width'",
"=>",
"$",
"this",
"->",
"Width",
",",
"'height'",
"=>",
"$",
"this",
"->",
"Height",
",",
"'alt'",
"=>",
"$",
"title",
"]",
")",
";",
"break",
";",
"}",
"return",
"$",
"html",
"->",
"setClass",
"(",
"$",
"class",
")",
";",
"}"
] |
Renders embed into appropriate template HTML
@return HTML
|
[
"Renders",
"embed",
"into",
"appropriate",
"template",
"HTML"
] |
757d10a5bc906cc9bdcf2c8278dfc07fa06c2335
|
https://github.com/gorriecoe/silverstripe-embed/blob/757d10a5bc906cc9bdcf2c8278dfc07fa06c2335/src/extensions/Embeddable.php#L296-L330
|
227,798
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setRedirectUris
|
public function setRedirectUris(array $redirectUris = null)
{
ValidationUtility::ensureNullOrArrayOfString('$redirectUris', $redirectUris);
$this->redirectUris = $redirectUris;
return $this;
}
|
php
|
public function setRedirectUris(array $redirectUris = null)
{
ValidationUtility::ensureNullOrArrayOfString('$redirectUris', $redirectUris);
$this->redirectUris = $redirectUris;
return $this;
}
|
[
"public",
"function",
"setRedirectUris",
"(",
"array",
"$",
"redirectUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$redirectUris'",
",",
"$",
"redirectUris",
")",
";",
"$",
"this",
"->",
"redirectUris",
"=",
"$",
"redirectUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the redirect URIs.
See [3.1.2. Redirection Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1.2)
of [RFC 6749](https://tools.ietf.org/html/rfc6749) for details.
@param string[] $redirectUris
A string array containing redirect URIs.
@return Client
`$this` object.
|
[
"Set",
"the",
"redirect",
"URIs",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L361-L368
|
227,799
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setResponseTypes
|
public function setResponseTypes(array $responseTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$responseTypes', $responseTypes, '\Authlete\Types\ResponseType');
$this->responseTypes = $responseTypes;
return $this;
}
|
php
|
public function setResponseTypes(array $responseTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$responseTypes', $responseTypes, '\Authlete\Types\ResponseType');
$this->responseTypes = $responseTypes;
return $this;
}
|
[
"public",
"function",
"setResponseTypes",
"(",
"array",
"$",
"responseTypes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$responseTypes'",
",",
"$",
"responseTypes",
",",
"'\\Authlete\\Types\\ResponseType'",
")",
";",
"$",
"this",
"->",
"responseTypes",
"=",
"$",
"responseTypes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the "response_type" values that this client application is
declaring that it will restrict itself to using.
This corresponds to the `response_types` metadata defined in
[2. Client Metadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata)
of [OpenID Connect Dynamic Client Registration 1.0](https://openid.net/specs/openid-connect-registration-1_0.html).
@param ResponseType[] $responseTypes
An array of \Authlete\Types\ResponseType.
@return Client
`$this` object.
|
[
"Set",
"the",
"response_type",
"values",
"that",
"this",
"client",
"application",
"is",
"declaring",
"that",
"it",
"will",
"restrict",
"itself",
"to",
"using",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L402-L410
|
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.