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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
237,600
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isJson
|
public static function isJson($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
if (((string) $value) === 'null') {
return true;
}
return (json_decode((string) $value) !== null && json_last_error() === JSON_ERROR_NONE);
}
|
php
|
public static function isJson($value): bool
{
if (!static::isStringCastable($value)) {
return false;
}
if (((string) $value) === 'null') {
return true;
}
return (json_decode((string) $value) !== null && json_last_error() === JSON_ERROR_NONE);
}
|
[
"public",
"static",
"function",
"isJson",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"(",
"string",
")",
"$",
"value",
")",
"===",
"'null'",
")",
"{",
"return",
"true",
";",
"}",
"return",
"(",
"json_decode",
"(",
"(",
"string",
")",
"$",
"value",
")",
"!==",
"null",
"&&",
"json_last_error",
"(",
")",
"===",
"JSON_ERROR_NONE",
")",
";",
"}"
] |
Checks if value is a JSON string
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"is",
"a",
"JSON",
"string"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L564-L575
|
237,601
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isMatch
|
public static function isMatch($value, string $pattern): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return !!preg_match($pattern, (string) $value);
}
|
php
|
public static function isMatch($value, string $pattern): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return !!preg_match($pattern, (string) $value);
}
|
[
"public",
"static",
"function",
"isMatch",
"(",
"$",
"value",
",",
"string",
"$",
"pattern",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"}"
] |
Checks if value matches a regular expression
@param mixed $value The value
@param string $pattern The regex pattern
@return bool
|
[
"Checks",
"if",
"value",
"matches",
"a",
"regular",
"expression"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L585-L592
|
237,602
|
novuso/system
|
src/Utility/Validate.php
|
Validate.contains
|
public static function contains($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return mb_strpos((string) $value, $search, 0, $encoding) !== false;
}
|
php
|
public static function contains($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return mb_strpos((string) $value, $search, 0, $encoding) !== false;
}
|
[
"public",
"static",
"function",
"contains",
"(",
"$",
"value",
",",
"string",
"$",
"search",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"mb_strpos",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"search",
",",
"0",
",",
"$",
"encoding",
")",
"!==",
"false",
";",
"}"
] |
Checks if value contains a search string
@param mixed $value The value
@param string $search The search string
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"contains",
"a",
"search",
"string"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L603-L610
|
237,603
|
novuso/system
|
src/Utility/Validate.php
|
Validate.startsWith
|
public static function startsWith($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$searchlen = (int) mb_strlen($search, $encoding);
$start = mb_substr((string) $value, 0, $searchlen, $encoding);
return $search === $start;
}
|
php
|
public static function startsWith($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$searchlen = (int) mb_strlen($search, $encoding);
$start = mb_substr((string) $value, 0, $searchlen, $encoding);
return $search === $start;
}
|
[
"public",
"static",
"function",
"startsWith",
"(",
"$",
"value",
",",
"string",
"$",
"search",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"searchlen",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"$",
"search",
",",
"$",
"encoding",
")",
";",
"$",
"start",
"=",
"mb_substr",
"(",
"(",
"string",
")",
"$",
"value",
",",
"0",
",",
"$",
"searchlen",
",",
"$",
"encoding",
")",
";",
"return",
"$",
"search",
"===",
"$",
"start",
";",
"}"
] |
Checks if value starts with a search string
@param mixed $value The value
@param string $search The search string
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"starts",
"with",
"a",
"search",
"string"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L621-L631
|
237,604
|
novuso/system
|
src/Utility/Validate.php
|
Validate.endsWith
|
public static function endsWith($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$searchlen = (int) mb_strlen($search, $encoding);
$length = (int) mb_strlen((string) $value, $encoding);
$end = mb_substr((string) $value, $length - $searchlen, $searchlen, $encoding);
return $search === $end;
}
|
php
|
public static function endsWith($value, string $search, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$searchlen = (int) mb_strlen($search, $encoding);
$length = (int) mb_strlen((string) $value, $encoding);
$end = mb_substr((string) $value, $length - $searchlen, $searchlen, $encoding);
return $search === $end;
}
|
[
"public",
"static",
"function",
"endsWith",
"(",
"$",
"value",
",",
"string",
"$",
"search",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"searchlen",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"$",
"search",
",",
"$",
"encoding",
")",
";",
"$",
"length",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"encoding",
")",
";",
"$",
"end",
"=",
"mb_substr",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"length",
"-",
"$",
"searchlen",
",",
"$",
"searchlen",
",",
"$",
"encoding",
")",
";",
"return",
"$",
"search",
"===",
"$",
"end",
";",
"}"
] |
Checks if value ends with a search string
@param mixed $value The value
@param string $search The search string
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"ends",
"with",
"a",
"search",
"string"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L642-L653
|
237,605
|
novuso/system
|
src/Utility/Validate.php
|
Validate.exactLength
|
public static function exactLength($value, int $length, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
return $strlen === $length;
}
|
php
|
public static function exactLength($value, int $length, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
return $strlen === $length;
}
|
[
"public",
"static",
"function",
"exactLength",
"(",
"$",
"value",
",",
"int",
"$",
"length",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"strlen",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"encoding",
")",
";",
"return",
"$",
"strlen",
"===",
"$",
"length",
";",
"}"
] |
Checks if value has an exact string length
@param mixed $value The value
@param int $length The string length
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"has",
"an",
"exact",
"string",
"length"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L664-L673
|
237,606
|
novuso/system
|
src/Utility/Validate.php
|
Validate.minLength
|
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
return $strlen >= $minLength;
}
|
php
|
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
return $strlen >= $minLength;
}
|
[
"public",
"static",
"function",
"minLength",
"(",
"$",
"value",
",",
"int",
"$",
"minLength",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"strlen",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"encoding",
")",
";",
"return",
"$",
"strlen",
">=",
"$",
"minLength",
";",
"}"
] |
Checks if value has a string length greater or equal to a minimum
@param mixed $value The value
@param int $minLength The minimum length
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"has",
"a",
"string",
"length",
"greater",
"or",
"equal",
"to",
"a",
"minimum"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L684-L693
|
237,607
|
novuso/system
|
src/Utility/Validate.php
|
Validate.rangeLength
|
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
if ($strlen < $minLength) {
return false;
}
if ($strlen > $maxLength) {
return false;
}
return true;
}
|
php
|
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool
{
if (!static::isStringCastable($value)) {
return false;
}
$strlen = (int) mb_strlen((string) $value, $encoding);
if ($strlen < $minLength) {
return false;
}
if ($strlen > $maxLength) {
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"rangeLength",
"(",
"$",
"value",
",",
"int",
"$",
"minLength",
",",
"int",
"$",
"maxLength",
",",
"string",
"$",
"encoding",
"=",
"'UTF-8'",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"strlen",
"=",
"(",
"int",
")",
"mb_strlen",
"(",
"(",
"string",
")",
"$",
"value",
",",
"$",
"encoding",
")",
";",
"if",
"(",
"$",
"strlen",
"<",
"$",
"minLength",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"strlen",
">",
"$",
"maxLength",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if value has a string length within a range
@param mixed $value The value
@param int $minLength The minimum length
@param int $maxLength The maximum length
@param string $encoding The string encoding
@return bool
|
[
"Checks",
"if",
"value",
"has",
"a",
"string",
"length",
"within",
"a",
"range"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L725-L741
|
237,608
|
novuso/system
|
src/Utility/Validate.php
|
Validate.rangeNumber
|
public static function rangeNumber($value, $minNumber, $maxNumber): bool
{
if (!is_numeric($value)) {
return false;
}
if ($value < $minNumber) {
return false;
}
if ($value > $maxNumber) {
return false;
}
return true;
}
|
php
|
public static function rangeNumber($value, $minNumber, $maxNumber): bool
{
if (!is_numeric($value)) {
return false;
}
if ($value < $minNumber) {
return false;
}
if ($value > $maxNumber) {
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"rangeNumber",
"(",
"$",
"value",
",",
"$",
"minNumber",
",",
"$",
"maxNumber",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"value",
"<",
"$",
"minNumber",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"value",
">",
"$",
"maxNumber",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if value is within a numeric range
@param mixed $value The value
@param int|float $minNumber The minimum number
@param int|float $maxNumber The maximum number
@return bool
|
[
"Checks",
"if",
"value",
"is",
"within",
"a",
"numeric",
"range"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L803-L817
|
237,609
|
novuso/system
|
src/Utility/Validate.php
|
Validate.intValue
|
public static function intValue($value): bool
{
if (!is_numeric($value)) {
return false;
}
return strval(intval($value)) == $value;
}
|
php
|
public static function intValue($value): bool
{
if (!is_numeric($value)) {
return false;
}
return strval(intval($value)) == $value;
}
|
[
"public",
"static",
"function",
"intValue",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"strval",
"(",
"intval",
"(",
"$",
"value",
")",
")",
"==",
"$",
"value",
";",
"}"
] |
Checks if value can be cast to an integer without changing value
Passing values include integers, integer strings, and floating-point
numbers with integer values.
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"can",
"be",
"cast",
"to",
"an",
"integer",
"without",
"changing",
"value"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L865-L872
|
237,610
|
novuso/system
|
src/Utility/Validate.php
|
Validate.exactCount
|
public static function exactCount($value, int $count): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) == $count;
}
|
php
|
public static function exactCount($value, int $count): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) == $count;
}
|
[
"public",
"static",
"function",
"exactCount",
"(",
"$",
"value",
",",
"int",
"$",
"count",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isCountable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"$",
"value",
")",
"==",
"$",
"count",
";",
"}"
] |
Checks if value has an exact count
@param mixed $value The value
@param int $count The count
@return bool
|
[
"Checks",
"if",
"value",
"has",
"an",
"exact",
"count"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L882-L889
|
237,611
|
novuso/system
|
src/Utility/Validate.php
|
Validate.minCount
|
public static function minCount($value, int $minCount): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) >= $minCount;
}
|
php
|
public static function minCount($value, int $minCount): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) >= $minCount;
}
|
[
"public",
"static",
"function",
"minCount",
"(",
"$",
"value",
",",
"int",
"$",
"minCount",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isCountable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"$",
"value",
")",
">=",
"$",
"minCount",
";",
"}"
] |
Checks if value has a count greater or equal to a minimum
@param mixed $value The value
@param int $minCount The minimum count
@return bool
|
[
"Checks",
"if",
"value",
"has",
"a",
"count",
"greater",
"or",
"equal",
"to",
"a",
"minimum"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L899-L906
|
237,612
|
novuso/system
|
src/Utility/Validate.php
|
Validate.maxCount
|
public static function maxCount($value, int $maxCount): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) <= $maxCount;
}
|
php
|
public static function maxCount($value, int $maxCount): bool
{
if (!static::isCountable($value)) {
return false;
}
return count($value) <= $maxCount;
}
|
[
"public",
"static",
"function",
"maxCount",
"(",
"$",
"value",
",",
"int",
"$",
"maxCount",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isCountable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"$",
"value",
")",
"<=",
"$",
"maxCount",
";",
"}"
] |
Checks if value has a count less or equal to a maximum
@param mixed $value The value
@param int $maxCount The maximum count
@return bool
|
[
"Checks",
"if",
"value",
"has",
"a",
"count",
"less",
"or",
"equal",
"to",
"a",
"maximum"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L916-L923
|
237,613
|
novuso/system
|
src/Utility/Validate.php
|
Validate.rangeCount
|
public static function rangeCount($value, int $minCount, int $maxCount): bool
{
if (!static::isCountable($value)) {
return false;
}
$count = count($value);
if ($count < $minCount) {
return false;
}
if ($count > $maxCount) {
return false;
}
return true;
}
|
php
|
public static function rangeCount($value, int $minCount, int $maxCount): bool
{
if (!static::isCountable($value)) {
return false;
}
$count = count($value);
if ($count < $minCount) {
return false;
}
if ($count > $maxCount) {
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"rangeCount",
"(",
"$",
"value",
",",
"int",
"$",
"minCount",
",",
"int",
"$",
"maxCount",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isCountable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"count",
"=",
"count",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"count",
"<",
"$",
"minCount",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"count",
">",
"$",
"maxCount",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if value has a count within a range
@param mixed $value The value
@param int $minCount The minimum count
@param int $maxCount The maximum count
@return bool
|
[
"Checks",
"if",
"value",
"has",
"a",
"count",
"within",
"a",
"range"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L934-L950
|
237,614
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isOneOf
|
public static function isOneOf($value, iterable $choices): bool
{
foreach ($choices as $choice) {
if ($value === $choice) {
return true;
}
}
return false;
}
|
php
|
public static function isOneOf($value, iterable $choices): bool
{
foreach ($choices as $choice) {
if ($value === $choice) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"isOneOf",
"(",
"$",
"value",
",",
"iterable",
"$",
"choices",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"choice",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"$",
"choice",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if value is one of a set of choices
@param mixed $value The value
@param iterable $choices The choices
@return bool
|
[
"Checks",
"if",
"value",
"is",
"one",
"of",
"a",
"set",
"of",
"choices"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L960-L969
|
237,615
|
novuso/system
|
src/Utility/Validate.php
|
Validate.keyIsset
|
public static function keyIsset($value, $key): bool
{
if (!static::isArrayAccessible($value)) {
return false;
}
return isset($value[$key]);
}
|
php
|
public static function keyIsset($value, $key): bool
{
if (!static::isArrayAccessible($value)) {
return false;
}
return isset($value[$key]);
}
|
[
"public",
"static",
"function",
"keyIsset",
"(",
"$",
"value",
",",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isArrayAccessible",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isset",
"(",
"$",
"value",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Checks if value is array accessible with a non-null key
@param mixed $value The value
@param mixed $key The key
@return bool
|
[
"Checks",
"if",
"value",
"is",
"array",
"accessible",
"with",
"a",
"non",
"-",
"null",
"key"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L979-L986
|
237,616
|
novuso/system
|
src/Utility/Validate.php
|
Validate.keyNotEmpty
|
public static function keyNotEmpty($value, $key): bool
{
if (!static::isArrayAccessible($value)) {
return false;
}
return isset($value[$key]) && !empty($value[$key]);
}
|
php
|
public static function keyNotEmpty($value, $key): bool
{
if (!static::isArrayAccessible($value)) {
return false;
}
return isset($value[$key]) && !empty($value[$key]);
}
|
[
"public",
"static",
"function",
"keyNotEmpty",
"(",
"$",
"value",
",",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isArrayAccessible",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isset",
"(",
"$",
"value",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"value",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Checks if value is array accessible with a non-empty key
@param mixed $value The value
@param mixed $key The key
@return bool
|
[
"Checks",
"if",
"value",
"is",
"array",
"accessible",
"with",
"a",
"non",
"-",
"empty",
"key"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L996-L1003
|
237,617
|
novuso/system
|
src/Utility/Validate.php
|
Validate.areEqual
|
public static function areEqual($value1, $value2): bool
{
if (static::isEquatable($value1) && static::areSameType($value1, $value2)) {
return $value1->equals($value2);
}
return $value1 == $value2;
}
|
php
|
public static function areEqual($value1, $value2): bool
{
if (static::isEquatable($value1) && static::areSameType($value1, $value2)) {
return $value1->equals($value2);
}
return $value1 == $value2;
}
|
[
"public",
"static",
"function",
"areEqual",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
":",
"bool",
"{",
"if",
"(",
"static",
"::",
"isEquatable",
"(",
"$",
"value1",
")",
"&&",
"static",
"::",
"areSameType",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
")",
"{",
"return",
"$",
"value1",
"->",
"equals",
"(",
"$",
"value2",
")",
";",
"}",
"return",
"$",
"value1",
"==",
"$",
"value2",
";",
"}"
] |
Checks if two values are equal
@param mixed $value1 The first value
@param mixed $value2 The second value
@return bool
|
[
"Checks",
"if",
"two",
"values",
"are",
"equal"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1013-L1020
|
237,618
|
novuso/system
|
src/Utility/Validate.php
|
Validate.areNotEqual
|
public static function areNotEqual($value1, $value2): bool
{
if (static::isEquatable($value1) && static::areSameType($value1, $value2)) {
return !$value1->equals($value2);
}
return $value1 != $value2;
}
|
php
|
public static function areNotEqual($value1, $value2): bool
{
if (static::isEquatable($value1) && static::areSameType($value1, $value2)) {
return !$value1->equals($value2);
}
return $value1 != $value2;
}
|
[
"public",
"static",
"function",
"areNotEqual",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
":",
"bool",
"{",
"if",
"(",
"static",
"::",
"isEquatable",
"(",
"$",
"value1",
")",
"&&",
"static",
"::",
"areSameType",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
")",
"{",
"return",
"!",
"$",
"value1",
"->",
"equals",
"(",
"$",
"value2",
")",
";",
"}",
"return",
"$",
"value1",
"!=",
"$",
"value2",
";",
"}"
] |
Checks if two values are not equal
@param mixed $value1 The first value
@param mixed $value2 The second value
@return bool
|
[
"Checks",
"if",
"two",
"values",
"are",
"not",
"equal"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1030-L1037
|
237,619
|
novuso/system
|
src/Utility/Validate.php
|
Validate.areSameType
|
public static function areSameType($value1, $value2): bool
{
if (!is_object($value1) || !is_object($value2)) {
return gettype($value1) === gettype($value2);
}
return get_class($value1) === get_class($value2);
}
|
php
|
public static function areSameType($value1, $value2): bool
{
if (!is_object($value1) || !is_object($value2)) {
return gettype($value1) === gettype($value2);
}
return get_class($value1) === get_class($value2);
}
|
[
"public",
"static",
"function",
"areSameType",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"value1",
")",
"||",
"!",
"is_object",
"(",
"$",
"value2",
")",
")",
"{",
"return",
"gettype",
"(",
"$",
"value1",
")",
"===",
"gettype",
"(",
"$",
"value2",
")",
";",
"}",
"return",
"get_class",
"(",
"$",
"value1",
")",
"===",
"get_class",
"(",
"$",
"value2",
")",
";",
"}"
] |
Checks if two values are the same type
@param mixed $value1 The first value
@param mixed $value2 The second value
@return bool
|
[
"Checks",
"if",
"two",
"values",
"are",
"the",
"same",
"type"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1073-L1080
|
237,620
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isType
|
public static function isType($value, ?string $type): bool
{
if ($type === null) {
return true;
}
$result = self::isSimpleType($value, $type);
if ($result !== null) {
return $result;
}
return ($value instanceof $type);
}
|
php
|
public static function isType($value, ?string $type): bool
{
if ($type === null) {
return true;
}
$result = self::isSimpleType($value, $type);
if ($result !== null) {
return $result;
}
return ($value instanceof $type);
}
|
[
"public",
"static",
"function",
"isType",
"(",
"$",
"value",
",",
"?",
"string",
"$",
"type",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"$",
"result",
"=",
"self",
"::",
"isSimpleType",
"(",
"$",
"value",
",",
"$",
"type",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"null",
")",
"{",
"return",
"$",
"result",
";",
"}",
"return",
"(",
"$",
"value",
"instanceof",
"$",
"type",
")",
";",
"}"
] |
Checks if value is a given type
The type can be any fully-qualified class or interface name,
or one of the following type strings:
[array, object, bool, int, float, string, callable]
@param mixed $value The value
@param string|null $type The type or null to accept all types
@return bool
|
[
"Checks",
"if",
"value",
"is",
"a",
"given",
"type"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1094-L1107
|
237,621
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isListOf
|
public static function isListOf($value, ?string $type): bool
{
if (!static::isTraversable($value)) {
return false;
}
if ($type === null) {
return true;
}
$result = true;
foreach ($value as $val) {
if (!static::isType($val, $type)) {
$result = false;
break;
}
}
return $result;
}
|
php
|
public static function isListOf($value, ?string $type): bool
{
if (!static::isTraversable($value)) {
return false;
}
if ($type === null) {
return true;
}
$result = true;
foreach ($value as $val) {
if (!static::isType($val, $type)) {
$result = false;
break;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"isListOf",
"(",
"$",
"value",
",",
"?",
"string",
"$",
"type",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isTraversable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"isType",
"(",
"$",
"val",
",",
"$",
"type",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Checks if value is a list of a given type
The type can be any fully-qualified class or interface name,
or one of the following type strings:
[array, object, bool, int, float, string]
@param mixed $value The value
@param string|null $type The type or null to accept all types
@return bool
|
[
"Checks",
"if",
"value",
"is",
"a",
"list",
"of",
"a",
"given",
"type"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1121-L1141
|
237,622
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isStringCastable
|
public static function isStringCastable($value): bool
{
$result = false;
$type = strtolower(gettype($value));
switch ($type) {
case 'string':
case 'null':
case 'boolean':
case 'integer':
case 'double':
$result = true;
break;
case 'object':
if (method_exists($value, '__toString')) {
$result = true;
}
break;
default:
break;
}
return $result;
}
|
php
|
public static function isStringCastable($value): bool
{
$result = false;
$type = strtolower(gettype($value));
switch ($type) {
case 'string':
case 'null':
case 'boolean':
case 'integer':
case 'double':
$result = true;
break;
case 'object':
if (method_exists($value, '__toString')) {
$result = true;
}
break;
default:
break;
}
return $result;
}
|
[
"public",
"static",
"function",
"isStringCastable",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"type",
"=",
"strtolower",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'string'",
":",
"case",
"'null'",
":",
"case",
"'boolean'",
":",
"case",
"'integer'",
":",
"case",
"'double'",
":",
"$",
"result",
"=",
"true",
";",
"break",
";",
"case",
"'object'",
":",
"if",
"(",
"method_exists",
"(",
"$",
"value",
",",
"'__toString'",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Checks if value can be cast to a string
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"can",
"be",
"cast",
"to",
"a",
"string"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1150-L1172
|
237,623
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isJsonEncodable
|
public static function isJsonEncodable($value): bool
{
if ($value === null || is_scalar($value) || is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof JsonSerializable)) {
return true;
}
return false;
}
|
php
|
public static function isJsonEncodable($value): bool
{
if ($value === null || is_scalar($value) || is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof JsonSerializable)) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isJsonEncodable",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
"||",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
"instanceof",
"JsonSerializable",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if value can be JSON encoded
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"can",
"be",
"JSON",
"encoded"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1181-L1192
|
237,624
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isSerializable
|
public static function isSerializable($value): bool
{
if ($value === null || is_scalar($value) || is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Serializable)) {
return true;
}
return false;
}
|
php
|
public static function isSerializable($value): bool
{
if ($value === null || is_scalar($value) || is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Serializable)) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isSerializable",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
"||",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
"instanceof",
"Serializable",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if value can be serialized
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"can",
"be",
"serialized"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1201-L1212
|
237,625
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isTraversable
|
public static function isTraversable($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Traversable)) {
return true;
}
return false;
}
|
php
|
public static function isTraversable($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Traversable)) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isTraversable",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
"instanceof",
"Traversable",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if value is traversable
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"is",
"traversable"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1221-L1232
|
237,626
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isCountable
|
public static function isCountable($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Countable)) {
return true;
}
return false;
}
|
php
|
public static function isCountable($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof Countable)) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isCountable",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
"instanceof",
"Countable",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if value is countable
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"is",
"countable"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1241-L1252
|
237,627
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isArrayAccessible
|
public static function isArrayAccessible($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof ArrayAccess)) {
return true;
}
return false;
}
|
php
|
public static function isArrayAccessible($value): bool
{
if (is_array($value)) {
return true;
}
if (is_object($value) && ($value instanceof ArrayAccess)) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"isArrayAccessible",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
"instanceof",
"ArrayAccess",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if value is array accessible
@param mixed $value The value
@return bool
|
[
"Checks",
"if",
"value",
"is",
"array",
"accessible"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1261-L1272
|
237,628
|
novuso/system
|
src/Utility/Validate.php
|
Validate.implementsInterface
|
public static function implementsInterface($value, string $interface): bool
{
if (!is_object($value)) {
if (!(static::classExists($value) || static::interfaceExists($value))) {
return false;
}
$value = (string) $value;
}
$reflection = new ReflectionClass($value);
return $reflection->implementsInterface($interface);
}
|
php
|
public static function implementsInterface($value, string $interface): bool
{
if (!is_object($value)) {
if (!(static::classExists($value) || static::interfaceExists($value))) {
return false;
}
$value = (string) $value;
}
$reflection = new ReflectionClass($value);
return $reflection->implementsInterface($interface);
}
|
[
"public",
"static",
"function",
"implementsInterface",
"(",
"$",
"value",
",",
"string",
"$",
"interface",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"(",
"static",
"::",
"classExists",
"(",
"$",
"value",
")",
"||",
"static",
"::",
"interfaceExists",
"(",
"$",
"value",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"value",
")",
";",
"return",
"$",
"reflection",
"->",
"implementsInterface",
"(",
"$",
"interface",
")",
";",
"}"
] |
Checks if value implements a given interface
@param mixed $value The value
@param string $interface The fully qualified interface name
@return bool
|
[
"Checks",
"if",
"value",
"implements",
"a",
"given",
"interface"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1314-L1326
|
237,629
|
novuso/system
|
src/Utility/Validate.php
|
Validate.methodExists
|
public static function methodExists($value, $object): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return method_exists($object, (string) $value);
}
|
php
|
public static function methodExists($value, $object): bool
{
if (!static::isStringCastable($value)) {
return false;
}
return method_exists($object, (string) $value);
}
|
[
"public",
"static",
"function",
"methodExists",
"(",
"$",
"value",
",",
"$",
"object",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"static",
"::",
"isStringCastable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"method_exists",
"(",
"$",
"object",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"}"
] |
Checks if value is a method name for an object or class
@param mixed $value The value
@param object|string $object The object or fully qualified class name
@return bool
|
[
"Checks",
"if",
"value",
"is",
"a",
"method",
"name",
"for",
"an",
"object",
"or",
"class"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1394-L1401
|
237,630
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidTimezone
|
private static function isValidTimezone(string $timezone): bool
{
// @codeCoverageIgnoreStart
if (self::$timezones === null) {
self::$timezones = [];
foreach (timezone_identifiers_list() as $zone) {
self::$timezones[$zone] = true;
}
}
// @codeCoverageIgnoreEnd
return isset(self::$timezones[$timezone]);
}
|
php
|
private static function isValidTimezone(string $timezone): bool
{
// @codeCoverageIgnoreStart
if (self::$timezones === null) {
self::$timezones = [];
foreach (timezone_identifiers_list() as $zone) {
self::$timezones[$zone] = true;
}
}
// @codeCoverageIgnoreEnd
return isset(self::$timezones[$timezone]);
}
|
[
"private",
"static",
"function",
"isValidTimezone",
"(",
"string",
"$",
"timezone",
")",
":",
"bool",
"{",
"// @codeCoverageIgnoreStart",
"if",
"(",
"self",
"::",
"$",
"timezones",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"timezones",
"=",
"[",
"]",
";",
"foreach",
"(",
"timezone_identifiers_list",
"(",
")",
"as",
"$",
"zone",
")",
"{",
"self",
"::",
"$",
"timezones",
"[",
"$",
"zone",
"]",
"=",
"true",
";",
"}",
"}",
"// @codeCoverageIgnoreEnd",
"return",
"isset",
"(",
"self",
"::",
"$",
"timezones",
"[",
"$",
"timezone",
"]",
")",
";",
"}"
] |
Checks if a timezone string is valid
@param string $timezone The timezone string
@return bool
|
[
"Checks",
"if",
"a",
"timezone",
"string",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1490-L1502
|
237,631
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUri
|
private static function isValidUri(array $uri): bool
{
if (!self::isValidUriScheme($uri['scheme'])) {
return false;
}
if (!self::isValidUriPath($uri['path'])) {
return false;
}
if (!self::isValidUriQuery($uri['query'])) {
return false;
}
if (!self::isValidUriFragment($uri['fragment'])) {
return false;
}
if (!self::isValidUriAuthority($uri['authority'])) {
return false;
}
return true;
}
|
php
|
private static function isValidUri(array $uri): bool
{
if (!self::isValidUriScheme($uri['scheme'])) {
return false;
}
if (!self::isValidUriPath($uri['path'])) {
return false;
}
if (!self::isValidUriQuery($uri['query'])) {
return false;
}
if (!self::isValidUriFragment($uri['fragment'])) {
return false;
}
if (!self::isValidUriAuthority($uri['authority'])) {
return false;
}
return true;
}
|
[
"private",
"static",
"function",
"isValidUri",
"(",
"array",
"$",
"uri",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"self",
"::",
"isValidUriScheme",
"(",
"$",
"uri",
"[",
"'scheme'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isValidUriPath",
"(",
"$",
"uri",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isValidUriQuery",
"(",
"$",
"uri",
"[",
"'query'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isValidUriFragment",
"(",
"$",
"uri",
"[",
"'fragment'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isValidUriAuthority",
"(",
"$",
"uri",
"[",
"'authority'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if URI components are valid
@param array $uri an associated array of URI components
@return bool
|
[
"Checks",
"if",
"URI",
"components",
"are",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1551-L1570
|
237,632
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUriScheme
|
private static function isValidUriScheme(?string $scheme): bool
{
// http://tools.ietf.org/html/rfc3986#section-3
// The scheme and path components are required, though the path may be
// empty (no characters)
if ($scheme === null || $scheme === '') {
return false;
}
// http://tools.ietf.org/html/rfc3986#section-3.1
// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
$pattern = '/\A[a-z][a-z0-9+.\-]*\z/i';
return !!preg_match($pattern, $scheme);
}
|
php
|
private static function isValidUriScheme(?string $scheme): bool
{
// http://tools.ietf.org/html/rfc3986#section-3
// The scheme and path components are required, though the path may be
// empty (no characters)
if ($scheme === null || $scheme === '') {
return false;
}
// http://tools.ietf.org/html/rfc3986#section-3.1
// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
$pattern = '/\A[a-z][a-z0-9+.\-]*\z/i';
return !!preg_match($pattern, $scheme);
}
|
[
"private",
"static",
"function",
"isValidUriScheme",
"(",
"?",
"string",
"$",
"scheme",
")",
":",
"bool",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3",
"// The scheme and path components are required, though the path may be",
"// empty (no characters)",
"if",
"(",
"$",
"scheme",
"===",
"null",
"||",
"$",
"scheme",
"===",
"''",
")",
"{",
"return",
"false",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.1",
"// scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )",
"$",
"pattern",
"=",
"'/\\A[a-z][a-z0-9+.\\-]*\\z/i'",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"scheme",
")",
";",
"}"
] |
Checks if a URI scheme is valid
@param string|null $scheme The URI scheme
@return bool
|
[
"Checks",
"if",
"a",
"URI",
"scheme",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1579-L1593
|
237,633
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUriAuthority
|
private static function isValidUriAuthority(?string $authority): bool
{
if ($authority === null || $authority === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2
// authority = [ userinfo "@" ] host [ ":" port ]
$pattern = '/\A(?:([^@]*)@)?(\[[^\]]*\]|[^:]*)(?::(?:\d*))?\z/';
preg_match($pattern, $authority, $matches);
if (!self::isValidAuthUser((isset($matches[1]) && $matches[1]) ? $matches[1] : null)) {
return false;
}
if (!self::isValidAuthHost((isset($matches[2]) && $matches[2]) ? $matches[2] : '')) {
return false;
}
return true;
}
|
php
|
private static function isValidUriAuthority(?string $authority): bool
{
if ($authority === null || $authority === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2
// authority = [ userinfo "@" ] host [ ":" port ]
$pattern = '/\A(?:([^@]*)@)?(\[[^\]]*\]|[^:]*)(?::(?:\d*))?\z/';
preg_match($pattern, $authority, $matches);
if (!self::isValidAuthUser((isset($matches[1]) && $matches[1]) ? $matches[1] : null)) {
return false;
}
if (!self::isValidAuthHost((isset($matches[2]) && $matches[2]) ? $matches[2] : '')) {
return false;
}
return true;
}
|
[
"private",
"static",
"function",
"isValidUriAuthority",
"(",
"?",
"string",
"$",
"authority",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"authority",
"===",
"null",
"||",
"$",
"authority",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.2",
"// authority = [ userinfo \"@\" ] host [ \":\" port ]",
"$",
"pattern",
"=",
"'/\\A(?:([^@]*)@)?(\\[[^\\]]*\\]|[^:]*)(?::(?:\\d*))?\\z/'",
";",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"authority",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"self",
"::",
"isValidAuthUser",
"(",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"&&",
"$",
"matches",
"[",
"1",
"]",
")",
"?",
"$",
"matches",
"[",
"1",
"]",
":",
"null",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"isValidAuthHost",
"(",
"(",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"&&",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"$",
"matches",
"[",
"2",
"]",
":",
"''",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if a URI authority is valid
@param string|null $authority The URI authority
@return bool
|
[
"Checks",
"if",
"a",
"URI",
"authority",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1602-L1621
|
237,634
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUriPath
|
private static function isValidUriPath(string $path): bool
{
// http://tools.ietf.org/html/rfc3986#section-3
// The scheme and path components are required, though the path may be
// empty (no characters)
if ($path === '') {
return true;
}
// path = path-abempty ; begins with "/" or is empty
// / path-absolute ; begins with "/" but not "//"
// / path-noscheme ; begins with a non-colon segment
// / path-rootless ; begins with a segment
// / path-empty ; zero characters
//
// path-abempty = *( "/" segment )
// path-absolute = "/" [ segment-nz *( "/" segment ) ]
// path-noscheme = segment-nz-nc *( "/" segment )
// path-rootless = segment-nz *( "/" segment )
// path-empty = 0<pchar>
// segment = *pchar
// segment-nz = 1*pchar
// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
// ; non-zero-length segment without any colon ":"
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:(?:[%s%s:@]|(?:%s))*\/?)*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $path);
}
|
php
|
private static function isValidUriPath(string $path): bool
{
// http://tools.ietf.org/html/rfc3986#section-3
// The scheme and path components are required, though the path may be
// empty (no characters)
if ($path === '') {
return true;
}
// path = path-abempty ; begins with "/" or is empty
// / path-absolute ; begins with "/" but not "//"
// / path-noscheme ; begins with a non-colon segment
// / path-rootless ; begins with a segment
// / path-empty ; zero characters
//
// path-abempty = *( "/" segment )
// path-absolute = "/" [ segment-nz *( "/" segment ) ]
// path-noscheme = segment-nz-nc *( "/" segment )
// path-rootless = segment-nz *( "/" segment )
// path-empty = 0<pchar>
// segment = *pchar
// segment-nz = 1*pchar
// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
// ; non-zero-length segment without any colon ":"
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:(?:[%s%s:@]|(?:%s))*\/?)*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $path);
}
|
[
"private",
"static",
"function",
"isValidUriPath",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3",
"// The scheme and path components are required, though the path may be",
"// empty (no characters)",
"if",
"(",
"$",
"path",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// path = path-abempty ; begins with \"/\" or is empty",
"// / path-absolute ; begins with \"/\" but not \"//\"",
"// / path-noscheme ; begins with a non-colon segment",
"// / path-rootless ; begins with a segment",
"// / path-empty ; zero characters",
"//",
"// path-abempty = *( \"/\" segment )",
"// path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]",
"// path-noscheme = segment-nz-nc *( \"/\" segment )",
"// path-rootless = segment-nz *( \"/\" segment )",
"// path-empty = 0<pchar>",
"// segment = *pchar",
"// segment-nz = 1*pchar",
"// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / \"@\" )",
"// ; non-zero-length segment without any colon \":\"",
"// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:(?:[%s%s:@]|(?:%s))*\\/?)*\\z/i'",
",",
"'a-z0-9\\-._~'",
",",
"'!$&\\'()*+,;='",
",",
"'%[a-f0-9]{2}'",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
")",
";",
"}"
] |
Checks if a URI path is valid
@param string $path The URI path
@return bool
|
[
"Checks",
"if",
"a",
"URI",
"path",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1630-L1663
|
237,635
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUriQuery
|
private static function isValidUriQuery(?string $query): bool
{
if ($query === null || $query === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.4
// query = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:[%s%s\/?:@]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $query);
}
|
php
|
private static function isValidUriQuery(?string $query): bool
{
if ($query === null || $query === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.4
// query = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:[%s%s\/?:@]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $query);
}
|
[
"private",
"static",
"function",
"isValidUriQuery",
"(",
"?",
"string",
"$",
"query",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"query",
"===",
"null",
"||",
"$",
"query",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.4",
"// query = *( pchar / \"/\" / \"?\" )",
"// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:[%s%s\\/?:@]|(?:%s))*\\z/i'",
",",
"'a-z0-9\\-._~'",
",",
"'!$&\\'()*+,;='",
",",
"'%[a-f0-9]{2}'",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"query",
")",
";",
"}"
] |
Checks if a URI query is valid
@param string|null $query The URI query
@return bool
|
[
"Checks",
"if",
"a",
"URI",
"query",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1672-L1689
|
237,636
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidUriFragment
|
private static function isValidUriFragment(?string $fragment): bool
{
if ($fragment === null || $fragment === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.5
// fragment = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:[%s%s\/?:@]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $fragment);
}
|
php
|
private static function isValidUriFragment(?string $fragment): bool
{
if ($fragment === null || $fragment === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.5
// fragment = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$pattern = sprintf(
'/\A(?:[%s%s\/?:@]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $fragment);
}
|
[
"private",
"static",
"function",
"isValidUriFragment",
"(",
"?",
"string",
"$",
"fragment",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"fragment",
"===",
"null",
"||",
"$",
"fragment",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.5",
"// fragment = *( pchar / \"/\" / \"?\" )",
"// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:[%s%s\\/?:@]|(?:%s))*\\z/i'",
",",
"'a-z0-9\\-._~'",
",",
"'!$&\\'()*+,;='",
",",
"'%[a-f0-9]{2}'",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"fragment",
")",
";",
"}"
] |
Checks if a URI fragment is valid
@param string|null $fragment The URI fragment
@return bool
|
[
"Checks",
"if",
"a",
"URI",
"fragment",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1698-L1715
|
237,637
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidAuthUser
|
private static function isValidAuthUser(?string $userinfo): bool
{
if ($userinfo === null) {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$pattern = sprintf(
'/\A(?:[%s%s:]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $userinfo);
}
|
php
|
private static function isValidAuthUser(?string $userinfo): bool
{
if ($userinfo === null) {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$pattern = sprintf(
'/\A(?:[%s%s:]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $userinfo);
}
|
[
"private",
"static",
"function",
"isValidAuthUser",
"(",
"?",
"string",
"$",
"userinfo",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"userinfo",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.2.1",
"// userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:[%s%s:]|(?:%s))*\\z/i'",
",",
"'a-z0-9\\-._~'",
",",
"'!$&\\'()*+,;='",
",",
"'%[a-f0-9]{2}'",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"userinfo",
")",
";",
"}"
] |
Checks if authority userinfo is valid
@param string|null $userinfo The userinfo
@return bool
|
[
"Checks",
"if",
"authority",
"userinfo",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1724-L1740
|
237,638
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isValidAuthHost
|
private static function isValidAuthHost(string $host): bool
{
if ($host === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// A host identified by an Internet Protocol literal address, version 6
// [RFC3513] or later, is distinguished by enclosing the IP literal
// within square brackets ("[" and "]"). This is the only place where
// square bracket characters are allowed in the URI syntax.
if (strpos($host, '[') !== false) {
return self::isValidIpLiteral($host);
}
// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
$dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])';
$ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec);
if (preg_match($ipV4, $host)) {
return true;
}
// reg-name = *( unreserved / pct-encoded / sub-delims )
$pattern = sprintf(
'/\A(?:[%s%s]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $host);
}
|
php
|
private static function isValidAuthHost(string $host): bool
{
if ($host === '') {
return true;
}
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// A host identified by an Internet Protocol literal address, version 6
// [RFC3513] or later, is distinguished by enclosing the IP literal
// within square brackets ("[" and "]"). This is the only place where
// square bracket characters are allowed in the URI syntax.
if (strpos($host, '[') !== false) {
return self::isValidIpLiteral($host);
}
// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
$dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])';
$ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec);
if (preg_match($ipV4, $host)) {
return true;
}
// reg-name = *( unreserved / pct-encoded / sub-delims )
$pattern = sprintf(
'/\A(?:[%s%s]|(?:%s))*\z/i',
'a-z0-9\-._~',
'!$&\'()*+,;=',
'%[a-f0-9]{2}'
);
return !!preg_match($pattern, $host);
}
|
[
"private",
"static",
"function",
"isValidAuthHost",
"(",
"string",
"$",
"host",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"host",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.2.2",
"// A host identified by an Internet Protocol literal address, version 6",
"// [RFC3513] or later, is distinguished by enclosing the IP literal",
"// within square brackets (\"[\" and \"]\"). This is the only place where",
"// square bracket characters are allowed in the URI syntax.",
"if",
"(",
"strpos",
"(",
"$",
"host",
",",
"'['",
")",
"!==",
"false",
")",
"{",
"return",
"self",
"::",
"isValidIpLiteral",
"(",
"$",
"host",
")",
";",
"}",
"// IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet",
"$",
"dec",
"=",
"'(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])'",
";",
"$",
"ipV4",
"=",
"sprintf",
"(",
"'/\\A(?:%s\\.){3}%s\\z/'",
",",
"$",
"dec",
",",
"$",
"dec",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"ipV4",
",",
"$",
"host",
")",
")",
"{",
"return",
"true",
";",
"}",
"// reg-name = *( unreserved / pct-encoded / sub-delims )",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:[%s%s]|(?:%s))*\\z/i'",
",",
"'a-z0-9\\-._~'",
",",
"'!$&\\'()*+,;='",
",",
"'%[a-f0-9]{2}'",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"host",
")",
";",
"}"
] |
Checks if authority host is valid
@param string $host The host
@return bool
|
[
"Checks",
"if",
"authority",
"host",
"is",
"valid"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1749-L1780
|
237,639
|
novuso/system
|
src/Utility/Validate.php
|
Validate.isSimpleType
|
private static function isSimpleType($value, string $type): ?bool
{
switch ($type) {
case 'array':
return static::isArray($value);
break;
case 'object':
return static::isObject($value);
break;
case 'bool':
return static::isBool($value);
break;
case 'int':
return static::isInt($value);
break;
case 'float':
return static::isFloat($value);
break;
case 'string':
return static::isString($value);
break;
case 'callable':
return static::isCallable($value);
break;
default:
break;
}
return null;
}
|
php
|
private static function isSimpleType($value, string $type): ?bool
{
switch ($type) {
case 'array':
return static::isArray($value);
break;
case 'object':
return static::isObject($value);
break;
case 'bool':
return static::isBool($value);
break;
case 'int':
return static::isInt($value);
break;
case 'float':
return static::isFloat($value);
break;
case 'string':
return static::isString($value);
break;
case 'callable':
return static::isCallable($value);
break;
default:
break;
}
return null;
}
|
[
"private",
"static",
"function",
"isSimpleType",
"(",
"$",
"value",
",",
"string",
"$",
"type",
")",
":",
"?",
"bool",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'array'",
":",
"return",
"static",
"::",
"isArray",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'object'",
":",
"return",
"static",
"::",
"isObject",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'bool'",
":",
"return",
"static",
"::",
"isBool",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'int'",
":",
"return",
"static",
"::",
"isInt",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'float'",
":",
"return",
"static",
"::",
"isFloat",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'string'",
":",
"return",
"static",
"::",
"isString",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'callable'",
":",
"return",
"static",
"::",
"isCallable",
"(",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"null",
";",
"}"
] |
Checks if a value matches a simple type
Returns null if the type is not supported
@param mixed $value The value
@param string $type The type
@return bool|null
|
[
"Checks",
"if",
"a",
"value",
"matches",
"a",
"simple",
"type"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1824-L1853
|
237,640
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.startPluginTraits
|
private function startPluginTraits()
{
foreach ($this->getPluginTraits() as $trait) {
if (method_exists(get_called_class(), $method = 'start' . class_basename($trait) . 'Plugin')) {
call_user_func([ $this, $method ], $this->app);
}
}
}
|
php
|
private function startPluginTraits()
{
foreach ($this->getPluginTraits() as $trait) {
if (method_exists(get_called_class(), $method = 'start' . class_basename($trait) . 'Plugin')) {
call_user_func([ $this, $method ], $this->app);
}
}
}
|
[
"private",
"function",
"startPluginTraits",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getPluginTraits",
"(",
")",
"as",
"$",
"trait",
")",
"{",
"if",
"(",
"method_exists",
"(",
"get_called_class",
"(",
")",
",",
"$",
"method",
"=",
"'start'",
".",
"class_basename",
"(",
"$",
"trait",
")",
".",
"'Plugin'",
")",
")",
"{",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"$",
"this",
"->",
"app",
")",
";",
"}",
"}",
"}"
] |
startPluginTraits method.
|
[
"startPluginTraits",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L200-L207
|
237,641
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.requiresPlugins
|
public function requiresPlugins()
{
$has = class_uses_recursive(get_called_class());
$check = array_combine(func_get_args(), func_get_args());
$missing = array_values(array_diff($check, $has));
if (isset($missing[ 0 ])) {
$plugin = collect(debug_backtrace())->where('function', 'requiresPlugins')->first();
throw ProviderPluginDependencyException::plugin($plugin[ 'file' ], implode(', ', $missing));
}
}
|
php
|
public function requiresPlugins()
{
$has = class_uses_recursive(get_called_class());
$check = array_combine(func_get_args(), func_get_args());
$missing = array_values(array_diff($check, $has));
if (isset($missing[ 0 ])) {
$plugin = collect(debug_backtrace())->where('function', 'requiresPlugins')->first();
throw ProviderPluginDependencyException::plugin($plugin[ 'file' ], implode(', ', $missing));
}
}
|
[
"public",
"function",
"requiresPlugins",
"(",
")",
"{",
"$",
"has",
"=",
"class_uses_recursive",
"(",
"get_called_class",
"(",
")",
")",
";",
"$",
"check",
"=",
"array_combine",
"(",
"func_get_args",
"(",
")",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"missing",
"=",
"array_values",
"(",
"array_diff",
"(",
"$",
"check",
",",
"$",
"has",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"missing",
"[",
"0",
"]",
")",
")",
"{",
"$",
"plugin",
"=",
"collect",
"(",
"debug_backtrace",
"(",
")",
")",
"->",
"where",
"(",
"'function'",
",",
"'requiresPlugins'",
")",
"->",
"first",
"(",
")",
";",
"throw",
"ProviderPluginDependencyException",
"::",
"plugin",
"(",
"$",
"plugin",
"[",
"'file'",
"]",
",",
"implode",
"(",
"', '",
",",
"$",
"missing",
")",
")",
";",
"}",
"}"
] |
requiresPlugins method.
|
[
"requiresPlugins",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L222-L231
|
237,642
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.resolveDirectories
|
private function resolveDirectories()
{
if ($this->scanDirs !== true) {
return;
}
if ($this->rootDir === null) {
$class = new ReflectionClass(get_called_class());
$filePath = $class->getFileName();
$this->dir = $rootDir = path_get_directory($filePath);
$found = false;
for ($i = 0; $i < $this->scanDirsMaxLevel; ++$i) {
if (file_exists($composerPath = path_join($rootDir, 'composer.json'))) {
$found = true;
break;
} else {
$rootDir = path_get_directory($rootDir); // go 1 up
}
}
if ($found === false) {
throw new \OutOfBoundsException("Could not determinse composer.json file location in [{$this->dir}] or in {$this->scanDirsMaxLevel} parents of [$this->rootDir}]");
}
$this->rootDir = $rootDir;
}
$this->dir = $this->dir ?: path_join($this->rootDir, 'src');
}
|
php
|
private function resolveDirectories()
{
if ($this->scanDirs !== true) {
return;
}
if ($this->rootDir === null) {
$class = new ReflectionClass(get_called_class());
$filePath = $class->getFileName();
$this->dir = $rootDir = path_get_directory($filePath);
$found = false;
for ($i = 0; $i < $this->scanDirsMaxLevel; ++$i) {
if (file_exists($composerPath = path_join($rootDir, 'composer.json'))) {
$found = true;
break;
} else {
$rootDir = path_get_directory($rootDir); // go 1 up
}
}
if ($found === false) {
throw new \OutOfBoundsException("Could not determinse composer.json file location in [{$this->dir}] or in {$this->scanDirsMaxLevel} parents of [$this->rootDir}]");
}
$this->rootDir = $rootDir;
}
$this->dir = $this->dir ?: path_join($this->rootDir, 'src');
}
|
[
"private",
"function",
"resolveDirectories",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scanDirs",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"rootDir",
"===",
"null",
")",
"{",
"$",
"class",
"=",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"$",
"filePath",
"=",
"$",
"class",
"->",
"getFileName",
"(",
")",
";",
"$",
"this",
"->",
"dir",
"=",
"$",
"rootDir",
"=",
"path_get_directory",
"(",
"$",
"filePath",
")",
";",
"$",
"found",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"scanDirsMaxLevel",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"composerPath",
"=",
"path_join",
"(",
"$",
"rootDir",
",",
"'composer.json'",
")",
")",
")",
"{",
"$",
"found",
"=",
"true",
";",
"break",
";",
"}",
"else",
"{",
"$",
"rootDir",
"=",
"path_get_directory",
"(",
"$",
"rootDir",
")",
";",
"// go 1 up",
"}",
"}",
"if",
"(",
"$",
"found",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Could not determinse composer.json file location in [{$this->dir}] or in {$this->scanDirsMaxLevel} parents of [$this->rootDir}]\"",
")",
";",
"}",
"$",
"this",
"->",
"rootDir",
"=",
"$",
"rootDir",
";",
"}",
"$",
"this",
"->",
"dir",
"=",
"$",
"this",
"->",
"dir",
"?",
":",
"path_join",
"(",
"$",
"this",
"->",
"rootDir",
",",
"'src'",
")",
";",
"}"
] |
resolveDirectories method.
|
[
"resolveDirectories",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L236-L261
|
237,643
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.getPluginPriority
|
private function getPluginPriority($name, $index = 0)
{
$priority = 10;
if (property_exists($this, "{$name}PluginPriority")) {
$value = $this->{$name . 'PluginPriority'};
$priority = is_array($value) ? $value[ $index ] : $value;
}
return $priority;
}
|
php
|
private function getPluginPriority($name, $index = 0)
{
$priority = 10;
if (property_exists($this, "{$name}PluginPriority")) {
$value = $this->{$name . 'PluginPriority'};
$priority = is_array($value) ? $value[ $index ] : $value;
}
return $priority;
}
|
[
"private",
"function",
"getPluginPriority",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"priority",
"=",
"10",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"\"{$name}PluginPriority\"",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"name",
".",
"'PluginPriority'",
"}",
";",
"$",
"priority",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"value",
"[",
"$",
"index",
"]",
":",
"$",
"value",
";",
"}",
"return",
"$",
"priority",
";",
"}"
] |
getPluginPriority method.
@param $name
@param int $index If a plugin priority is defined as array, the 0 index is for register and 1 for boot
@return int|mixed
|
[
"getPluginPriority",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L282-L291
|
237,644
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.onRegister
|
public function onRegister($name, Closure $callback)
{
$priority = $this->getPluginPriority($name);
$this->registerCallbacks[] = compact('name', 'priority', 'callback');
}
|
php
|
public function onRegister($name, Closure $callback)
{
$priority = $this->getPluginPriority($name);
$this->registerCallbacks[] = compact('name', 'priority', 'callback');
}
|
[
"public",
"function",
"onRegister",
"(",
"$",
"name",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"priority",
"=",
"$",
"this",
"->",
"getPluginPriority",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"registerCallbacks",
"[",
"]",
"=",
"compact",
"(",
"'name'",
",",
"'priority'",
",",
"'callback'",
")",
";",
"}"
] |
onRegister method.
@param $name
@param \Closure $callback
|
[
"onRegister",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L299-L303
|
237,645
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.onBoot
|
public function onBoot($name, Closure $callback)
{
$priority = $this->getPluginPriority($name, 1);
$this->bootCallbacks[] = compact('name', 'priority', 'callback');
}
|
php
|
public function onBoot($name, Closure $callback)
{
$priority = $this->getPluginPriority($name, 1);
$this->bootCallbacks[] = compact('name', 'priority', 'callback');
}
|
[
"public",
"function",
"onBoot",
"(",
"$",
"name",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"priority",
"=",
"$",
"this",
"->",
"getPluginPriority",
"(",
"$",
"name",
",",
"1",
")",
";",
"$",
"this",
"->",
"bootCallbacks",
"[",
"]",
"=",
"compact",
"(",
"'name'",
",",
"'priority'",
",",
"'callback'",
")",
";",
"}"
] |
onBoot method.
@param $name
@param \Closure $callback
|
[
"onBoot",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L311-L315
|
237,646
|
laradic/service-provider
|
src/BaseServiceProvider.php
|
BaseServiceProvider.fireCallbacks
|
private function fireCallbacks($name, Closure $modifier = null, Closure $caller = null)
{
$list = collect($this->{$name . 'Callbacks'});
if ($modifier) {
$list = call_user_func_array($modifier, [ $list ]);
}
$caller = $caller ?: function (Closure $callback) {
$callback->bindTo($this);
$callback($this->app);
};
$list->pluck('callback')->each($caller);
}
|
php
|
private function fireCallbacks($name, Closure $modifier = null, Closure $caller = null)
{
$list = collect($this->{$name . 'Callbacks'});
if ($modifier) {
$list = call_user_func_array($modifier, [ $list ]);
}
$caller = $caller ?: function (Closure $callback) {
$callback->bindTo($this);
$callback($this->app);
};
$list->pluck('callback')->each($caller);
}
|
[
"private",
"function",
"fireCallbacks",
"(",
"$",
"name",
",",
"Closure",
"$",
"modifier",
"=",
"null",
",",
"Closure",
"$",
"caller",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"collect",
"(",
"$",
"this",
"->",
"{",
"$",
"name",
".",
"'Callbacks'",
"}",
")",
";",
"if",
"(",
"$",
"modifier",
")",
"{",
"$",
"list",
"=",
"call_user_func_array",
"(",
"$",
"modifier",
",",
"[",
"$",
"list",
"]",
")",
";",
"}",
"$",
"caller",
"=",
"$",
"caller",
"?",
":",
"function",
"(",
"Closure",
"$",
"callback",
")",
"{",
"$",
"callback",
"->",
"bindTo",
"(",
"$",
"this",
")",
";",
"$",
"callback",
"(",
"$",
"this",
"->",
"app",
")",
";",
"}",
";",
"$",
"list",
"->",
"pluck",
"(",
"'callback'",
")",
"->",
"each",
"(",
"$",
"caller",
")",
";",
"}"
] |
fireCallbacks method.
@param $name
@param \Closure|null $modifier
@param \Closure|null $caller
|
[
"fireCallbacks",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L324-L335
|
237,647
|
WellCommerce/Form
|
Elements/Input/FontStyle.php
|
FontStyle.formatStylesJs
|
public function formatStylesJs()
{
$options = [];
$options[] = $this->formatStyle('Arial,Arial,Helvetica,sans-serif', 'Arial');
$options[] = $this->formatStyle('Arial Black,Arial Black,Gadget,sans-serif', 'Arial Black');
$options[] = $this->formatStyle('Comic Sans MS,Comic Sans MS,cursive', 'Comic Sans MS');
$options[] = $this->formatStyle('Courier New,Courier New,Courier,monospace', 'Courier New');
$options[] = $this->formatStyle('Georgia,Georgia,serif', 'Georgia');
$options[] = $this->formatStyle('Impact,Charcoal,sans-serif', 'Impact');
$options[] = $this->formatStyle('Lucida Console,Monaco,monospace', 'Lucida Console');
$options[] = $this->formatStyle('Lucida Sans Unicode,Lucida Grande,sans-serif', 'Lucida Sans');
$options[] = $this->formatStyle('Palatino Linotype,Book Antiqua,Palatino,serif', 'Palatino Linotype');
$options[] = $this->formatStyle('Tahoma,Geneva,sans-serif', 'Tahoma');
$options[] = $this->formatStyle('Times New Roman,Times,serif', 'Times New Roman');
$options[] = $this->formatStyle('Trebuchet MS,Helvetica,sans-serif', 'Trebuchet');
$options[] = $this->formatStyle('Verdana,Geneva,sans-serif', 'Verdana');
return 'aoTypes: ['.implode(', ', $options).']';
}
|
php
|
public function formatStylesJs()
{
$options = [];
$options[] = $this->formatStyle('Arial,Arial,Helvetica,sans-serif', 'Arial');
$options[] = $this->formatStyle('Arial Black,Arial Black,Gadget,sans-serif', 'Arial Black');
$options[] = $this->formatStyle('Comic Sans MS,Comic Sans MS,cursive', 'Comic Sans MS');
$options[] = $this->formatStyle('Courier New,Courier New,Courier,monospace', 'Courier New');
$options[] = $this->formatStyle('Georgia,Georgia,serif', 'Georgia');
$options[] = $this->formatStyle('Impact,Charcoal,sans-serif', 'Impact');
$options[] = $this->formatStyle('Lucida Console,Monaco,monospace', 'Lucida Console');
$options[] = $this->formatStyle('Lucida Sans Unicode,Lucida Grande,sans-serif', 'Lucida Sans');
$options[] = $this->formatStyle('Palatino Linotype,Book Antiqua,Palatino,serif', 'Palatino Linotype');
$options[] = $this->formatStyle('Tahoma,Geneva,sans-serif', 'Tahoma');
$options[] = $this->formatStyle('Times New Roman,Times,serif', 'Times New Roman');
$options[] = $this->formatStyle('Trebuchet MS,Helvetica,sans-serif', 'Trebuchet');
$options[] = $this->formatStyle('Verdana,Geneva,sans-serif', 'Verdana');
return 'aoTypes: ['.implode(', ', $options).']';
}
|
[
"public",
"function",
"formatStylesJs",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Arial,Arial,Helvetica,sans-serif'",
",",
"'Arial'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Arial Black,Arial Black,Gadget,sans-serif'",
",",
"'Arial Black'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Comic Sans MS,Comic Sans MS,cursive'",
",",
"'Comic Sans MS'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Courier New,Courier New,Courier,monospace'",
",",
"'Courier New'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Georgia,Georgia,serif'",
",",
"'Georgia'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Impact,Charcoal,sans-serif'",
",",
"'Impact'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Lucida Console,Monaco,monospace'",
",",
"'Lucida Console'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Lucida Sans Unicode,Lucida Grande,sans-serif'",
",",
"'Lucida Sans'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Palatino Linotype,Book Antiqua,Palatino,serif'",
",",
"'Palatino Linotype'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Tahoma,Geneva,sans-serif'",
",",
"'Tahoma'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Times New Roman,Times,serif'",
",",
"'Times New Roman'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Trebuchet MS,Helvetica,sans-serif'",
",",
"'Trebuchet'",
")",
";",
"$",
"options",
"[",
"]",
"=",
"$",
"this",
"->",
"formatStyle",
"(",
"'Verdana,Geneva,sans-serif'",
",",
"'Verdana'",
")",
";",
"return",
"'aoTypes: ['",
".",
"implode",
"(",
"', '",
",",
"$",
"options",
")",
".",
"']'",
";",
"}"
] |
Formats font styles to use them in layout editor
@return string
|
[
"Formats",
"font",
"styles",
"to",
"use",
"them",
"in",
"layout",
"editor"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Input/FontStyle.php#L29-L48
|
237,648
|
Silvestra/Silvestra
|
src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php
|
TextNodeFormHandler.process
|
public function process(Request $request, FormInterface $form)
{
if ($request->isMethod('POST')) {
$form->submit($request);
if ($form->isValid()) {
return true;
}
}
return false;
}
|
php
|
public function process(Request $request, FormInterface $form)
{
if ($request->isMethod('POST')) {
$form->submit($request);
if ($form->isValid()) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"FormInterface",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isMethod",
"(",
"'POST'",
")",
")",
"{",
"$",
"form",
"->",
"submit",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Process text node form.
@param Request $request
@param FormInterface $form
@return bool
|
[
"Process",
"text",
"node",
"form",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php#L70-L80
|
237,649
|
Silvestra/Silvestra
|
src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php
|
TextNodeFormHandler.onSuccess
|
public function onSuccess($locale, NodeInterface $node)
{
$this->eventDispatcher->dispatch(TadckaTreeEvents::NODE_EDIT_SUCCESS, new TreeNodeEvent($locale, $node));
$this->textNodeManager->save();
return $this->translator->trans('success.text_node_save', array(), 'SilvestraTextNodeBundle');
}
|
php
|
public function onSuccess($locale, NodeInterface $node)
{
$this->eventDispatcher->dispatch(TadckaTreeEvents::NODE_EDIT_SUCCESS, new TreeNodeEvent($locale, $node));
$this->textNodeManager->save();
return $this->translator->trans('success.text_node_save', array(), 'SilvestraTextNodeBundle');
}
|
[
"public",
"function",
"onSuccess",
"(",
"$",
"locale",
",",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"TadckaTreeEvents",
"::",
"NODE_EDIT_SUCCESS",
",",
"new",
"TreeNodeEvent",
"(",
"$",
"locale",
",",
"$",
"node",
")",
")",
";",
"$",
"this",
"->",
"textNodeManager",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"'success.text_node_save'",
",",
"array",
"(",
")",
",",
"'SilvestraTextNodeBundle'",
")",
";",
"}"
] |
On edit text node success.
@param string $locale
@param NodeInterface $node
@return string
|
[
"On",
"edit",
"text",
"node",
"success",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php#L90-L96
|
237,650
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.all
|
public function all()
{
$res = [];
$len = count($this->fragments);
for ($index=0; $index < $len; $index++) {
$res[] = $this->get($index);
}
return $res;
}
|
php
|
public function all()
{
$res = [];
$len = count($this->fragments);
for ($index=0; $index < $len; $index++) {
$res[] = $this->get($index);
}
return $res;
}
|
[
"public",
"function",
"all",
"(",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"len",
"=",
"count",
"(",
"$",
"this",
"->",
"fragments",
")",
";",
"for",
"(",
"$",
"index",
"=",
"0",
";",
"$",
"index",
"<",
"$",
"len",
";",
"$",
"index",
"++",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"index",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Get all fragments.
@return array<integer|null>
|
[
"Get",
"all",
"fragments",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L59-L69
|
237,651
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.with
|
public function with($index, $value)
{
$res = clone $this;
$res->fragments = $this->insertInList($res->fragments, $index, $value);
return $this;
}
|
php
|
public function with($index, $value)
{
$res = clone $this;
$res->fragments = $this->insertInList($res->fragments, $index, $value);
return $this;
}
|
[
"public",
"function",
"with",
"(",
"$",
"index",
",",
"$",
"value",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"fragments",
"=",
"$",
"this",
"->",
"insertInList",
"(",
"$",
"res",
"->",
"fragments",
",",
"$",
"index",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set time fragment, adding null fragments if needed.
@param integer $index
@param integer|null $value
|
[
"Set",
"time",
"fragment",
"adding",
"null",
"fragments",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L98-L105
|
237,652
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.withFragments
|
public function withFragments(array $fragments)
{
$res = clone $this;
$res->fragments = $res->fillArrayInput($fragments);
return $res;
}
|
php
|
public function withFragments(array $fragments)
{
$res = clone $this;
$res->fragments = $res->fillArrayInput($fragments);
return $res;
}
|
[
"public",
"function",
"withFragments",
"(",
"array",
"$",
"fragments",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"fragments",
"=",
"$",
"res",
"->",
"fillArrayInput",
"(",
"$",
"fragments",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Set all fragments, adding null fragments if needed.
@param array<integer|null> $fragments
@return static a new instance.
|
[
"Set",
"all",
"fragments",
"adding",
"null",
"fragments",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L114-L121
|
237,653
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.withSize
|
public function withSize($index, $value)
{
$res = clone $this;
$res->sizes = $this->insertInList($res->sizes, $index, $value);
return $res;
}
|
php
|
public function withSize($index, $value)
{
$res = clone $this;
$res->sizes = $this->insertInList($res->sizes, $index, $value);
return $res;
}
|
[
"public",
"function",
"withSize",
"(",
"$",
"index",
",",
"$",
"value",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"sizes",
"=",
"$",
"this",
"->",
"insertInList",
"(",
"$",
"res",
"->",
"sizes",
",",
"$",
"index",
",",
"$",
"value",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Set time fragment size, adding null values if needed.
@param integer $index
@param integer|null $value
|
[
"Set",
"time",
"fragment",
"size",
"adding",
"null",
"values",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L153-L160
|
237,654
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.withSizes
|
public function withSizes(array $sizes)
{
$res = clone $this;
$res->sizes = $res->fillArrayInput($sizes);
return $res;
}
|
php
|
public function withSizes(array $sizes)
{
$res = clone $this;
$res->sizes = $res->fillArrayInput($sizes);
return $res;
}
|
[
"public",
"function",
"withSizes",
"(",
"array",
"$",
"sizes",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"sizes",
"=",
"$",
"res",
"->",
"fillArrayInput",
"(",
"$",
"sizes",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Set all sizes, adding null values if needed.
@param array<integer|null> $sizes
@return static a new instance.
|
[
"Set",
"all",
"sizes",
"adding",
"null",
"values",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L169-L176
|
237,655
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.insertInList
|
public function insertInList(array $values, $index, $value)
{
for ($i=count($values); $i < $index; $i++) {
$values[$i] = null;
}
$values[$index] = $value;
return $values;
}
|
php
|
public function insertInList(array $values, $index, $value)
{
for ($i=count($values); $i < $index; $i++) {
$values[$i] = null;
}
$values[$index] = $value;
return $values;
}
|
[
"public",
"function",
"insertInList",
"(",
"array",
"$",
"values",
",",
"$",
"index",
",",
"$",
"value",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"values",
")",
";",
"$",
"i",
"<",
"$",
"index",
";",
"$",
"i",
"++",
")",
"{",
"$",
"values",
"[",
"$",
"i",
"]",
"=",
"null",
";",
"}",
"$",
"values",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"values",
";",
"}"
] |
Insrt a value in a list, inserting null values if needed to keep a
conscutive indexing.
@param array $values Actual values.
@param integer $index New value index.
@param mixed|null $value New value.
@return array new value list.
|
[
"Insrt",
"a",
"value",
"in",
"a",
"list",
"inserting",
"null",
"values",
"if",
"needed",
"to",
"keep",
"a",
"conscutive",
"indexing",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L188-L197
|
237,656
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.withTransversal
|
public function withTransversal($index, $value)
{
$res = clone $this;
$res->transversals = $this->insertInList($res->transversals, $index, $value);
return $res;
}
|
php
|
public function withTransversal($index, $value)
{
$res = clone $this;
$res->transversals = $this->insertInList($res->transversals, $index, $value);
return $res;
}
|
[
"public",
"function",
"withTransversal",
"(",
"$",
"index",
",",
"$",
"value",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"transversals",
"=",
"$",
"this",
"->",
"insertInList",
"(",
"$",
"res",
"->",
"transversals",
",",
"$",
"index",
",",
"$",
"value",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Set transversal unit, adding null values if needed.
@param integer $index
@param integer|null $value
|
[
"Set",
"transversal",
"unit",
"adding",
"null",
"values",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L229-L236
|
237,657
|
popy-dev/popy-calendar
|
src/ValueObject/AbstractFragmentedDuration.php
|
AbstractFragmentedDuration.withTransversals
|
public function withTransversals(array $transversals)
{
$res = clone $this;
$res->transversals = $res->fillArrayInput($transversals);
return $res;
}
|
php
|
public function withTransversals(array $transversals)
{
$res = clone $this;
$res->transversals = $res->fillArrayInput($transversals);
return $res;
}
|
[
"public",
"function",
"withTransversals",
"(",
"array",
"$",
"transversals",
")",
"{",
"$",
"res",
"=",
"clone",
"$",
"this",
";",
"$",
"res",
"->",
"transversals",
"=",
"$",
"res",
"->",
"fillArrayInput",
"(",
"$",
"transversals",
")",
";",
"return",
"$",
"res",
";",
"}"
] |
Set all transversal units, adding null values if needed.
@param array<integer|null> $transversals
@return static a new instance.
|
[
"Set",
"all",
"transversal",
"units",
"adding",
"null",
"values",
"if",
"needed",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L245-L252
|
237,658
|
DivideBV/PHPDivideIQ
|
src/Token.php
|
Token.expired
|
public function expired(\DateTime $date = null)
{
// Check if the token has an expiration date.
if (!$this->expire) {
return false;
}
$date = $date ?: new \DateTime('now', new \DateTimezone('UTC'));
return ($date > $this->expire);
}
|
php
|
public function expired(\DateTime $date = null)
{
// Check if the token has an expiration date.
if (!$this->expire) {
return false;
}
$date = $date ?: new \DateTime('now', new \DateTimezone('UTC'));
return ($date > $this->expire);
}
|
[
"public",
"function",
"expired",
"(",
"\\",
"DateTime",
"$",
"date",
"=",
"null",
")",
"{",
"// Check if the token has an expiration date.",
"if",
"(",
"!",
"$",
"this",
"->",
"expire",
")",
"{",
"return",
"false",
";",
"}",
"$",
"date",
"=",
"$",
"date",
"?",
":",
"new",
"\\",
"DateTime",
"(",
"'now'",
",",
"new",
"\\",
"DateTimezone",
"(",
"'UTC'",
")",
")",
";",
"return",
"(",
"$",
"date",
">",
"$",
"this",
"->",
"expire",
")",
";",
"}"
] |
Checks whether the token has expired or is still valid.
If the token has no expiration date, assumes the token doesn't expire.
@param \DateTime $date
(optional) The date to compare with the epiration date of the token.
If not provided, the current time is used.
@return bool
|
[
"Checks",
"whether",
"the",
"token",
"has",
"expired",
"or",
"is",
"still",
"valid",
"."
] |
bd12e3c226b061d7152f93ab1195fbaaf074b20d
|
https://github.com/DivideBV/PHPDivideIQ/blob/bd12e3c226b061d7152f93ab1195fbaaf074b20d/src/Token.php#L71-L81
|
237,659
|
popy-dev/popy-calendar
|
src/Converter/UnixTimeConverter/TimeOffset.php
|
TimeOffset.extractAbbreviation
|
protected function extractAbbreviation(DateRepresentationInterface $input)
{
$offset = $input->getOffset();
if (null === $abbr = $offset->getAbbreviation()) {
return $input;
}
$abbr = strtolower($abbr);
$list = DateTimeZone::listAbbreviations();
if (!isset($list[$abbr]) || empty($list[$abbr])) {
return $input;
}
$list = $list[$abbr];
$criterias = [
'offset' => $offset->getValue(),
'timezone_id' => $input->getTimezone()->getName(),
'dst' => $offset->isDst(),
];
foreach ($criterias as $key => $value) {
if (null === $value) {
continue;
}
$previous = $list;
$list = array_filter($list, function ($infos) use ($key, $value) {
return $value === $infos[$key];
});
if (empty($list)) {
$list = $previous;
}
}
$infos = reset($list);
if (null === $offset->getValue()) {
$offset = $offset->withValue($infos['offset']);
}
return $input
->withOffset($offset->withDst($infos['dst']))
->withTimezone(new DateTimeZone($infos['timezone_id']))
;
}
|
php
|
protected function extractAbbreviation(DateRepresentationInterface $input)
{
$offset = $input->getOffset();
if (null === $abbr = $offset->getAbbreviation()) {
return $input;
}
$abbr = strtolower($abbr);
$list = DateTimeZone::listAbbreviations();
if (!isset($list[$abbr]) || empty($list[$abbr])) {
return $input;
}
$list = $list[$abbr];
$criterias = [
'offset' => $offset->getValue(),
'timezone_id' => $input->getTimezone()->getName(),
'dst' => $offset->isDst(),
];
foreach ($criterias as $key => $value) {
if (null === $value) {
continue;
}
$previous = $list;
$list = array_filter($list, function ($infos) use ($key, $value) {
return $value === $infos[$key];
});
if (empty($list)) {
$list = $previous;
}
}
$infos = reset($list);
if (null === $offset->getValue()) {
$offset = $offset->withValue($infos['offset']);
}
return $input
->withOffset($offset->withDst($infos['dst']))
->withTimezone(new DateTimeZone($infos['timezone_id']))
;
}
|
[
"protected",
"function",
"extractAbbreviation",
"(",
"DateRepresentationInterface",
"$",
"input",
")",
"{",
"$",
"offset",
"=",
"$",
"input",
"->",
"getOffset",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"abbr",
"=",
"$",
"offset",
"->",
"getAbbreviation",
"(",
")",
")",
"{",
"return",
"$",
"input",
";",
"}",
"$",
"abbr",
"=",
"strtolower",
"(",
"$",
"abbr",
")",
";",
"$",
"list",
"=",
"DateTimeZone",
"::",
"listAbbreviations",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"list",
"[",
"$",
"abbr",
"]",
")",
"||",
"empty",
"(",
"$",
"list",
"[",
"$",
"abbr",
"]",
")",
")",
"{",
"return",
"$",
"input",
";",
"}",
"$",
"list",
"=",
"$",
"list",
"[",
"$",
"abbr",
"]",
";",
"$",
"criterias",
"=",
"[",
"'offset'",
"=>",
"$",
"offset",
"->",
"getValue",
"(",
")",
",",
"'timezone_id'",
"=>",
"$",
"input",
"->",
"getTimezone",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'dst'",
"=>",
"$",
"offset",
"->",
"isDst",
"(",
")",
",",
"]",
";",
"foreach",
"(",
"$",
"criterias",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"continue",
";",
"}",
"$",
"previous",
"=",
"$",
"list",
";",
"$",
"list",
"=",
"array_filter",
"(",
"$",
"list",
",",
"function",
"(",
"$",
"infos",
")",
"use",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"return",
"$",
"value",
"===",
"$",
"infos",
"[",
"$",
"key",
"]",
";",
"}",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"$",
"list",
"=",
"$",
"previous",
";",
"}",
"}",
"$",
"infos",
"=",
"reset",
"(",
"$",
"list",
")",
";",
"if",
"(",
"null",
"===",
"$",
"offset",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"offset",
"=",
"$",
"offset",
"->",
"withValue",
"(",
"$",
"infos",
"[",
"'offset'",
"]",
")",
";",
"}",
"return",
"$",
"input",
"->",
"withOffset",
"(",
"$",
"offset",
"->",
"withDst",
"(",
"$",
"infos",
"[",
"'dst'",
"]",
")",
")",
"->",
"withTimezone",
"(",
"new",
"DateTimeZone",
"(",
"$",
"infos",
"[",
"'timezone_id'",
"]",
")",
")",
";",
"}"
] |
Extract informations from timezone abbreviation.
@param DateRepresentationInterface $input
@return DateRepresentationInterface
|
[
"Extract",
"informations",
"from",
"timezone",
"abbreviation",
"."
] |
989048be18451c813cfce926229c6aaddd1b0639
|
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Converter/UnixTimeConverter/TimeOffset.php#L130-L178
|
237,660
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Customers.php
|
Customers.setBirthdate
|
public function setBirthdate($date)
{
if ($date instanceof DateTime) {
$date = $date->format('Y-m-d');
}
$this->data->birthDate = $date;
return $this;
}
|
php
|
public function setBirthdate($date)
{
if ($date instanceof DateTime) {
$date = $date->format('Y-m-d');
}
$this->data->birthDate = $date;
return $this;
}
|
[
"public",
"function",
"setBirthdate",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"$",
"date",
"instanceof",
"DateTime",
")",
"{",
"$",
"date",
"=",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d'",
")",
";",
"}",
"$",
"this",
"->",
"data",
"->",
"birthDate",
"=",
"$",
"date",
";",
"return",
"$",
"this",
";",
"}"
] |
Set customer birth date
@param string|DateTime $date
@return $this
|
[
"Set",
"customer",
"birth",
"date"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L140-L149
|
237,661
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Customers.php
|
Customers.setTaxDocument
|
public function setTaxDocument(TaxDocument $taxDocument)
{
$taxDocument->setContext(Moip::PAYMENT);
$this->data->taxDocument = $taxDocument->getData();
return $this;
}
|
php
|
public function setTaxDocument(TaxDocument $taxDocument)
{
$taxDocument->setContext(Moip::PAYMENT);
$this->data->taxDocument = $taxDocument->getData();
return $this;
}
|
[
"public",
"function",
"setTaxDocument",
"(",
"TaxDocument",
"$",
"taxDocument",
")",
"{",
"$",
"taxDocument",
"->",
"setContext",
"(",
"Moip",
"::",
"PAYMENT",
")",
";",
"$",
"this",
"->",
"data",
"->",
"taxDocument",
"=",
"$",
"taxDocument",
"->",
"getData",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set customer tax document
@param \Softpampa\Moip\Helpers\TaxDocument $taxDocument
@return $this
|
[
"Set",
"customer",
"tax",
"document"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L171-L177
|
237,662
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Customers.php
|
Customers.setCreditCard
|
public function setCreditCard(CreditCard $creditCard)
{
$creditCard->setContext(Moip::PAYMENT);
$fundingInstrument = new stdClass;
$fundingInstrument->method = 'CREDIT_CARD';
$fundingInstrument->creditCard = $creditCard->getData();
$this->data->fundingInstrument = $fundingInstrument;
unset($this->data->fundingInstruments);
return $this;
}
|
php
|
public function setCreditCard(CreditCard $creditCard)
{
$creditCard->setContext(Moip::PAYMENT);
$fundingInstrument = new stdClass;
$fundingInstrument->method = 'CREDIT_CARD';
$fundingInstrument->creditCard = $creditCard->getData();
$this->data->fundingInstrument = $fundingInstrument;
unset($this->data->fundingInstruments);
return $this;
}
|
[
"public",
"function",
"setCreditCard",
"(",
"CreditCard",
"$",
"creditCard",
")",
"{",
"$",
"creditCard",
"->",
"setContext",
"(",
"Moip",
"::",
"PAYMENT",
")",
";",
"$",
"fundingInstrument",
"=",
"new",
"stdClass",
";",
"$",
"fundingInstrument",
"->",
"method",
"=",
"'CREDIT_CARD'",
";",
"$",
"fundingInstrument",
"->",
"creditCard",
"=",
"$",
"creditCard",
"->",
"getData",
"(",
")",
";",
"$",
"this",
"->",
"data",
"->",
"fundingInstrument",
"=",
"$",
"fundingInstrument",
";",
"unset",
"(",
"$",
"this",
"->",
"data",
"->",
"fundingInstruments",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set customer credit card
@param \Softpampa\Moip\Helpers\CreditCard $creditCard
@return $this
|
[
"Set",
"customer",
"credit",
"card"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L222-L235
|
237,663
|
Softpampa/moip-sdk-php
|
src/Payments/Resources/Customers.php
|
Customers.createNewCreditCard
|
public function createNewCreditCard(CreditCard $creditCard, $id = null)
{
if (! $id) {
$id = $this->data->id;
}
$creditCard->setContext(Moip::PAYMENT);
$this->data = new stdClass;
$this->data->method = 'CREDIT_CARD';
$this->data->creditCard = $creditCard->getData();
$response = $this->client->post('{id}/fundinginstruments', [$id], $this->data);
$this->populate($response);
return $this;
}
|
php
|
public function createNewCreditCard(CreditCard $creditCard, $id = null)
{
if (! $id) {
$id = $this->data->id;
}
$creditCard->setContext(Moip::PAYMENT);
$this->data = new stdClass;
$this->data->method = 'CREDIT_CARD';
$this->data->creditCard = $creditCard->getData();
$response = $this->client->post('{id}/fundinginstruments', [$id], $this->data);
$this->populate($response);
return $this;
}
|
[
"public",
"function",
"createNewCreditCard",
"(",
"CreditCard",
"$",
"creditCard",
",",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"data",
"->",
"id",
";",
"}",
"$",
"creditCard",
"->",
"setContext",
"(",
"Moip",
"::",
"PAYMENT",
")",
";",
"$",
"this",
"->",
"data",
"=",
"new",
"stdClass",
";",
"$",
"this",
"->",
"data",
"->",
"method",
"=",
"'CREDIT_CARD'",
";",
"$",
"this",
"->",
"data",
"->",
"creditCard",
"=",
"$",
"creditCard",
"->",
"getData",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"'{id}/fundinginstruments'",
",",
"[",
"$",
"id",
"]",
",",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"populate",
"(",
"$",
"response",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Create a new credit card for customer
@param \Softpampa\Moip\Helpers\CreditCard $creditCard
@param int $id
@return $this
|
[
"Create",
"a",
"new",
"credit",
"card",
"for",
"customer"
] |
621a71bd2ef1f9b690cd3431507af608152f6ad2
|
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L265-L282
|
237,664
|
Joseki/LeanMapper-extension
|
src/Joseki/LeanMapper/Mapper.php
|
Mapper.getEntityClass
|
public function getEntityClass($table, Row $row = null)
{
$namespace = $this->defaultEntityNamespace . '\\';
return $namespace . ucfirst(Utils::underscoreToCamel($table));
}
|
php
|
public function getEntityClass($table, Row $row = null)
{
$namespace = $this->defaultEntityNamespace . '\\';
return $namespace . ucfirst(Utils::underscoreToCamel($table));
}
|
[
"public",
"function",
"getEntityClass",
"(",
"$",
"table",
",",
"Row",
"$",
"row",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"defaultEntityNamespace",
".",
"'\\\\'",
";",
"return",
"$",
"namespace",
".",
"ucfirst",
"(",
"Utils",
"::",
"underscoreToCamel",
"(",
"$",
"table",
")",
")",
";",
"}"
] |
some_entity -> App\Entity\SomeEntity
@param string $table
@param Row $row
@return string
|
[
"some_entity",
"-",
">",
"App",
"\\",
"Entity",
"\\",
"SomeEntity"
] |
5f51fed7a770bece15c6dae7f9482706d44ec7e5
|
https://github.com/Joseki/LeanMapper-extension/blob/5f51fed7a770bece15c6dae7f9482706d44ec7e5/src/Joseki/LeanMapper/Mapper.php#L45-L49
|
237,665
|
Joseki/LeanMapper-extension
|
src/Joseki/LeanMapper/Mapper.php
|
Mapper.getEntityField
|
public function getEntityField($table, $column)
{
$class = $this->getEntityClass($table);
/** @var Entity $entity */
$entity = new $class;
$reflection = $entity->getReflection($this);
foreach ($reflection->getEntityProperties() as $property) {
if ($property->getColumn() == $column) {
return Utils::underscoreToCamel($property->getName());
}
}
throw new InvalidArgumentException(sprintf("Could not find property for table '%s' and column '%s'", $table, $column));
}
|
php
|
public function getEntityField($table, $column)
{
$class = $this->getEntityClass($table);
/** @var Entity $entity */
$entity = new $class;
$reflection = $entity->getReflection($this);
foreach ($reflection->getEntityProperties() as $property) {
if ($property->getColumn() == $column) {
return Utils::underscoreToCamel($property->getName());
}
}
throw new InvalidArgumentException(sprintf("Could not find property for table '%s' and column '%s'", $table, $column));
}
|
[
"public",
"function",
"getEntityField",
"(",
"$",
"table",
",",
"$",
"column",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getEntityClass",
"(",
"$",
"table",
")",
";",
"/** @var Entity $entity */",
"$",
"entity",
"=",
"new",
"$",
"class",
";",
"$",
"reflection",
"=",
"$",
"entity",
"->",
"getReflection",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"reflection",
"->",
"getEntityProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"getColumn",
"(",
")",
"==",
"$",
"column",
")",
"{",
"return",
"Utils",
"::",
"underscoreToCamel",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Could not find property for table '%s' and column '%s'\"",
",",
"$",
"table",
",",
"$",
"column",
")",
")",
";",
"}"
] |
some_field -> someField
@param string $table
@param string $column
@return string
|
[
"some_field",
"-",
">",
"someField"
] |
5f51fed7a770bece15c6dae7f9482706d44ec7e5
|
https://github.com/Joseki/LeanMapper-extension/blob/5f51fed7a770bece15c6dae7f9482706d44ec7e5/src/Joseki/LeanMapper/Mapper.php#L72-L84
|
237,666
|
arkanmgerges/multi-tier-architecture
|
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
|
RequestAbstract.hydrateIfJsonToArray
|
private function hydrateIfJsonToArray($data)
{
if (is_array($data)) {
return $data;
}
elseif (is_string($data)) {
$attempt = json_decode($data, true);
return empty($attempt) ? $data : $attempt;
}
return [];
}
|
php
|
private function hydrateIfJsonToArray($data)
{
if (is_array($data)) {
return $data;
}
elseif (is_string($data)) {
$attempt = json_decode($data, true);
return empty($attempt) ? $data : $attempt;
}
return [];
}
|
[
"private",
"function",
"hydrateIfJsonToArray",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"data",
")",
")",
"{",
"$",
"attempt",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"return",
"empty",
"(",
"$",
"attempt",
")",
"?",
"$",
"data",
":",
"$",
"attempt",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Hydrate if the passed parameter is json to array
@param mixed $data It can be json or array
@return array
|
[
"Hydrate",
"if",
"the",
"passed",
"parameter",
"is",
"json",
"to",
"array"
] |
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
|
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L49-L60
|
237,667
|
arkanmgerges/multi-tier-architecture
|
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
|
RequestAbstract.setData
|
public function setData($data)
{
$resultData = $this->hydrateIfJsonToArray($data);
if (!empty($resultData)) {
$this->data = $resultData;
}
else {
$this->data = [];
}
}
|
php
|
public function setData($data)
{
$resultData = $this->hydrateIfJsonToArray($data);
if (!empty($resultData)) {
$this->data = $resultData;
}
else {
$this->data = [];
}
}
|
[
"public",
"function",
"setData",
"(",
"$",
"data",
")",
"{",
"$",
"resultData",
"=",
"$",
"this",
"->",
"hydrateIfJsonToArray",
"(",
"$",
"data",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"resultData",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"resultData",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"=",
"[",
"]",
";",
"}",
"}"
] |
Set data to data array
@param string|array $data Data that need to be set into extra array
@return void
|
[
"Set",
"data",
"to",
"data",
"array"
] |
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
|
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L175-L184
|
237,668
|
arkanmgerges/multi-tier-architecture
|
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
|
RequestAbstract.setExtra
|
public function setExtra($extra)
{
$resultData = $this->hydrateIfJsonToArray($extra);
if (!empty($resultData)) {
$this->extra = $resultData;
}
else {
$this->extra = [];
}
}
|
php
|
public function setExtra($extra)
{
$resultData = $this->hydrateIfJsonToArray($extra);
if (!empty($resultData)) {
$this->extra = $resultData;
}
else {
$this->extra = [];
}
}
|
[
"public",
"function",
"setExtra",
"(",
"$",
"extra",
")",
"{",
"$",
"resultData",
"=",
"$",
"this",
"->",
"hydrateIfJsonToArray",
"(",
"$",
"extra",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"resultData",
")",
")",
"{",
"$",
"this",
"->",
"extra",
"=",
"$",
"resultData",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"extra",
"=",
"[",
"]",
";",
"}",
"}"
] |
Set data to extra array
@param string|array $extra Data that need to be set into extra array
@return void
|
[
"Set",
"data",
"to",
"extra",
"array"
] |
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
|
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L193-L202
|
237,669
|
lazyguru/toggl
|
src/TogglService.php
|
TogglService.saveTimeEntry
|
public function saveTimeEntry(TimeEntry $entry)
{
$startTime = strtotime($entry->getEntryDate());
$endTime = $startTime + $entry->getDurationTime();
$this->uri = 'https://www.toggl.com/api/v8/time_entries/' . $entry->getId();
$data = [
'time_entry' => [
'description' => $entry->getDescription(),
'start' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $startTime), 0, 22) . ':00',
'stop' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $endTime), 0, 22) . ':00',
'billable' => $entry->isBillable(),
'wid' => $this->workspace_id,
'duration' => $entry->getDurationTime(),
'tags' => $entry->getTags(),
'id' => $entry->getId(),
'created_with' => $this->user_agent
]
];
$this->output->debug(print_r($data, true));
$data = json_encode($data);
$response = $this->processRequest($data, self::PUT);
$this->_handleError($data, $response);
return $entry;
}
|
php
|
public function saveTimeEntry(TimeEntry $entry)
{
$startTime = strtotime($entry->getEntryDate());
$endTime = $startTime + $entry->getDurationTime();
$this->uri = 'https://www.toggl.com/api/v8/time_entries/' . $entry->getId();
$data = [
'time_entry' => [
'description' => $entry->getDescription(),
'start' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $startTime), 0, 22) . ':00',
'stop' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $endTime), 0, 22) . ':00',
'billable' => $entry->isBillable(),
'wid' => $this->workspace_id,
'duration' => $entry->getDurationTime(),
'tags' => $entry->getTags(),
'id' => $entry->getId(),
'created_with' => $this->user_agent
]
];
$this->output->debug(print_r($data, true));
$data = json_encode($data);
$response = $this->processRequest($data, self::PUT);
$this->_handleError($data, $response);
return $entry;
}
|
[
"public",
"function",
"saveTimeEntry",
"(",
"TimeEntry",
"$",
"entry",
")",
"{",
"$",
"startTime",
"=",
"strtotime",
"(",
"$",
"entry",
"->",
"getEntryDate",
"(",
")",
")",
";",
"$",
"endTime",
"=",
"$",
"startTime",
"+",
"$",
"entry",
"->",
"getDurationTime",
"(",
")",
";",
"$",
"this",
"->",
"uri",
"=",
"'https://www.toggl.com/api/v8/time_entries/'",
".",
"$",
"entry",
"->",
"getId",
"(",
")",
";",
"$",
"data",
"=",
"[",
"'time_entry'",
"=>",
"[",
"'description'",
"=>",
"$",
"entry",
"->",
"getDescription",
"(",
")",
",",
"'start'",
"=>",
"substr",
"(",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%S%z'",
",",
"$",
"startTime",
")",
",",
"0",
",",
"22",
")",
".",
"':00'",
",",
"'stop'",
"=>",
"substr",
"(",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%S%z'",
",",
"$",
"endTime",
")",
",",
"0",
",",
"22",
")",
".",
"':00'",
",",
"'billable'",
"=>",
"$",
"entry",
"->",
"isBillable",
"(",
")",
",",
"'wid'",
"=>",
"$",
"this",
"->",
"workspace_id",
",",
"'duration'",
"=>",
"$",
"entry",
"->",
"getDurationTime",
"(",
")",
",",
"'tags'",
"=>",
"$",
"entry",
"->",
"getTags",
"(",
")",
",",
"'id'",
"=>",
"$",
"entry",
"->",
"getId",
"(",
")",
",",
"'created_with'",
"=>",
"$",
"this",
"->",
"user_agent",
"]",
"]",
";",
"$",
"this",
"->",
"output",
"->",
"debug",
"(",
"print_r",
"(",
"$",
"data",
",",
"true",
")",
")",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"data",
",",
"self",
"::",
"PUT",
")",
";",
"$",
"this",
"->",
"_handleError",
"(",
"$",
"data",
",",
"$",
"response",
")",
";",
"return",
"$",
"entry",
";",
"}"
] |
Persists a time entry to the Toggl API
@param TimeEntry $entry
@return TimeEntry
|
[
"Persists",
"a",
"time",
"entry",
"to",
"the",
"Toggl",
"API"
] |
5ce8b5f937b38dc5afd40b362db26e93239d7135
|
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TogglService.php#L47-L72
|
237,670
|
lazyguru/toggl
|
src/TogglService.php
|
TogglService.processTogglResponse
|
protected function processTogglResponse($response)
{
// We only need to do something if results are paginated
if ($response->total_count <= 50) {
return $response->data;
}
$reqdata = [];
$reqdata = json_encode($reqdata);
$pages = ceil($response->total_count / 50);
$curr_page = 1;
$data = $response->data;
$orig_uri = $this->uri;
while ($curr_page < $pages) {
$curr_page++;
$this->uri .= '&page=' . $curr_page;
$response = $this->processRequest($reqdata, self::GET);
$this->_handleError($reqdata, $response);
foreach ($response->data as $entry) {
$data[] = $entry;
}
$this->uri = $orig_uri;
}
return $data;
}
|
php
|
protected function processTogglResponse($response)
{
// We only need to do something if results are paginated
if ($response->total_count <= 50) {
return $response->data;
}
$reqdata = [];
$reqdata = json_encode($reqdata);
$pages = ceil($response->total_count / 50);
$curr_page = 1;
$data = $response->data;
$orig_uri = $this->uri;
while ($curr_page < $pages) {
$curr_page++;
$this->uri .= '&page=' . $curr_page;
$response = $this->processRequest($reqdata, self::GET);
$this->_handleError($reqdata, $response);
foreach ($response->data as $entry) {
$data[] = $entry;
}
$this->uri = $orig_uri;
}
return $data;
}
|
[
"protected",
"function",
"processTogglResponse",
"(",
"$",
"response",
")",
"{",
"// We only need to do something if results are paginated",
"if",
"(",
"$",
"response",
"->",
"total_count",
"<=",
"50",
")",
"{",
"return",
"$",
"response",
"->",
"data",
";",
"}",
"$",
"reqdata",
"=",
"[",
"]",
";",
"$",
"reqdata",
"=",
"json_encode",
"(",
"$",
"reqdata",
")",
";",
"$",
"pages",
"=",
"ceil",
"(",
"$",
"response",
"->",
"total_count",
"/",
"50",
")",
";",
"$",
"curr_page",
"=",
"1",
";",
"$",
"data",
"=",
"$",
"response",
"->",
"data",
";",
"$",
"orig_uri",
"=",
"$",
"this",
"->",
"uri",
";",
"while",
"(",
"$",
"curr_page",
"<",
"$",
"pages",
")",
"{",
"$",
"curr_page",
"++",
";",
"$",
"this",
"->",
"uri",
".=",
"'&page='",
".",
"$",
"curr_page",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"reqdata",
",",
"self",
"::",
"GET",
")",
";",
"$",
"this",
"->",
"_handleError",
"(",
"$",
"reqdata",
",",
"$",
"response",
")",
";",
"foreach",
"(",
"$",
"response",
"->",
"data",
"as",
"$",
"entry",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"entry",
";",
"}",
"$",
"this",
"->",
"uri",
"=",
"$",
"orig_uri",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Process the response from Toggl to create a TimeEntry object
@param array $response API response
@return array
|
[
"Process",
"the",
"response",
"from",
"Toggl",
"to",
"create",
"a",
"TimeEntry",
"object"
] |
5ce8b5f937b38dc5afd40b362db26e93239d7135
|
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TogglService.php#L124-L151
|
237,671
|
jmpantoja/planb-utils
|
src/Type/Assurance/AssuranceMethod.php
|
AssuranceMethod.initialize
|
private function initialize(object $object, string $original, string $inverted): void
{
$this->initMethod($object, $original, true);
$this->initMethod($object, $inverted, false);
}
|
php
|
private function initialize(object $object, string $original, string $inverted): void
{
$this->initMethod($object, $original, true);
$this->initMethod($object, $inverted, false);
}
|
[
"private",
"function",
"initialize",
"(",
"object",
"$",
"object",
",",
"string",
"$",
"original",
",",
"string",
"$",
"inverted",
")",
":",
"void",
"{",
"$",
"this",
"->",
"initMethod",
"(",
"$",
"object",
",",
"$",
"original",
",",
"true",
")",
";",
"$",
"this",
"->",
"initMethod",
"(",
"$",
"object",
",",
"$",
"inverted",
",",
"false",
")",
";",
"}"
] |
Inicializa la instancia calculando los valores para method y expected
@param object $object
@param string $original
@param string $inverted
|
[
"Inicializa",
"la",
"instancia",
"calculando",
"los",
"valores",
"para",
"method",
"y",
"expected"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Assurance/AssuranceMethod.php#L97-L101
|
237,672
|
mapado/doctrine-blender
|
lib/ObjectBlender.php
|
ObjectBlender.mapExternalAssociation
|
public function mapExternalAssociation(
ExternalAssociation $externalAssociation
) {
// @See https://github.com/doctrine/common/issues/336
//if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) {
if (!(method_exists($externalAssociation->getReferenceManager(), 'getReference'))) {
$msg = '$referenceManager needs to implements a `getReference` method';
throw new \InvalidArgumentException($msg);
}
$this->eventListener->addExternalAssoctiation($externalAssociation);
$externalAssociation->getObjectManager()
->getEventManager()
->addEventListener(['postLoad'], $this->eventListener);
// todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged
}
|
php
|
public function mapExternalAssociation(
ExternalAssociation $externalAssociation
) {
// @See https://github.com/doctrine/common/issues/336
//if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) {
if (!(method_exists($externalAssociation->getReferenceManager(), 'getReference'))) {
$msg = '$referenceManager needs to implements a `getReference` method';
throw new \InvalidArgumentException($msg);
}
$this->eventListener->addExternalAssoctiation($externalAssociation);
$externalAssociation->getObjectManager()
->getEventManager()
->addEventListener(['postLoad'], $this->eventListener);
// todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged
}
|
[
"public",
"function",
"mapExternalAssociation",
"(",
"ExternalAssociation",
"$",
"externalAssociation",
")",
"{",
"// @See https://github.com/doctrine/common/issues/336",
"//if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) {",
"if",
"(",
"!",
"(",
"method_exists",
"(",
"$",
"externalAssociation",
"->",
"getReferenceManager",
"(",
")",
",",
"'getReference'",
")",
")",
")",
"{",
"$",
"msg",
"=",
"'$referenceManager needs to implements a `getReference` method'",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"eventListener",
"->",
"addExternalAssoctiation",
"(",
"$",
"externalAssociation",
")",
";",
"$",
"externalAssociation",
"->",
"getObjectManager",
"(",
")",
"->",
"getEventManager",
"(",
")",
"->",
"addEventListener",
"(",
"[",
"'postLoad'",
"]",
",",
"$",
"this",
"->",
"eventListener",
")",
";",
"// todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged",
"}"
] |
Map an external association between two differents Object Manager
@param ExternalAssociation $externalAssociation the external association object
@access public
@return void
|
[
"Map",
"an",
"external",
"association",
"between",
"two",
"differents",
"Object",
"Manager"
] |
73edac762598d35062d8c220b05459dc7fdae20d
|
https://github.com/mapado/doctrine-blender/blob/73edac762598d35062d8c220b05459dc7fdae20d/lib/ObjectBlender.php#L44-L61
|
237,673
|
olajoscs/QueryBuilder
|
src/ConnectionFactory.php
|
ConnectionFactory.create
|
public function create(PDO $pdo)
{
switch ($pdo->getDatabaseType()) {
case 'mysql':
$connection = new MySqlConnection($pdo);
break;
case 'pgsql':
$connection = new PostgreSqlConnection($pdo);
break;
case 'sqlite':
$connection = new SQLiteConnection($pdo);
break;
default:
throw new InvalidDriverException('Not implemented driver: ' . $pdo->getDatabaseType());
}
return $connection;
}
|
php
|
public function create(PDO $pdo)
{
switch ($pdo->getDatabaseType()) {
case 'mysql':
$connection = new MySqlConnection($pdo);
break;
case 'pgsql':
$connection = new PostgreSqlConnection($pdo);
break;
case 'sqlite':
$connection = new SQLiteConnection($pdo);
break;
default:
throw new InvalidDriverException('Not implemented driver: ' . $pdo->getDatabaseType());
}
return $connection;
}
|
[
"public",
"function",
"create",
"(",
"PDO",
"$",
"pdo",
")",
"{",
"switch",
"(",
"$",
"pdo",
"->",
"getDatabaseType",
"(",
")",
")",
"{",
"case",
"'mysql'",
":",
"$",
"connection",
"=",
"new",
"MySqlConnection",
"(",
"$",
"pdo",
")",
";",
"break",
";",
"case",
"'pgsql'",
":",
"$",
"connection",
"=",
"new",
"PostgreSqlConnection",
"(",
"$",
"pdo",
")",
";",
"break",
";",
"case",
"'sqlite'",
":",
"$",
"connection",
"=",
"new",
"SQLiteConnection",
"(",
"$",
"pdo",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidDriverException",
"(",
"'Not implemented driver: '",
".",
"$",
"pdo",
"->",
"getDatabaseType",
"(",
")",
")",
";",
"}",
"return",
"$",
"connection",
";",
"}"
] |
Create a new Connection based on the config
@param PDO $pdo
@return Connection
@throws InvalidDriverException
|
[
"Create",
"a",
"new",
"Connection",
"based",
"on",
"the",
"config"
] |
5e1568ced2c2c7f0294cf32f30a290db1e642035
|
https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/ConnectionFactory.php#L26-L43
|
237,674
|
webberig/html-utilbelt
|
src/Generator/GeneratorAbstract.php
|
GeneratorAbstract.updateElement
|
public function updateElement(Element $element, array $data) {
if (isset($data["id"])) {
$element->setId($data["id"]);
}
if (isset($data["class"])) {
$element->addClass($data["class"]);
}
return $element;
}
|
php
|
public function updateElement(Element $element, array $data) {
if (isset($data["id"])) {
$element->setId($data["id"]);
}
if (isset($data["class"])) {
$element->addClass($data["class"]);
}
return $element;
}
|
[
"public",
"function",
"updateElement",
"(",
"Element",
"$",
"element",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"\"id\"",
"]",
")",
")",
"{",
"$",
"element",
"->",
"setId",
"(",
"$",
"data",
"[",
"\"id\"",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"\"class\"",
"]",
")",
")",
"{",
"$",
"element",
"->",
"addClass",
"(",
"$",
"data",
"[",
"\"class\"",
"]",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] |
Set element properties using a json string
@param Element $element array
@param $data array
@return Element $element
|
[
"Set",
"element",
"properties",
"using",
"a",
"json",
"string"
] |
0f49426e46ff9958e2454c44852a0aa9fd83ff74
|
https://github.com/webberig/html-utilbelt/blob/0f49426e46ff9958e2454c44852a0aa9fd83ff74/src/Generator/GeneratorAbstract.php#L21-L29
|
237,675
|
it-blaster/uploadable-bundle
|
Form/Type/UploadableType.php
|
UploadableType.onPreSetData
|
public function onPreSetData(FormEvent $event)
{
if (!$event->getData() || !$event->getForm()->getConfig()->getOption('removable')) {
return;
}
$event->getForm()->add('remove', 'checkbox', array(
'label' => $this->options['remove_label']
));
}
|
php
|
public function onPreSetData(FormEvent $event)
{
if (!$event->getData() || !$event->getForm()->getConfig()->getOption('removable')) {
return;
}
$event->getForm()->add('remove', 'checkbox', array(
'label' => $this->options['remove_label']
));
}
|
[
"public",
"function",
"onPreSetData",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"getData",
"(",
")",
"||",
"!",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"getConfig",
"(",
")",
"->",
"getOption",
"(",
"'removable'",
")",
")",
"{",
"return",
";",
"}",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"add",
"(",
"'remove'",
",",
"'checkbox'",
",",
"array",
"(",
"'label'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'remove_label'",
"]",
")",
")",
";",
"}"
] |
Adds a remove-field if need
@param FormEvent $event
|
[
"Adds",
"a",
"remove",
"-",
"field",
"if",
"need"
] |
76b9a17b292965d334bf3338b2bbc54cd17a7829
|
https://github.com/it-blaster/uploadable-bundle/blob/76b9a17b292965d334bf3338b2bbc54cd17a7829/Form/Type/UploadableType.php#L93-L102
|
237,676
|
it-blaster/uploadable-bundle
|
Form/Type/UploadableType.php
|
UploadableType.onPreSubmit
|
public function onPreSubmit(FormEvent $event)
{
$data = $event->getData();
if ($data['file'] instanceof UploadedFile) {
$event->getForm()->remove('remove');
}
if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
$event->setData($event->getForm()->getViewData());
}
}
|
php
|
public function onPreSubmit(FormEvent $event)
{
$data = $event->getData();
if ($data['file'] instanceof UploadedFile) {
$event->getForm()->remove('remove');
}
if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
$event->setData($event->getForm()->getViewData());
}
}
|
[
"public",
"function",
"onPreSubmit",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"$",
"data",
"=",
"$",
"event",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"$",
"data",
"[",
"'file'",
"]",
"instanceof",
"UploadedFile",
")",
"{",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"remove",
"(",
"'remove'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'file'",
"]",
")",
"&&",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'remove'",
"]",
")",
"||",
"!",
"$",
"data",
"[",
"'remove'",
"]",
")",
")",
"{",
"$",
"event",
"->",
"setData",
"(",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"getViewData",
"(",
")",
")",
";",
"}",
"}"
] |
Forbids to erase a value
@param FormEvent $event
|
[
"Forbids",
"to",
"erase",
"a",
"value"
] |
76b9a17b292965d334bf3338b2bbc54cd17a7829
|
https://github.com/it-blaster/uploadable-bundle/blob/76b9a17b292965d334bf3338b2bbc54cd17a7829/Form/Type/UploadableType.php#L109-L120
|
237,677
|
ekyna/GoogleBundle
|
DependencyInjection/Configuration.php
|
Configuration.addClientSection
|
private function addClientSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('client')
->children()
->scalarNode('application_name')->isRequired()->cannotBeEmpty()->end()
->scalarNode('client_id')->end()
->scalarNode('client_secret')->end()
->scalarNode('redirect_uri')->end()
->scalarNode('developer_key')->end()
->end()
->end()
->end()
;
}
|
php
|
private function addClientSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('client')
->children()
->scalarNode('application_name')->isRequired()->cannotBeEmpty()->end()
->scalarNode('client_id')->end()
->scalarNode('client_secret')->end()
->scalarNode('redirect_uri')->end()
->scalarNode('developer_key')->end()
->end()
->end()
->end()
;
}
|
[
"private",
"function",
"addClientSection",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'client'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'application_name'",
")",
"->",
"isRequired",
"(",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'client_id'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'client_secret'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'redirect_uri'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'developer_key'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"}"
] |
Adds the client section.
@param ArrayNodeDefinition $node
|
[
"Adds",
"the",
"client",
"section",
"."
] |
b6689522de5911b8de332b18c07154eafc5f3589
|
https://github.com/ekyna/GoogleBundle/blob/b6689522de5911b8de332b18c07154eafc5f3589/DependencyInjection/Configuration.php#L34-L49
|
237,678
|
codebobbly/dvoconnector
|
Classes/Controller/AssociationStaticController.php
|
AssociationStaticController.singleAssociationAction
|
public function singleAssociationAction()
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID]
], __CLASS__, __FUNCTION__);
return $this->view->render();
}
|
php
|
public function singleAssociationAction()
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID]
], __CLASS__, __FUNCTION__);
return $this->view->render();
}
|
[
"public",
"function",
"singleAssociationAction",
"(",
")",
"{",
"$",
"this",
"->",
"checkStaticTemplateIsIncluded",
"(",
")",
";",
"$",
"this",
"->",
"checkSettings",
"(",
")",
";",
"$",
"this",
"->",
"slotExtendedAssignMultiple",
"(",
"[",
"self",
"::",
"VIEW_VARIABLE_ASSOCIATION_ID",
"=>",
"$",
"this",
"->",
"settings",
"[",
"self",
"::",
"SETTINGS_ASSOCIATION_ID",
"]",
"]",
",",
"__CLASS__",
",",
"__FUNCTION__",
")",
";",
"return",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
")",
";",
"}"
] |
single association action.
@return string
|
[
"single",
"association",
"action",
"."
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationStaticController.php#L31-L41
|
237,679
|
lciolecki/zf-extensions-library
|
library/Extlib/Traits/Logger.php
|
Logger.getLogger
|
public function getLogger()
{
if (null === $this->logger && \Zend_Registry::isRegistered(self::getNamespace())) {
$this->setLogger(\Zend_Registry::get(self::getNamespace()));
}
return $this->logger;
}
|
php
|
public function getLogger()
{
if (null === $this->logger && \Zend_Registry::isRegistered(self::getNamespace())) {
$this->setLogger(\Zend_Registry::get(self::getNamespace()));
}
return $this->logger;
}
|
[
"public",
"function",
"getLogger",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"logger",
"&&",
"\\",
"Zend_Registry",
"::",
"isRegistered",
"(",
"self",
"::",
"getNamespace",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"setLogger",
"(",
"\\",
"Zend_Registry",
"::",
"get",
"(",
"self",
"::",
"getNamespace",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"logger",
";",
"}"
] |
Get instance of logger
@return \Zend_Log
|
[
"Get",
"instance",
"of",
"logger"
] |
f479a63188d17f1488b392d4fc14fe47a417ea55
|
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Traits/Logger.php#L34-L41
|
237,680
|
indigophp-archive/fuel-core
|
classes/Providers/FuelServiceProvider.php
|
FuelServiceProvider.resolveManager
|
public function resolveManager($dic, $placement = 'prepend')
{
$manager = $dic->resolve('Fuel\\Alias\\Manager');
$manager->register($placement);
return $manager;
}
|
php
|
public function resolveManager($dic, $placement = 'prepend')
{
$manager = $dic->resolve('Fuel\\Alias\\Manager');
$manager->register($placement);
return $manager;
}
|
[
"public",
"function",
"resolveManager",
"(",
"$",
"dic",
",",
"$",
"placement",
"=",
"'prepend'",
")",
"{",
"$",
"manager",
"=",
"$",
"dic",
"->",
"resolve",
"(",
"'Fuel\\\\Alias\\\\Manager'",
")",
";",
"$",
"manager",
"->",
"register",
"(",
"$",
"placement",
")",
";",
"return",
"$",
"manager",
";",
"}"
] |
Resolves an Alias Manager
@param Container $dic
@param string $placement
@return Manager
|
[
"Resolves",
"an",
"Alias",
"Manager"
] |
275462154fb7937f8e1c2c541b31d8e7c5760e39
|
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/Providers/FuelServiceProvider.php#L49-L56
|
237,681
|
wucdbm/wucdbm-bundle
|
Twig/ControllerActionName.php
|
ControllerActionName.controllerName
|
public function controllerName() {
$request = $this->stack->getCurrentRequest();
if ($request instanceof Request) {
$string = $request->get('_controller');
$parts = explode('::', $string);
$controller = $parts[0];
$pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#";
$matches = array();
preg_match($pattern, $controller, $matches);
if (isset($matches[1])) {
return strtolower(str_replace('\\', '_', $matches[1]));
}
return '';
}
return '';
}
|
php
|
public function controllerName() {
$request = $this->stack->getCurrentRequest();
if ($request instanceof Request) {
$string = $request->get('_controller');
$parts = explode('::', $string);
$controller = $parts[0];
$pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#";
$matches = array();
preg_match($pattern, $controller, $matches);
if (isset($matches[1])) {
return strtolower(str_replace('\\', '_', $matches[1]));
}
return '';
}
return '';
}
|
[
"public",
"function",
"controllerName",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"stack",
"->",
"getCurrentRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"instanceof",
"Request",
")",
"{",
"$",
"string",
"=",
"$",
"request",
"->",
"get",
"(",
"'_controller'",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'::'",
",",
"$",
"string",
")",
";",
"$",
"controller",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"pattern",
"=",
"\"#Controller\\\\\\([a-zA-Z\\\\\\]*)Controller#\"",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"controller",
",",
"$",
"matches",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"strtolower",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
")",
";",
"}",
"return",
"''",
";",
"}",
"return",
"''",
";",
"}"
] |
Get current controller name
|
[
"Get",
"current",
"controller",
"name"
] |
7479e7a864b58b03c7b1045d4021f683b5396245
|
https://github.com/wucdbm/wucdbm-bundle/blob/7479e7a864b58b03c7b1045d4021f683b5396245/Twig/ControllerActionName.php#L43-L60
|
237,682
|
wucdbm/wucdbm-bundle
|
Twig/ControllerActionName.php
|
ControllerActionName.actionName
|
public function actionName() {
$request = $this->stack->getCurrentRequest();
if ($request instanceof Request) {
$pattern = "#::([a-zA-Z]*)Action#";
$matches = array();
preg_match($pattern, $request->get('_controller'), $matches);
if (isset($matches[1])) {
return strtolower($matches[1]);
}
return '';
}
return '';
}
|
php
|
public function actionName() {
$request = $this->stack->getCurrentRequest();
if ($request instanceof Request) {
$pattern = "#::([a-zA-Z]*)Action#";
$matches = array();
preg_match($pattern, $request->get('_controller'), $matches);
if (isset($matches[1])) {
return strtolower($matches[1]);
}
return '';
}
return '';
}
|
[
"public",
"function",
"actionName",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"stack",
"->",
"getCurrentRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"instanceof",
"Request",
")",
"{",
"$",
"pattern",
"=",
"\"#::([a-zA-Z]*)Action#\"",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"request",
"->",
"get",
"(",
"'_controller'",
")",
",",
"$",
"matches",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"strtolower",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"return",
"''",
";",
"}",
"return",
"''",
";",
"}"
] |
Get current action name
|
[
"Get",
"current",
"action",
"name"
] |
7479e7a864b58b03c7b1045d4021f683b5396245
|
https://github.com/wucdbm/wucdbm-bundle/blob/7479e7a864b58b03c7b1045d4021f683b5396245/Twig/ControllerActionName.php#L65-L79
|
237,683
|
kpacha/php-benchmark-tool
|
src/Kpacha/BenchmarkTool/Benchmarker/Base.php
|
Base.run
|
public function run($target)
{
$return = $this->exec($this->getCommand($target));
return $this->output[$target] = $this->cleanOutput($target, $return['output']);
}
|
php
|
public function run($target)
{
$return = $this->exec($this->getCommand($target));
return $this->output[$target] = $this->cleanOutput($target, $return['output']);
}
|
[
"public",
"function",
"run",
"(",
"$",
"target",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"exec",
"(",
"$",
"this",
"->",
"getCommand",
"(",
"$",
"target",
")",
")",
";",
"return",
"$",
"this",
"->",
"output",
"[",
"$",
"target",
"]",
"=",
"$",
"this",
"->",
"cleanOutput",
"(",
"$",
"target",
",",
"$",
"return",
"[",
"'output'",
"]",
")",
";",
"}"
] |
Run the command with the given target
@param string $target
|
[
"Run",
"the",
"command",
"with",
"the",
"given",
"target"
] |
71c73feadb01ba4c36d9df5ac947c07a7120c732
|
https://github.com/kpacha/php-benchmark-tool/blob/71c73feadb01ba4c36d9df5ac947c07a7120c732/src/Kpacha/BenchmarkTool/Benchmarker/Base.php#L45-L49
|
237,684
|
drmvc/helpers
|
src/Helpers/UUID.php
|
UUID.v5
|
public static function v5(string $namespace, string $name)
{
if (!Validate::isValidUUID($namespace)) {
return false;
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
// Binary Value
$nstr = '';
// Convert Namespace UUID to bits
for ($i = 0; $i < strlen($nhex); $i += 2) {
$nstr .= \chr(hexdec($nhex[$i] . $nhex[$i + 1]));
}
// Calculate hash value
$hash = sha1($nstr . $name);
return sprintf('%08s-%04s-%04x-%04x-%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 5
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12)
);
}
|
php
|
public static function v5(string $namespace, string $name)
{
if (!Validate::isValidUUID($namespace)) {
return false;
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-', '{', '}'), '', $namespace);
// Binary Value
$nstr = '';
// Convert Namespace UUID to bits
for ($i = 0; $i < strlen($nhex); $i += 2) {
$nstr .= \chr(hexdec($nhex[$i] . $nhex[$i + 1]));
}
// Calculate hash value
$hash = sha1($nstr . $name);
return sprintf('%08s-%04s-%04x-%04x-%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 5
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12)
);
}
|
[
"public",
"static",
"function",
"v5",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"Validate",
"::",
"isValidUUID",
"(",
"$",
"namespace",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Get hexadecimal components of namespace",
"$",
"nhex",
"=",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"'{'",
",",
"'}'",
")",
",",
"''",
",",
"$",
"namespace",
")",
";",
"// Binary Value",
"$",
"nstr",
"=",
"''",
";",
"// Convert Namespace UUID to bits",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"nhex",
")",
";",
"$",
"i",
"+=",
"2",
")",
"{",
"$",
"nstr",
".=",
"\\",
"chr",
"(",
"hexdec",
"(",
"$",
"nhex",
"[",
"$",
"i",
"]",
".",
"$",
"nhex",
"[",
"$",
"i",
"+",
"1",
"]",
")",
")",
";",
"}",
"// Calculate hash value",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"nstr",
".",
"$",
"name",
")",
";",
"return",
"sprintf",
"(",
"'%08s-%04s-%04x-%04x-%12s'",
",",
"// 32 bits for \"time_low\"",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"8",
")",
",",
"// 16 bits for \"time_mid\"",
"substr",
"(",
"$",
"hash",
",",
"8",
",",
"4",
")",
",",
"// 16 bits for \"time_hi_and_version\",",
"// four most significant bits holds version number 5",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hash",
",",
"12",
",",
"4",
")",
")",
"&",
"0x0fff",
")",
"|",
"0x5000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\",",
"// 8 bits for \"clk_seq_low\",",
"// two most significant bits holds zero and one for variant DCE1.1",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hash",
",",
"16",
",",
"4",
")",
")",
"&",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"substr",
"(",
"$",
"hash",
",",
"20",
",",
"12",
")",
")",
";",
"}"
] |
Generate identifier of 5th version
@param string $namespace
@param string $name
@return bool|string
|
[
"Generate",
"identifier",
"of",
"5th",
"version"
] |
1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b
|
https://github.com/drmvc/helpers/blob/1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b/src/Helpers/UUID.php#L96-L136
|
237,685
|
jeromeklam/freefw
|
src/FreeFW/Model/Field.php
|
Field.getFldTypeForPhp
|
public function getFldTypeForPhp()
{
$type = 'mixed';
switch ($this->getFldType()) {
case FFCST::TYPE_INTEGER:
case FFCST::TYPE_BIGINT:
$type = 'int';
break;
case FFCST::TYPE_DATETIME:
case FFCST::TYPE_MD5:
case FFCST::TYPE_STRING:
$type = 'string';
break;
case FFCST::TYPE_BOOLEAN:
$type = 'bool';
break;
}
return $type;
}
|
php
|
public function getFldTypeForPhp()
{
$type = 'mixed';
switch ($this->getFldType()) {
case FFCST::TYPE_INTEGER:
case FFCST::TYPE_BIGINT:
$type = 'int';
break;
case FFCST::TYPE_DATETIME:
case FFCST::TYPE_MD5:
case FFCST::TYPE_STRING:
$type = 'string';
break;
case FFCST::TYPE_BOOLEAN:
$type = 'bool';
break;
}
return $type;
}
|
[
"public",
"function",
"getFldTypeForPhp",
"(",
")",
"{",
"$",
"type",
"=",
"'mixed'",
";",
"switch",
"(",
"$",
"this",
"->",
"getFldType",
"(",
")",
")",
"{",
"case",
"FFCST",
"::",
"TYPE_INTEGER",
":",
"case",
"FFCST",
"::",
"TYPE_BIGINT",
":",
"$",
"type",
"=",
"'int'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_DATETIME",
":",
"case",
"FFCST",
"::",
"TYPE_MD5",
":",
"case",
"FFCST",
"::",
"TYPE_STRING",
":",
"$",
"type",
"=",
"'string'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_BOOLEAN",
":",
"$",
"type",
"=",
"'bool'",
";",
"break",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Convert local type to php
@return string
|
[
"Convert",
"local",
"type",
"to",
"php"
] |
16ecf24192375c920a070296f396b9d3fd994a1e
|
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Model/Field.php#L236-L254
|
237,686
|
jeromeklam/freefw
|
src/FreeFW/Model/Field.php
|
Field.getFldTypeForClass
|
public function getFldTypeForClass()
{
$type = 'TYPE_STRING';
switch ($this->getFldType()) {
case FFCST::TYPE_INTEGER:
$type = 'TYPE_INTEGER';
break;
case FFCST::TYPE_BIGINT:
$type = 'TYPE_BIGINT';
break;
case FFCST::TYPE_DATETIME:
$type = 'TYPE_DATETIME';
break;
case FFCST::TYPE_MD5:
$type = 'TYPE_MD5';
break;
case FFCST::TYPE_STRING:
$type = 'TYPE_STRING';
break;
case FFCST::TYPE_BOOLEAN:
$type = 'TYPE_BOOLEAN';
break;
case FFCST::TYPE_BLOB:
$type = 'TYPE_BLOB';
break;
}
return $type;
}
|
php
|
public function getFldTypeForClass()
{
$type = 'TYPE_STRING';
switch ($this->getFldType()) {
case FFCST::TYPE_INTEGER:
$type = 'TYPE_INTEGER';
break;
case FFCST::TYPE_BIGINT:
$type = 'TYPE_BIGINT';
break;
case FFCST::TYPE_DATETIME:
$type = 'TYPE_DATETIME';
break;
case FFCST::TYPE_MD5:
$type = 'TYPE_MD5';
break;
case FFCST::TYPE_STRING:
$type = 'TYPE_STRING';
break;
case FFCST::TYPE_BOOLEAN:
$type = 'TYPE_BOOLEAN';
break;
case FFCST::TYPE_BLOB:
$type = 'TYPE_BLOB';
break;
}
return $type;
}
|
[
"public",
"function",
"getFldTypeForClass",
"(",
")",
"{",
"$",
"type",
"=",
"'TYPE_STRING'",
";",
"switch",
"(",
"$",
"this",
"->",
"getFldType",
"(",
")",
")",
"{",
"case",
"FFCST",
"::",
"TYPE_INTEGER",
":",
"$",
"type",
"=",
"'TYPE_INTEGER'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_BIGINT",
":",
"$",
"type",
"=",
"'TYPE_BIGINT'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_DATETIME",
":",
"$",
"type",
"=",
"'TYPE_DATETIME'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_MD5",
":",
"$",
"type",
"=",
"'TYPE_MD5'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_STRING",
":",
"$",
"type",
"=",
"'TYPE_STRING'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_BOOLEAN",
":",
"$",
"type",
"=",
"'TYPE_BOOLEAN'",
";",
"break",
";",
"case",
"FFCST",
"::",
"TYPE_BLOB",
":",
"$",
"type",
"=",
"'TYPE_BLOB'",
";",
"break",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Convert local type to class
@return string
|
[
"Convert",
"local",
"type",
"to",
"class"
] |
16ecf24192375c920a070296f396b9d3fd994a1e
|
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Model/Field.php#L261-L288
|
237,687
|
jeromeklam/freefw
|
src/FreeFW/Model/Field.php
|
Field.getFromPDO
|
public static function getFromPDO(array $p_pdo_description)
{
$me = self::getNew();
if (is_array($p_pdo_description)) {
if (array_key_exists('name', $p_pdo_description)) {
$me->setFldName($p_pdo_description['name']);
}
if (array_key_exists('len', $p_pdo_description)) {
$me->setFldLength($p_pdo_description['len']);
}
if (array_key_exists('precision', $p_pdo_description)) {
$me->setFldComplement($p_pdo_description['precision']);
}
$me->setFldType(FFCST::TYPE_STRING);
if (array_key_exists('native_type', $p_pdo_description)) {
switch (strtoupper($p_pdo_description['native_type'])) {
case 'LONGLONG':
$me->setFldType(FFCST::TYPE_BIGINT);
break;
case 'TINY':
$me->setFldType(FFCST::TYPE_INTEGER);
break;
case 'BLOB':
$me->setFldType(FFCST::TYPE_BLOB);
break;
case 'TIMESTAMP':
$me->setFldType(FFCST::TYPE_DATETIME);
break;
}
}
if (array_key_exists('flags', $p_pdo_description)) {
if (is_array($p_pdo_description['flags'])) {
foreach ($p_pdo_description['flags'] as $idx => $flag) {
if ($flag == 'primary_key') {
$me->setFldPrimary(true);
}
if ($flag == 'not_null') {
$me->setFldRequired(true);
}
}
}
}
}
return $me;
}
|
php
|
public static function getFromPDO(array $p_pdo_description)
{
$me = self::getNew();
if (is_array($p_pdo_description)) {
if (array_key_exists('name', $p_pdo_description)) {
$me->setFldName($p_pdo_description['name']);
}
if (array_key_exists('len', $p_pdo_description)) {
$me->setFldLength($p_pdo_description['len']);
}
if (array_key_exists('precision', $p_pdo_description)) {
$me->setFldComplement($p_pdo_description['precision']);
}
$me->setFldType(FFCST::TYPE_STRING);
if (array_key_exists('native_type', $p_pdo_description)) {
switch (strtoupper($p_pdo_description['native_type'])) {
case 'LONGLONG':
$me->setFldType(FFCST::TYPE_BIGINT);
break;
case 'TINY':
$me->setFldType(FFCST::TYPE_INTEGER);
break;
case 'BLOB':
$me->setFldType(FFCST::TYPE_BLOB);
break;
case 'TIMESTAMP':
$me->setFldType(FFCST::TYPE_DATETIME);
break;
}
}
if (array_key_exists('flags', $p_pdo_description)) {
if (is_array($p_pdo_description['flags'])) {
foreach ($p_pdo_description['flags'] as $idx => $flag) {
if ($flag == 'primary_key') {
$me->setFldPrimary(true);
}
if ($flag == 'not_null') {
$me->setFldRequired(true);
}
}
}
}
}
return $me;
}
|
[
"public",
"static",
"function",
"getFromPDO",
"(",
"array",
"$",
"p_pdo_description",
")",
"{",
"$",
"me",
"=",
"self",
"::",
"getNew",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"p_pdo_description",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'name'",
",",
"$",
"p_pdo_description",
")",
")",
"{",
"$",
"me",
"->",
"setFldName",
"(",
"$",
"p_pdo_description",
"[",
"'name'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'len'",
",",
"$",
"p_pdo_description",
")",
")",
"{",
"$",
"me",
"->",
"setFldLength",
"(",
"$",
"p_pdo_description",
"[",
"'len'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'precision'",
",",
"$",
"p_pdo_description",
")",
")",
"{",
"$",
"me",
"->",
"setFldComplement",
"(",
"$",
"p_pdo_description",
"[",
"'precision'",
"]",
")",
";",
"}",
"$",
"me",
"->",
"setFldType",
"(",
"FFCST",
"::",
"TYPE_STRING",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'native_type'",
",",
"$",
"p_pdo_description",
")",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"$",
"p_pdo_description",
"[",
"'native_type'",
"]",
")",
")",
"{",
"case",
"'LONGLONG'",
":",
"$",
"me",
"->",
"setFldType",
"(",
"FFCST",
"::",
"TYPE_BIGINT",
")",
";",
"break",
";",
"case",
"'TINY'",
":",
"$",
"me",
"->",
"setFldType",
"(",
"FFCST",
"::",
"TYPE_INTEGER",
")",
";",
"break",
";",
"case",
"'BLOB'",
":",
"$",
"me",
"->",
"setFldType",
"(",
"FFCST",
"::",
"TYPE_BLOB",
")",
";",
"break",
";",
"case",
"'TIMESTAMP'",
":",
"$",
"me",
"->",
"setFldType",
"(",
"FFCST",
"::",
"TYPE_DATETIME",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"array_key_exists",
"(",
"'flags'",
",",
"$",
"p_pdo_description",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"p_pdo_description",
"[",
"'flags'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"p_pdo_description",
"[",
"'flags'",
"]",
"as",
"$",
"idx",
"=>",
"$",
"flag",
")",
"{",
"if",
"(",
"$",
"flag",
"==",
"'primary_key'",
")",
"{",
"$",
"me",
"->",
"setFldPrimary",
"(",
"true",
")",
";",
"}",
"if",
"(",
"$",
"flag",
"==",
"'not_null'",
")",
"{",
"$",
"me",
"->",
"setFldRequired",
"(",
"true",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"me",
";",
"}"
] |
Get new from pdo metadatas
@param array $p_pdo_description
@return \FreeFW\Model\Field
|
[
"Get",
"new",
"from",
"pdo",
"metadatas"
] |
16ecf24192375c920a070296f396b9d3fd994a1e
|
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Model/Field.php#L314-L358
|
237,688
|
raidros/storer
|
src/Response.php
|
Response.getBody
|
public function getBody()
{
$body = json_decode($this->response->getBody(), true);
if (!$body) {
throw new ResponseWithoutBody('Response without body');
}
if (!$this->transformer) {
return $body;
}
return $this->transformer->transformData($body);
}
|
php
|
public function getBody()
{
$body = json_decode($this->response->getBody(), true);
if (!$body) {
throw new ResponseWithoutBody('Response without body');
}
if (!$this->transformer) {
return $body;
}
return $this->transformer->transformData($body);
}
|
[
"public",
"function",
"getBody",
"(",
")",
"{",
"$",
"body",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"body",
")",
"{",
"throw",
"new",
"ResponseWithoutBody",
"(",
"'Response without body'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"transformer",
")",
"{",
"return",
"$",
"body",
";",
"}",
"return",
"$",
"this",
"->",
"transformer",
"->",
"transformData",
"(",
"$",
"body",
")",
";",
"}"
] |
Return a transformed response.
@return array
|
[
"Return",
"a",
"transformed",
"response",
"."
] |
e8ebea105b27888a9c42cbc5266e02e9e51324ee
|
https://github.com/raidros/storer/blob/e8ebea105b27888a9c42cbc5266e02e9e51324ee/src/Response.php#L40-L53
|
237,689
|
alcalyn/awale
|
src/Awale.php
|
Awale.move
|
public function move($player, $move)
{
$this->checkPlayer($player);
$this->checkMove($move);
// Take seeds in hand
$hand = $this->grid[$player]['seeds'][$move];
$this->grid[$player]['seeds'][$move] = 0;
$row = $player;
$box = $move;
/**
* Dispatch seeds
*/
while ($hand > 0) {
if (0 === $row) {
if (0 === $box) {
$row = 1;
} else {
$box--;
}
} else {
if (5 === $box) {
$row = 0;
} else {
$box++;
}
}
// Feed box
if (($row !== $player) || ($box !== $move)) {
$hand--;
$this->grid[$row]['seeds'][$box]++;
}
}
/**
* Anti starve check
*/
if ((0 === $row && 0 === $box) || (1 === $row && 5 === $box)) {
if (($row !== $player) && self::allSeedsVulnerable($this->grid[$row]['seeds'])) {
return $this;
}
}
/**
* Store opponent seeds
*/
while (($row !== $player) && in_array($this->grid[$row]['seeds'][$box], array(2, 3))) {
// Store his seeds
$this->grid[$player]['attic'] += $this->grid[$row]['seeds'][$box];
$this->grid[$row]['seeds'][$box] = 0;
// Check previous box
if (0 === $row) {
if (5 === $box) {
$row = 1;
} else {
$box++;
}
} else {
if (0 === $box) {
$row = 0;
} else {
$box--;
}
}
}
return $this;
}
|
php
|
public function move($player, $move)
{
$this->checkPlayer($player);
$this->checkMove($move);
// Take seeds in hand
$hand = $this->grid[$player]['seeds'][$move];
$this->grid[$player]['seeds'][$move] = 0;
$row = $player;
$box = $move;
/**
* Dispatch seeds
*/
while ($hand > 0) {
if (0 === $row) {
if (0 === $box) {
$row = 1;
} else {
$box--;
}
} else {
if (5 === $box) {
$row = 0;
} else {
$box++;
}
}
// Feed box
if (($row !== $player) || ($box !== $move)) {
$hand--;
$this->grid[$row]['seeds'][$box]++;
}
}
/**
* Anti starve check
*/
if ((0 === $row && 0 === $box) || (1 === $row && 5 === $box)) {
if (($row !== $player) && self::allSeedsVulnerable($this->grid[$row]['seeds'])) {
return $this;
}
}
/**
* Store opponent seeds
*/
while (($row !== $player) && in_array($this->grid[$row]['seeds'][$box], array(2, 3))) {
// Store his seeds
$this->grid[$player]['attic'] += $this->grid[$row]['seeds'][$box];
$this->grid[$row]['seeds'][$box] = 0;
// Check previous box
if (0 === $row) {
if (5 === $box) {
$row = 1;
} else {
$box++;
}
} else {
if (0 === $box) {
$row = 0;
} else {
$box--;
}
}
}
return $this;
}
|
[
"public",
"function",
"move",
"(",
"$",
"player",
",",
"$",
"move",
")",
"{",
"$",
"this",
"->",
"checkPlayer",
"(",
"$",
"player",
")",
";",
"$",
"this",
"->",
"checkMove",
"(",
"$",
"move",
")",
";",
"// Take seeds in hand",
"$",
"hand",
"=",
"$",
"this",
"->",
"grid",
"[",
"$",
"player",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"move",
"]",
";",
"$",
"this",
"->",
"grid",
"[",
"$",
"player",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"move",
"]",
"=",
"0",
";",
"$",
"row",
"=",
"$",
"player",
";",
"$",
"box",
"=",
"$",
"move",
";",
"/**\n * Dispatch seeds\n */",
"while",
"(",
"$",
"hand",
">",
"0",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"row",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"box",
")",
"{",
"$",
"row",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"box",
"--",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"5",
"===",
"$",
"box",
")",
"{",
"$",
"row",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"box",
"++",
";",
"}",
"}",
"// Feed box",
"if",
"(",
"(",
"$",
"row",
"!==",
"$",
"player",
")",
"||",
"(",
"$",
"box",
"!==",
"$",
"move",
")",
")",
"{",
"$",
"hand",
"--",
";",
"$",
"this",
"->",
"grid",
"[",
"$",
"row",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"box",
"]",
"++",
";",
"}",
"}",
"/**\n * Anti starve check\n */",
"if",
"(",
"(",
"0",
"===",
"$",
"row",
"&&",
"0",
"===",
"$",
"box",
")",
"||",
"(",
"1",
"===",
"$",
"row",
"&&",
"5",
"===",
"$",
"box",
")",
")",
"{",
"if",
"(",
"(",
"$",
"row",
"!==",
"$",
"player",
")",
"&&",
"self",
"::",
"allSeedsVulnerable",
"(",
"$",
"this",
"->",
"grid",
"[",
"$",
"row",
"]",
"[",
"'seeds'",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"/**\n * Store opponent seeds\n */",
"while",
"(",
"(",
"$",
"row",
"!==",
"$",
"player",
")",
"&&",
"in_array",
"(",
"$",
"this",
"->",
"grid",
"[",
"$",
"row",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"box",
"]",
",",
"array",
"(",
"2",
",",
"3",
")",
")",
")",
"{",
"// Store his seeds",
"$",
"this",
"->",
"grid",
"[",
"$",
"player",
"]",
"[",
"'attic'",
"]",
"+=",
"$",
"this",
"->",
"grid",
"[",
"$",
"row",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"box",
"]",
";",
"$",
"this",
"->",
"grid",
"[",
"$",
"row",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"box",
"]",
"=",
"0",
";",
"// Check previous box",
"if",
"(",
"0",
"===",
"$",
"row",
")",
"{",
"if",
"(",
"5",
"===",
"$",
"box",
")",
"{",
"$",
"row",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"box",
"++",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"0",
"===",
"$",
"box",
")",
"{",
"$",
"row",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"box",
"--",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Play a move naively.
Do not check player turn.
@param int $player
@param int $move
@return self
@throws AwaleException on invalid input value.
|
[
"Play",
"a",
"move",
"naively",
".",
"Do",
"not",
"check",
"player",
"turn",
"."
] |
d148a8fe10735e73f31fc19f31f40b84972a0079
|
https://github.com/alcalyn/awale/blob/d148a8fe10735e73f31fc19f31f40b84972a0079/src/Awale.php#L192-L263
|
237,690
|
alcalyn/awale
|
src/Awale.php
|
Awale.play
|
public function play($player, $move)
{
if (!$this->isPlayerTurn($player)) {
throw new AwaleException('Not your turn.');
}
if (0 === $this->grid[$player]['seeds'][$move]) {
throw new AwaleException('This container is empty.');
}
$this->checkMustFeedOpponentRule($player, $move);
$this
->move($player, $move)
->setLastMove(array(
'player' => $player,
'move' => $move,
))
->changePlayerTurn()
;
if (!$this->hasSeeds(1 - $this->currentPlayer) && !$this->canFeedOpponent($this->currentPlayer)) {
$this->storeRemainingSeeds($this->currentPlayer);
}
return $this;
}
|
php
|
public function play($player, $move)
{
if (!$this->isPlayerTurn($player)) {
throw new AwaleException('Not your turn.');
}
if (0 === $this->grid[$player]['seeds'][$move]) {
throw new AwaleException('This container is empty.');
}
$this->checkMustFeedOpponentRule($player, $move);
$this
->move($player, $move)
->setLastMove(array(
'player' => $player,
'move' => $move,
))
->changePlayerTurn()
;
if (!$this->hasSeeds(1 - $this->currentPlayer) && !$this->canFeedOpponent($this->currentPlayer)) {
$this->storeRemainingSeeds($this->currentPlayer);
}
return $this;
}
|
[
"public",
"function",
"play",
"(",
"$",
"player",
",",
"$",
"move",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPlayerTurn",
"(",
"$",
"player",
")",
")",
"{",
"throw",
"new",
"AwaleException",
"(",
"'Not your turn.'",
")",
";",
"}",
"if",
"(",
"0",
"===",
"$",
"this",
"->",
"grid",
"[",
"$",
"player",
"]",
"[",
"'seeds'",
"]",
"[",
"$",
"move",
"]",
")",
"{",
"throw",
"new",
"AwaleException",
"(",
"'This container is empty.'",
")",
";",
"}",
"$",
"this",
"->",
"checkMustFeedOpponentRule",
"(",
"$",
"player",
",",
"$",
"move",
")",
";",
"$",
"this",
"->",
"move",
"(",
"$",
"player",
",",
"$",
"move",
")",
"->",
"setLastMove",
"(",
"array",
"(",
"'player'",
"=>",
"$",
"player",
",",
"'move'",
"=>",
"$",
"move",
",",
")",
")",
"->",
"changePlayerTurn",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSeeds",
"(",
"1",
"-",
"$",
"this",
"->",
"currentPlayer",
")",
"&&",
"!",
"$",
"this",
"->",
"canFeedOpponent",
"(",
"$",
"this",
"->",
"currentPlayer",
")",
")",
"{",
"$",
"this",
"->",
"storeRemainingSeeds",
"(",
"$",
"this",
"->",
"currentPlayer",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Play a turn, check current player turn.
@param int $player
@param int $move
@return self
@throws AwaleException on invalid move.
|
[
"Play",
"a",
"turn",
"check",
"current",
"player",
"turn",
"."
] |
d148a8fe10735e73f31fc19f31f40b84972a0079
|
https://github.com/alcalyn/awale/blob/d148a8fe10735e73f31fc19f31f40b84972a0079/src/Awale.php#L292-L318
|
237,691
|
alcalyn/awale
|
src/Awale.php
|
Awale.getPlayerWithMoreThanHalfSeeds
|
private function getPlayerWithMoreThanHalfSeeds()
{
$seedsToWin = $this->getSeedsNeededToWin();
if ($this->grid[Awale::PLAYER_0]['attic'] > $seedsToWin) {
return self::PLAYER_0;
}
if ($this->grid[Awale::PLAYER_1]['attic'] > $seedsToWin) {
return self::PLAYER_1;
}
return null;
}
|
php
|
private function getPlayerWithMoreThanHalfSeeds()
{
$seedsToWin = $this->getSeedsNeededToWin();
if ($this->grid[Awale::PLAYER_0]['attic'] > $seedsToWin) {
return self::PLAYER_0;
}
if ($this->grid[Awale::PLAYER_1]['attic'] > $seedsToWin) {
return self::PLAYER_1;
}
return null;
}
|
[
"private",
"function",
"getPlayerWithMoreThanHalfSeeds",
"(",
")",
"{",
"$",
"seedsToWin",
"=",
"$",
"this",
"->",
"getSeedsNeededToWin",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"grid",
"[",
"Awale",
"::",
"PLAYER_0",
"]",
"[",
"'attic'",
"]",
">",
"$",
"seedsToWin",
")",
"{",
"return",
"self",
"::",
"PLAYER_0",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"grid",
"[",
"Awale",
"::",
"PLAYER_1",
"]",
"[",
"'attic'",
"]",
">",
"$",
"seedsToWin",
")",
"{",
"return",
"self",
"::",
"PLAYER_1",
";",
"}",
"return",
"null",
";",
"}"
] |
Check if a player reached the seeds number to win and returns it.
Or return null.
@return int|null
|
[
"Check",
"if",
"a",
"player",
"reached",
"the",
"seeds",
"number",
"to",
"win",
"and",
"returns",
"it",
".",
"Or",
"return",
"null",
"."
] |
d148a8fe10735e73f31fc19f31f40b84972a0079
|
https://github.com/alcalyn/awale/blob/d148a8fe10735e73f31fc19f31f40b84972a0079/src/Awale.php#L437-L450
|
237,692
|
alcalyn/awale
|
src/Awale.php
|
Awale.getWinner
|
public function getWinner()
{
if (!$this->isGameOver()) {
return null;
}
if ($this->getScore(self::PLAYER_0) === $this->getScore(self::PLAYER_1)) {
return self::DRAW;
} elseif ($this->getScore(self::PLAYER_0) > $this->getScore(self::PLAYER_1)) {
return self::PLAYER_0;
} else {
return self::PLAYER_1;
}
}
|
php
|
public function getWinner()
{
if (!$this->isGameOver()) {
return null;
}
if ($this->getScore(self::PLAYER_0) === $this->getScore(self::PLAYER_1)) {
return self::DRAW;
} elseif ($this->getScore(self::PLAYER_0) > $this->getScore(self::PLAYER_1)) {
return self::PLAYER_0;
} else {
return self::PLAYER_1;
}
}
|
[
"public",
"function",
"getWinner",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGameOver",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getScore",
"(",
"self",
"::",
"PLAYER_0",
")",
"===",
"$",
"this",
"->",
"getScore",
"(",
"self",
"::",
"PLAYER_1",
")",
")",
"{",
"return",
"self",
"::",
"DRAW",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getScore",
"(",
"self",
"::",
"PLAYER_0",
")",
">",
"$",
"this",
"->",
"getScore",
"(",
"self",
"::",
"PLAYER_1",
")",
")",
"{",
"return",
"self",
"::",
"PLAYER_0",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"PLAYER_1",
";",
"}",
"}"
] |
Returns the winner, or null if game not over.
@return int|null null for party not ended, or one of them: self::PLAYER_0, self::PLAYER_1, self::DRAW.
|
[
"Returns",
"the",
"winner",
"or",
"null",
"if",
"game",
"not",
"over",
"."
] |
d148a8fe10735e73f31fc19f31f40b84972a0079
|
https://github.com/alcalyn/awale/blob/d148a8fe10735e73f31fc19f31f40b84972a0079/src/Awale.php#L457-L470
|
237,693
|
ExSituMarketing/EXS-ErrorBundle
|
Services/Loggers/ExceptionLogger.php
|
ExceptionLogger.getTrace
|
public function getTrace($trace = array())
{
$traceMessage = '';
foreach ($trace as $t) {
$traceMessage .= sprintf(' at %s line %s', $t['file'], $t['line']) . "\n";
}
return $traceMessage;
}
|
php
|
public function getTrace($trace = array())
{
$traceMessage = '';
foreach ($trace as $t) {
$traceMessage .= sprintf(' at %s line %s', $t['file'], $t['line']) . "\n";
}
return $traceMessage;
}
|
[
"public",
"function",
"getTrace",
"(",
"$",
"trace",
"=",
"array",
"(",
")",
")",
"{",
"$",
"traceMessage",
"=",
"''",
";",
"foreach",
"(",
"$",
"trace",
"as",
"$",
"t",
")",
"{",
"$",
"traceMessage",
".=",
"sprintf",
"(",
"' at %s line %s'",
",",
"$",
"t",
"[",
"'file'",
"]",
",",
"$",
"t",
"[",
"'line'",
"]",
")",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"traceMessage",
";",
"}"
] |
Implodes the trace into a readable string representation
@param array $trace
@return string
|
[
"Implodes",
"the",
"trace",
"into",
"a",
"readable",
"string",
"representation"
] |
33e8bf302c00af2e20a6e9ed8ae8b4817aa252ba
|
https://github.com/ExSituMarketing/EXS-ErrorBundle/blob/33e8bf302c00af2e20a6e9ed8ae8b4817aa252ba/Services/Loggers/ExceptionLogger.php#L42-L50
|
237,694
|
ExSituMarketing/EXS-ErrorBundle
|
Services/Loggers/ExceptionLogger.php
|
ExceptionLogger.getStatusCode
|
public function getStatusCode(FlattenException $exception)
{
$str = '';
if (method_exists($exception, 'getStatusCode') == true) {
$str = $exception->getStatusCode();
} elseif (method_exists($exception, 'getCode') == true) {
$str = $exception->getCode();
}
return $str;
}
|
php
|
public function getStatusCode(FlattenException $exception)
{
$str = '';
if (method_exists($exception, 'getStatusCode') == true) {
$str = $exception->getStatusCode();
} elseif (method_exists($exception, 'getCode') == true) {
$str = $exception->getCode();
}
return $str;
}
|
[
"public",
"function",
"getStatusCode",
"(",
"FlattenException",
"$",
"exception",
")",
"{",
"$",
"str",
"=",
"''",
";",
"if",
"(",
"method_exists",
"(",
"$",
"exception",
",",
"'getStatusCode'",
")",
"==",
"true",
")",
"{",
"$",
"str",
"=",
"$",
"exception",
"->",
"getStatusCode",
"(",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"exception",
",",
"'getCode'",
")",
"==",
"true",
")",
"{",
"$",
"str",
"=",
"$",
"exception",
"->",
"getCode",
"(",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Attempts to extract a nice exception code string
@param FlattenException $exception
@return string
|
[
"Attempts",
"to",
"extract",
"a",
"nice",
"exception",
"code",
"string"
] |
33e8bf302c00af2e20a6e9ed8ae8b4817aa252ba
|
https://github.com/ExSituMarketing/EXS-ErrorBundle/blob/33e8bf302c00af2e20a6e9ed8ae8b4817aa252ba/Services/Loggers/ExceptionLogger.php#L58-L68
|
237,695
|
timostamm/injector
|
src/Injector/ArgumentList.php
|
ArgumentList.addConfig
|
public function addConfig(ParametersConfig $config):void
{
array_unshift($this->configs, $config);
foreach ($this->info->getNames() as $name) {
if ($config->hasValue($name)) {
$this->missingValues[$name] = false;
}
}
}
|
php
|
public function addConfig(ParametersConfig $config):void
{
array_unshift($this->configs, $config);
foreach ($this->info->getNames() as $name) {
if ($config->hasValue($name)) {
$this->missingValues[$name] = false;
}
}
}
|
[
"public",
"function",
"addConfig",
"(",
"ParametersConfig",
"$",
"config",
")",
":",
"void",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"configs",
",",
"$",
"config",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"info",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"hasValue",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"missingValues",
"[",
"$",
"name",
"]",
"=",
"false",
";",
"}",
"}",
"}"
] |
Add a parameter configuration that may provide values
and type hints.
|
[
"Add",
"a",
"parameter",
"configuration",
"that",
"may",
"provide",
"values",
"and",
"type",
"hints",
"."
] |
5f5c0a0993bde368ad6703936ac578d6ab022fa7
|
https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector/ArgumentList.php#L48-L56
|
237,696
|
timostamm/injector
|
src/Injector/ArgumentList.php
|
ArgumentList.getType
|
public function getType(string $name):?string
{
if (! $this->info->includes($name)) {
throw ArgumentListException::parameterNotFound($name);
}
foreach ($this->configs as $config) {
/** @var $config ParametersConfig */
if ($config->hasType($name)) {
return $config->getType($name);
}
}
return $this->info->getType($name);
}
|
php
|
public function getType(string $name):?string
{
if (! $this->info->includes($name)) {
throw ArgumentListException::parameterNotFound($name);
}
foreach ($this->configs as $config) {
/** @var $config ParametersConfig */
if ($config->hasType($name)) {
return $config->getType($name);
}
}
return $this->info->getType($name);
}
|
[
"public",
"function",
"getType",
"(",
"string",
"$",
"name",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"info",
"->",
"includes",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"ArgumentListException",
"::",
"parameterNotFound",
"(",
"$",
"name",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"configs",
"as",
"$",
"config",
")",
"{",
"/** @var $config ParametersConfig */",
"if",
"(",
"$",
"config",
"->",
"hasType",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"config",
"->",
"getType",
"(",
"$",
"name",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"info",
"->",
"getType",
"(",
"$",
"name",
")",
";",
"}"
] |
Get the type of an argument.
May be NULL if untyped, a built-in type or a class name.
|
[
"Get",
"the",
"type",
"of",
"an",
"argument",
"."
] |
5f5c0a0993bde368ad6703936ac578d6ab022fa7
|
https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector/ArgumentList.php#L118-L130
|
237,697
|
timostamm/injector
|
src/Injector/ArgumentList.php
|
ArgumentList.getOptional
|
public function getOptional(int $type = AII::TYPE_BUILTIN | AII::TYPE_UNTYPED | AII::TYPE_CLASS):array
{
$includeUntyped = ($type & AII::TYPE_UNTYPED) === AII::TYPE_UNTYPED;
$includeBuiltin = ($type & AII::TYPE_BUILTIN) === AII::TYPE_BUILTIN;
$includeClass = ($type & AII::TYPE_CLASS) === AII::TYPE_CLASS;
$names = [];
foreach ($this->info->getNames() as $name) {
if ($this->info->isRequired($name) ) {
continue;
}
if ($this->hasExplicitValue($name)) {
continue;
}
$type = $this->getType($name);
if ( ! $includeUntyped && is_null($type) ) {
continue;
}
if ( ! $includeBuiltin && ! is_null($type) && Reflector::isBuiltinType($type) ) {
continue;
}
if ( ! $includeClass && ! is_null($type) && ! Reflector::isBuiltinType($type) ) {
continue;
}
$names[] = $name;
}
return $names;
}
|
php
|
public function getOptional(int $type = AII::TYPE_BUILTIN | AII::TYPE_UNTYPED | AII::TYPE_CLASS):array
{
$includeUntyped = ($type & AII::TYPE_UNTYPED) === AII::TYPE_UNTYPED;
$includeBuiltin = ($type & AII::TYPE_BUILTIN) === AII::TYPE_BUILTIN;
$includeClass = ($type & AII::TYPE_CLASS) === AII::TYPE_CLASS;
$names = [];
foreach ($this->info->getNames() as $name) {
if ($this->info->isRequired($name) ) {
continue;
}
if ($this->hasExplicitValue($name)) {
continue;
}
$type = $this->getType($name);
if ( ! $includeUntyped && is_null($type) ) {
continue;
}
if ( ! $includeBuiltin && ! is_null($type) && Reflector::isBuiltinType($type) ) {
continue;
}
if ( ! $includeClass && ! is_null($type) && ! Reflector::isBuiltinType($type) ) {
continue;
}
$names[] = $name;
}
return $names;
}
|
[
"public",
"function",
"getOptional",
"(",
"int",
"$",
"type",
"=",
"AII",
"::",
"TYPE_BUILTIN",
"|",
"AII",
"::",
"TYPE_UNTYPED",
"|",
"AII",
"::",
"TYPE_CLASS",
")",
":",
"array",
"{",
"$",
"includeUntyped",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_UNTYPED",
")",
"===",
"AII",
"::",
"TYPE_UNTYPED",
";",
"$",
"includeBuiltin",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_BUILTIN",
")",
"===",
"AII",
"::",
"TYPE_BUILTIN",
";",
"$",
"includeClass",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_CLASS",
")",
"===",
"AII",
"::",
"TYPE_CLASS",
";",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"info",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"info",
"->",
"isRequired",
"(",
"$",
"name",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasExplicitValue",
"(",
"$",
"name",
")",
")",
"{",
"continue",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"includeUntyped",
"&&",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"includeBuiltin",
"&&",
"!",
"is_null",
"(",
"$",
"type",
")",
"&&",
"Reflector",
"::",
"isBuiltinType",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"includeClass",
"&&",
"!",
"is_null",
"(",
"$",
"type",
")",
"&&",
"!",
"Reflector",
"::",
"isBuiltinType",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"$",
"names",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"names",
";",
"}"
] |
Get the names of optional arguments that are not yet provided.
|
[
"Get",
"the",
"names",
"of",
"optional",
"arguments",
"that",
"are",
"not",
"yet",
"provided",
"."
] |
5f5c0a0993bde368ad6703936ac578d6ab022fa7
|
https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector/ArgumentList.php#L136-L163
|
237,698
|
timostamm/injector
|
src/Injector/ArgumentList.php
|
ArgumentList.getMissing
|
public function getMissing(int $type = AII::TYPE_BUILTIN | AII::TYPE_UNTYPED | AII::TYPE_CLASS ):array
{
$includeUntyped = ($type & AII::TYPE_UNTYPED) === AII::TYPE_UNTYPED;
$includeBuiltin = ($type & AII::TYPE_BUILTIN) === AII::TYPE_BUILTIN;
$includeClass = ($type & AII::TYPE_CLASS) === AII::TYPE_CLASS;
$names = [];
foreach ($this->info->getNames() as $name) {
if (! $this->missingValues[$name]) {
continue;
}
$type = $this->getType($name);
if ( ! $includeUntyped && is_null($type) ) {
continue;
}
$isBuiltin = Reflector::isBuiltinType($type);
if ( ! $includeBuiltin && $isBuiltin && ! is_null($type) ) {
continue;
}
if ( ! $includeClass && ! $isBuiltin && ! is_null($type) ) {
continue;
}
$names[] = $name;
}
return $names;
}
|
php
|
public function getMissing(int $type = AII::TYPE_BUILTIN | AII::TYPE_UNTYPED | AII::TYPE_CLASS ):array
{
$includeUntyped = ($type & AII::TYPE_UNTYPED) === AII::TYPE_UNTYPED;
$includeBuiltin = ($type & AII::TYPE_BUILTIN) === AII::TYPE_BUILTIN;
$includeClass = ($type & AII::TYPE_CLASS) === AII::TYPE_CLASS;
$names = [];
foreach ($this->info->getNames() as $name) {
if (! $this->missingValues[$name]) {
continue;
}
$type = $this->getType($name);
if ( ! $includeUntyped && is_null($type) ) {
continue;
}
$isBuiltin = Reflector::isBuiltinType($type);
if ( ! $includeBuiltin && $isBuiltin && ! is_null($type) ) {
continue;
}
if ( ! $includeClass && ! $isBuiltin && ! is_null($type) ) {
continue;
}
$names[] = $name;
}
return $names;
}
|
[
"public",
"function",
"getMissing",
"(",
"int",
"$",
"type",
"=",
"AII",
"::",
"TYPE_BUILTIN",
"|",
"AII",
"::",
"TYPE_UNTYPED",
"|",
"AII",
"::",
"TYPE_CLASS",
")",
":",
"array",
"{",
"$",
"includeUntyped",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_UNTYPED",
")",
"===",
"AII",
"::",
"TYPE_UNTYPED",
";",
"$",
"includeBuiltin",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_BUILTIN",
")",
"===",
"AII",
"::",
"TYPE_BUILTIN",
";",
"$",
"includeClass",
"=",
"(",
"$",
"type",
"&",
"AII",
"::",
"TYPE_CLASS",
")",
"===",
"AII",
"::",
"TYPE_CLASS",
";",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"info",
"->",
"getNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"missingValues",
"[",
"$",
"name",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"includeUntyped",
"&&",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"$",
"isBuiltin",
"=",
"Reflector",
"::",
"isBuiltinType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"includeBuiltin",
"&&",
"$",
"isBuiltin",
"&&",
"!",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"includeClass",
"&&",
"!",
"$",
"isBuiltin",
"&&",
"!",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"$",
"names",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"names",
";",
"}"
] |
Get the names of missing arguments.
|
[
"Get",
"the",
"names",
"of",
"missing",
"arguments",
"."
] |
5f5c0a0993bde368ad6703936ac578d6ab022fa7
|
https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector/ArgumentList.php#L169-L194
|
237,699
|
infusephp/twitter
|
src/libs/TwitterService.php
|
TwitterService.setAccessTokenFromProfile
|
public function setAccessTokenFromProfile(TwitterProfile $profile)
{
$tokens = $profile->get(['access_token', 'access_token_secret']);
if (!empty($tokens['access_token'])) {
$this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']);
$this->profile = $profile;
} else {
// use the access token from profile that referenced this profile
$referencingProfile = $profile->relation('most_recently_referenced_by');
// recursion would be nice here, but could be dangerous
$tokens = $referencingProfile->get(['access_token', 'access_token_secret']);
if ($referencingProfile->exists() && !empty($tokens['access_token'])) {
$this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']);
$this->profile = $referencingProfile;
}
}
return $this;
}
|
php
|
public function setAccessTokenFromProfile(TwitterProfile $profile)
{
$tokens = $profile->get(['access_token', 'access_token_secret']);
if (!empty($tokens['access_token'])) {
$this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']);
$this->profile = $profile;
} else {
// use the access token from profile that referenced this profile
$referencingProfile = $profile->relation('most_recently_referenced_by');
// recursion would be nice here, but could be dangerous
$tokens = $referencingProfile->get(['access_token', 'access_token_secret']);
if ($referencingProfile->exists() && !empty($tokens['access_token'])) {
$this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']);
$this->profile = $referencingProfile;
}
}
return $this;
}
|
[
"public",
"function",
"setAccessTokenFromProfile",
"(",
"TwitterProfile",
"$",
"profile",
")",
"{",
"$",
"tokens",
"=",
"$",
"profile",
"->",
"get",
"(",
"[",
"'access_token'",
",",
"'access_token_secret'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tokens",
"[",
"'access_token'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'twitter'",
"]",
"->",
"setTokens",
"(",
"$",
"tokens",
"[",
"'access_token'",
"]",
",",
"$",
"tokens",
"[",
"'access_token_secret'",
"]",
")",
";",
"$",
"this",
"->",
"profile",
"=",
"$",
"profile",
";",
"}",
"else",
"{",
"// use the access token from profile that referenced this profile",
"$",
"referencingProfile",
"=",
"$",
"profile",
"->",
"relation",
"(",
"'most_recently_referenced_by'",
")",
";",
"// recursion would be nice here, but could be dangerous",
"$",
"tokens",
"=",
"$",
"referencingProfile",
"->",
"get",
"(",
"[",
"'access_token'",
",",
"'access_token_secret'",
"]",
")",
";",
"if",
"(",
"$",
"referencingProfile",
"->",
"exists",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"tokens",
"[",
"'access_token'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'twitter'",
"]",
"->",
"setTokens",
"(",
"$",
"tokens",
"[",
"'access_token'",
"]",
",",
"$",
"tokens",
"[",
"'access_token_secret'",
"]",
")",
";",
"$",
"this",
"->",
"profile",
"=",
"$",
"referencingProfile",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the appropriate Twitter API access token using
a given Twitter Profile
@param TwitterProfile $profile
@return TwitterService
|
[
"Sets",
"the",
"appropriate",
"Twitter",
"API",
"access",
"token",
"using",
"a",
"given",
"Twitter",
"Profile"
] |
7d287881ee726640bca904760a2bb0dcb2ba3279
|
https://github.com/infusephp/twitter/blob/7d287881ee726640bca904760a2bb0dcb2ba3279/src/libs/TwitterService.php#L26-L47
|
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.