id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,000 | heyday/heystack-ecommerce-core | src/Locale/LocaleService.php | LocaleService.restoreState | public function restoreState()
{
if ($activeCountry = $this->sessionState->getByKey(self::ACTIVE_COUNTRY_KEY)) {
$this->activeCountry = $activeCountry;
}
} | php | public function restoreState()
{
if ($activeCountry = $this->sessionState->getByKey(self::ACTIVE_COUNTRY_KEY)) {
$this->activeCountry = $activeCountry;
}
} | [
"public",
"function",
"restoreState",
"(",
")",
"{",
"if",
"(",
"$",
"activeCountry",
"=",
"$",
"this",
"->",
"sessionState",
"->",
"getByKey",
"(",
"self",
"::",
"ACTIVE_COUNTRY_KEY",
")",
")",
"{",
"$",
"this",
"->",
"activeCountry",
"=",
"$",
"activeCountry",
";",
"}",
"}"
] | Uses the State service to retrieve the active country's identifier and sets the active country.
If the retrieved identifier is not an instance of the Identifier Interface, then it checks if it is a string,
which it uses to create a new Identifier object to set the active country.
@return void | [
"Uses",
"the",
"State",
"service",
"to",
"retrieve",
"the",
"active",
"country",
"s",
"identifier",
"and",
"sets",
"the",
"active",
"country",
"."
] | b56c83839cd3396da6bc881d843fcb4f28b74685 | https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Locale/LocaleService.php#L90-L95 |
9,001 | heyday/heystack-ecommerce-core | src/Locale/LocaleService.php | LocaleService.getCountry | public function getCountry(IdentifierInterface $identifier)
{
$identifierFull = $identifier->getFull();
return isset($this->countries[$identifierFull]) ? $this->countries[$identifierFull] : null;
} | php | public function getCountry(IdentifierInterface $identifier)
{
$identifierFull = $identifier->getFull();
return isset($this->countries[$identifierFull]) ? $this->countries[$identifierFull] : null;
} | [
"public",
"function",
"getCountry",
"(",
"IdentifierInterface",
"$",
"identifier",
")",
"{",
"$",
"identifierFull",
"=",
"$",
"identifier",
"->",
"getFull",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"countries",
"[",
"$",
"identifierFull",
"]",
")",
"?",
"$",
"this",
"->",
"countries",
"[",
"$",
"identifierFull",
"]",
":",
"null",
";",
"}"
] | Uses the identifier to retrieve the country object from the cache
@param \Heystack\Core\Identifier\IdentifierInterface $identifier
@return \Heystack\Ecommerce\Locale\Interfaces\CountryInterface|null | [
"Uses",
"the",
"identifier",
"to",
"retrieve",
"the",
"country",
"object",
"from",
"the",
"cache"
] | b56c83839cd3396da6bc881d843fcb4f28b74685 | https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Locale/LocaleService.php#L138-L142 |
9,002 | phossa2/libs | src/Phossa2/Db/Driver/Pdo/Driver.php | Driver.checkAttribute | protected function checkAttribute(/*# string */ $attribute)
{
if (!defined($attribute)) {
throw new LogicException(
Message::get(Message::DB_ATTRIBUTE_UNKNOWN, $attribute),
Message::DB_ATTRIBUTE_UNKNOWN
);
}
} | php | protected function checkAttribute(/*# string */ $attribute)
{
if (!defined($attribute)) {
throw new LogicException(
Message::get(Message::DB_ATTRIBUTE_UNKNOWN, $attribute),
Message::DB_ATTRIBUTE_UNKNOWN
);
}
} | [
"protected",
"function",
"checkAttribute",
"(",
"/*# string */",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"$",
"attribute",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"DB_ATTRIBUTE_UNKNOWN",
",",
"$",
"attribute",
")",
",",
"Message",
"::",
"DB_ATTRIBUTE_UNKNOWN",
")",
";",
"}",
"}"
] | Is attribute defined ?
@param string $attribute
@throws LogicException
@access protected | [
"Is",
"attribute",
"defined",
"?"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Driver/Pdo/Driver.php#L198-L206 |
9,003 | agencms/core | src/Group.php | Group.size | public static function size(string $name, int $size = 12)
{
$instance = new static();
$instance->group['name'] = $name;
$instance->group['size'] = $size;
return $instance;
} | php | public static function size(string $name, int $size = 12)
{
$instance = new static();
$instance->group['name'] = $name;
$instance->group['size'] = $size;
return $instance;
} | [
"public",
"static",
"function",
"size",
"(",
"string",
"$",
"name",
",",
"int",
"$",
"size",
"=",
"12",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"instance",
"->",
"group",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"instance",
"->",
"group",
"[",
"'size'",
"]",
"=",
"$",
"size",
";",
"return",
"$",
"instance",
";",
"}"
] | Set the display column width of the group
@param string $name
@param int $size
@return Agencms\Core\Group | [
"Set",
"the",
"display",
"column",
"width",
"of",
"the",
"group"
] | 67a20e1889fb4f8548a38b66ff0abf72194bb49e | https://github.com/agencms/core/blob/67a20e1889fb4f8548a38b66ff0abf72194bb49e/src/Group.php#L33-L41 |
9,004 | agencms/core | src/Group.php | Group.repeater | public function repeater(string $key)
{
$this->key($key);
$this->group['repeater'] = true;
return $this;
} | php | public function repeater(string $key)
{
$this->key($key);
$this->group['repeater'] = true;
return $this;
} | [
"public",
"function",
"repeater",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"key",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"group",
"[",
"'repeater'",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Defined a sub-group as a repeater group and assigns a key for saving
@param string $key
@return Agencms\Core\Group | [
"Defined",
"a",
"sub",
"-",
"group",
"as",
"a",
"repeater",
"group",
"and",
"assigns",
"a",
"key",
"for",
"saving"
] | 67a20e1889fb4f8548a38b66ff0abf72194bb49e | https://github.com/agencms/core/blob/67a20e1889fb4f8548a38b66ff0abf72194bb49e/src/Group.php#L80-L86 |
9,005 | agencms/core | src/Group.php | Group.addField | public function addField(Field ...$fields)
{
collect($fields)->map(function ($field) {
$this->group['fields']->put($field->key(), $field->get());
});
return $this;
} | php | public function addField(Field ...$fields)
{
collect($fields)->map(function ($field) {
$this->group['fields']->put($field->key(), $field->get());
});
return $this;
} | [
"public",
"function",
"addField",
"(",
"Field",
"...",
"$",
"fields",
")",
"{",
"collect",
"(",
"$",
"fields",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"group",
"[",
"'fields'",
"]",
"->",
"put",
"(",
"$",
"field",
"->",
"key",
"(",
")",
",",
"$",
"field",
"->",
"get",
"(",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add fields to the current group. Accepts a comma separated list of Fields
@param Field ...$fields
@return Agencms\Core\Group | [
"Add",
"fields",
"to",
"the",
"current",
"group",
".",
"Accepts",
"a",
"comma",
"separated",
"list",
"of",
"Fields"
] | 67a20e1889fb4f8548a38b66ff0abf72194bb49e | https://github.com/agencms/core/blob/67a20e1889fb4f8548a38b66ff0abf72194bb49e/src/Group.php#L107-L114 |
9,006 | agencms/core | src/Group.php | Group.addGroup | public function addGroup(Group ...$groups)
{
collect($groups)->map(function ($group) {
$this->group['groups'][] = $group->get();
});
return $this;
} | php | public function addGroup(Group ...$groups)
{
collect($groups)->map(function ($group) {
$this->group['groups'][] = $group->get();
});
return $this;
} | [
"public",
"function",
"addGroup",
"(",
"Group",
"...",
"$",
"groups",
")",
"{",
"collect",
"(",
"$",
"groups",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"group",
")",
"{",
"$",
"this",
"->",
"group",
"[",
"'groups'",
"]",
"[",
"]",
"=",
"$",
"group",
"->",
"get",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sub-groups are used to define collections of repeatable fields which can be
inserted, deleted and re-ordered by the user.
@param Agencms\Core\Group ...$groups
@return Agencms\Core\Group | [
"Sub",
"-",
"groups",
"are",
"used",
"to",
"define",
"collections",
"of",
"repeatable",
"fields",
"which",
"can",
"be",
"inserted",
"deleted",
"and",
"re",
"-",
"ordered",
"by",
"the",
"user",
"."
] | 67a20e1889fb4f8548a38b66ff0abf72194bb49e | https://github.com/agencms/core/blob/67a20e1889fb4f8548a38b66ff0abf72194bb49e/src/Group.php#L123-L130 |
9,007 | diatem-net/jin-ui | src/UI/Components/AbstractUIComponent.php | AbstractUIComponent.addClass | public function addClass($className)
{
if (!is_numeric(array_search($className, $this->classes))) {
$this->classes[] = $className;
return true;
}
return false;
} | php | public function addClass($className)
{
if (!is_numeric(array_search($className, $this->classes))) {
$this->classes[] = $className;
return true;
}
return false;
} | [
"public",
"function",
"addClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"array_search",
"(",
"$",
"className",
",",
"$",
"this",
"->",
"classes",
")",
")",
")",
"{",
"$",
"this",
"->",
"classes",
"[",
"]",
"=",
"$",
"className",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Applique une nouvelle classe CSS
@param string $className Nom de la classe à appliquer
@return boolean Retourne FALSE si cette classe était déjà appliquée | [
"Applique",
"une",
"nouvelle",
"classe",
"CSS"
] | d0825d3d0a983ee3d22b23e545eb9724b67bbaa5 | https://github.com/diatem-net/jin-ui/blob/d0825d3d0a983ee3d22b23e545eb9724b67bbaa5/src/UI/Components/AbstractUIComponent.php#L140-L147 |
9,008 | diatem-net/jin-ui | src/UI/Components/AbstractUIComponent.php | AbstractUIComponent.addAttribute | public function addAttribute($attributeName, $attributeValue)
{
if (!array_key_exists($attributeName, $this->attributes)) {
$this->attributes[$attributeName] = $attributeValue;
return true;
}
return false;
} | php | public function addAttribute($attributeName, $attributeValue)
{
if (!array_key_exists($attributeName, $this->attributes)) {
$this->attributes[$attributeName] = $attributeValue;
return true;
}
return false;
} | [
"public",
"function",
"addAttribute",
"(",
"$",
"attributeName",
",",
"$",
"attributeValue",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"attributeName",
",",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attributeName",
"]",
"=",
"$",
"attributeValue",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Ajoute un nouvel attribut
@param string $attributeName Nom de l'attribut
@param string $attributeValue Value de l'attribut
@return boolean Retourne FALSE si cet atribut était déjà ajouté | [
"Ajoute",
"un",
"nouvel",
"attribut"
] | d0825d3d0a983ee3d22b23e545eb9724b67bbaa5 | https://github.com/diatem-net/jin-ui/blob/d0825d3d0a983ee3d22b23e545eb9724b67bbaa5/src/UI/Components/AbstractUIComponent.php#L182-L189 |
9,009 | diatem-net/jin-ui | src/UI/Components/AbstractUIComponent.php | AbstractUIComponent.replaceMagicFields | public function replaceMagicFields($html)
{
$html = str_replace('%id%', $this->getId(), $html);
$html = str_replace('%class%', implode(' ', $this->classes), $html);
$html = str_replace('%style%', $this->getStyle(), $html);
$strAttributes = '';
foreach ($this->attributes as $key => $value) {
$strAttributes .= ' ' . $key . '="' . $value . '"';
}
$html = str_replace('%attributes%', $strAttributes, $html);
return $html;
} | php | public function replaceMagicFields($html)
{
$html = str_replace('%id%', $this->getId(), $html);
$html = str_replace('%class%', implode(' ', $this->classes), $html);
$html = str_replace('%style%', $this->getStyle(), $html);
$strAttributes = '';
foreach ($this->attributes as $key => $value) {
$strAttributes .= ' ' . $key . '="' . $value . '"';
}
$html = str_replace('%attributes%', $strAttributes, $html);
return $html;
} | [
"public",
"function",
"replaceMagicFields",
"(",
"$",
"html",
")",
"{",
"$",
"html",
"=",
"str_replace",
"(",
"'%id%'",
",",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"html",
")",
";",
"$",
"html",
"=",
"str_replace",
"(",
"'%class%'",
",",
"implode",
"(",
"' '",
",",
"$",
"this",
"->",
"classes",
")",
",",
"$",
"html",
")",
";",
"$",
"html",
"=",
"str_replace",
"(",
"'%style%'",
",",
"$",
"this",
"->",
"getStyle",
"(",
")",
",",
"$",
"html",
")",
";",
"$",
"strAttributes",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"strAttributes",
".=",
"' '",
".",
"$",
"key",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"}",
"$",
"html",
"=",
"str_replace",
"(",
"'%attributes%'",
",",
"$",
"strAttributes",
",",
"$",
"html",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Remplace les champs magiques des assets - concernant uniquement les champs magiques des composants de type UI
@param string $html HTML à inspeter
@return string | [
"Remplace",
"les",
"champs",
"magiques",
"des",
"assets",
"-",
"concernant",
"uniquement",
"les",
"champs",
"magiques",
"des",
"composants",
"de",
"type",
"UI"
] | d0825d3d0a983ee3d22b23e545eb9724b67bbaa5 | https://github.com/diatem-net/jin-ui/blob/d0825d3d0a983ee3d22b23e545eb9724b67bbaa5/src/UI/Components/AbstractUIComponent.php#L229-L241 |
9,010 | nirix/radium | src/Http/Request.php | Request.buildQueryString | public static function buildQueryString(array $data = null, $urlEncode = true)
{
if ($data === null) {
$data = static::$get;
}
$query = [];
foreach ($data as $name => $value) {
$query[] = "{$name}=" . ($urlEncode ? urlencode($value) : $value);
}
if (count($query)) {
return '?' . implode('&', $query);
}
} | php | public static function buildQueryString(array $data = null, $urlEncode = true)
{
if ($data === null) {
$data = static::$get;
}
$query = [];
foreach ($data as $name => $value) {
$query[] = "{$name}=" . ($urlEncode ? urlencode($value) : $value);
}
if (count($query)) {
return '?' . implode('&', $query);
}
} | [
"public",
"static",
"function",
"buildQueryString",
"(",
"array",
"$",
"data",
"=",
"null",
",",
"$",
"urlEncode",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"$",
"data",
"=",
"static",
"::",
"$",
"get",
";",
"}",
"$",
"query",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"[",
"]",
"=",
"\"{$name}=\"",
".",
"(",
"$",
"urlEncode",
"?",
"urlencode",
"(",
"$",
"value",
")",
":",
"$",
"value",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"query",
")",
")",
"{",
"return",
"'?'",
".",
"implode",
"(",
"'&'",
",",
"$",
"query",
")",
";",
"}",
"}"
] | Builds a query string, including the question mark.
@param array $data
@return string | [
"Builds",
"a",
"query",
"string",
"including",
"the",
"question",
"mark",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Request.php#L295-L310 |
9,011 | nirix/radium | src/Http/Request.php | Request.getAllHeaders | protected function getAllHeaders()
{
$headers = [];
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == 'HTTP_') {
$key = substr($key, 5);
$key = str_replace('_', ' ', strtolower($key));
$key = str_replace(' ', '-', ucwords($key));
$headers[$key] = $value;
}
}
return $headers;
} | php | protected function getAllHeaders()
{
$headers = [];
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) == 'HTTP_') {
$key = substr($key, 5);
$key = str_replace('_', ' ', strtolower($key));
$key = str_replace(' ', '-', ucwords($key));
$headers[$key] = $value;
}
}
return $headers;
} | [
"protected",
"function",
"getAllHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"_SERVER",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"5",
")",
"==",
"'HTTP_'",
")",
"{",
"$",
"key",
"=",
"substr",
"(",
"$",
"key",
",",
"5",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"strtolower",
"(",
"$",
"key",
")",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"' '",
",",
"'-'",
",",
"ucwords",
"(",
"$",
"key",
")",
")",
";",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] | Gets headers from `_SERVER` and formats the names nicely.
@return array | [
"Gets",
"headers",
"from",
"_SERVER",
"and",
"formats",
"the",
"names",
"nicely",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Http/Request.php#L317-L332 |
9,012 | synapsestudios/synapse-base | src/Synapse/Migration/RunMigrationsCommand.php | RunMigrationsCommand.migrationsToRun | protected function migrationsToRun()
{
// Get all migration files
$path = APPDIR.'/src/'.str_replace('\\', '/', $this->migrationNamespace);
if (! is_dir($path)) {
return [];
}
$dir = new DirectoryIterator($path);
$migrations = [];
foreach ($dir as $file) {
// Ignore directories and dotfiles (e.g. .DS_Store)
if (! $file->isFile() or substr($file->getBasename(), 0, 1) === '.') {
continue;
}
$class = $this->migrationNamespace.$file->getBasename('.php');
$migrations[] = new $class;
}
$alreadyExecutedMigrations = $this->alreadyExecutedMigrations();
$migrationsToRun = [];
foreach ($migrations as $migration) {
$compare = new ArrayObject([
'description' => $migration->getDescription(),
'timestamp' => $migration->getTimestamp(),
]);
if (in_array($compare, $alreadyExecutedMigrations)) {
continue;
}
$migrationsToRun[] = $migration;
}
return $migrationsToRun;
} | php | protected function migrationsToRun()
{
// Get all migration files
$path = APPDIR.'/src/'.str_replace('\\', '/', $this->migrationNamespace);
if (! is_dir($path)) {
return [];
}
$dir = new DirectoryIterator($path);
$migrations = [];
foreach ($dir as $file) {
// Ignore directories and dotfiles (e.g. .DS_Store)
if (! $file->isFile() or substr($file->getBasename(), 0, 1) === '.') {
continue;
}
$class = $this->migrationNamespace.$file->getBasename('.php');
$migrations[] = new $class;
}
$alreadyExecutedMigrations = $this->alreadyExecutedMigrations();
$migrationsToRun = [];
foreach ($migrations as $migration) {
$compare = new ArrayObject([
'description' => $migration->getDescription(),
'timestamp' => $migration->getTimestamp(),
]);
if (in_array($compare, $alreadyExecutedMigrations)) {
continue;
}
$migrationsToRun[] = $migration;
}
return $migrationsToRun;
} | [
"protected",
"function",
"migrationsToRun",
"(",
")",
"{",
"// Get all migration files",
"$",
"path",
"=",
"APPDIR",
".",
"'/src/'",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"this",
"->",
"migrationNamespace",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"dir",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"$",
"migrations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"file",
")",
"{",
"// Ignore directories and dotfiles (e.g. .DS_Store)",
"if",
"(",
"!",
"$",
"file",
"->",
"isFile",
"(",
")",
"or",
"substr",
"(",
"$",
"file",
"->",
"getBasename",
"(",
")",
",",
"0",
",",
"1",
")",
"===",
"'.'",
")",
"{",
"continue",
";",
"}",
"$",
"class",
"=",
"$",
"this",
"->",
"migrationNamespace",
".",
"$",
"file",
"->",
"getBasename",
"(",
"'.php'",
")",
";",
"$",
"migrations",
"[",
"]",
"=",
"new",
"$",
"class",
";",
"}",
"$",
"alreadyExecutedMigrations",
"=",
"$",
"this",
"->",
"alreadyExecutedMigrations",
"(",
")",
";",
"$",
"migrationsToRun",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"migrations",
"as",
"$",
"migration",
")",
"{",
"$",
"compare",
"=",
"new",
"ArrayObject",
"(",
"[",
"'description'",
"=>",
"$",
"migration",
"->",
"getDescription",
"(",
")",
",",
"'timestamp'",
"=>",
"$",
"migration",
"->",
"getTimestamp",
"(",
")",
",",
"]",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"compare",
",",
"$",
"alreadyExecutedMigrations",
")",
")",
"{",
"continue",
";",
"}",
"$",
"migrationsToRun",
"[",
"]",
"=",
"$",
"migration",
";",
"}",
"return",
"$",
"migrationsToRun",
";",
"}"
] | Determine all migrations that have not yet been run on the database
@return array | [
"Determine",
"all",
"migrations",
"that",
"have",
"not",
"yet",
"been",
"run",
"on",
"the",
"database"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Migration/RunMigrationsCommand.php#L106-L146 |
9,013 | synapsestudios/synapse-base | src/Synapse/Migration/RunMigrationsCommand.php | RunMigrationsCommand.recordMigration | protected function recordMigration(AbstractMigration $migration)
{
$query = 'INSERT INTO `app_migrations` (`timestamp`, `description`) VALUES ("%s", "%s")';
$query = sprintf($query, $migration->getTimestamp(), $migration->getDescription());
$this->db->query($query, DbAdapter::QUERY_MODE_EXECUTE);
} | php | protected function recordMigration(AbstractMigration $migration)
{
$query = 'INSERT INTO `app_migrations` (`timestamp`, `description`) VALUES ("%s", "%s")';
$query = sprintf($query, $migration->getTimestamp(), $migration->getDescription());
$this->db->query($query, DbAdapter::QUERY_MODE_EXECUTE);
} | [
"protected",
"function",
"recordMigration",
"(",
"AbstractMigration",
"$",
"migration",
")",
"{",
"$",
"query",
"=",
"'INSERT INTO `app_migrations` (`timestamp`, `description`) VALUES (\"%s\", \"%s\")'",
";",
"$",
"query",
"=",
"sprintf",
"(",
"$",
"query",
",",
"$",
"migration",
"->",
"getTimestamp",
"(",
")",
",",
"$",
"migration",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"query",
",",
"DbAdapter",
"::",
"QUERY_MODE_EXECUTE",
")",
";",
"}"
] | Insert a record into app_migrations to record that this migration was run
@param AbstractMigration $migration | [
"Insert",
"a",
"record",
"into",
"app_migrations",
"to",
"record",
"that",
"this",
"migration",
"was",
"run"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Migration/RunMigrationsCommand.php#L153-L159 |
9,014 | synapsestudios/synapse-base | src/Synapse/Migration/RunMigrationsCommand.php | RunMigrationsCommand.alreadyExecutedMigrations | protected function alreadyExecutedMigrations()
{
$results = $this->db->query(
'SELECT * FROM `app_migrations`',
DbAdapter::QUERY_MODE_EXECUTE
);
return (array) iterator_to_array($results, true);
} | php | protected function alreadyExecutedMigrations()
{
$results = $this->db->query(
'SELECT * FROM `app_migrations`',
DbAdapter::QUERY_MODE_EXECUTE
);
return (array) iterator_to_array($results, true);
} | [
"protected",
"function",
"alreadyExecutedMigrations",
"(",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"'SELECT * FROM `app_migrations`'",
",",
"DbAdapter",
"::",
"QUERY_MODE_EXECUTE",
")",
";",
"return",
"(",
"array",
")",
"iterator_to_array",
"(",
"$",
"results",
",",
"true",
")",
";",
"}"
] | Return array of already executed migrations.
@return array | [
"Return",
"array",
"of",
"already",
"executed",
"migrations",
"."
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Migration/RunMigrationsCommand.php#L166-L174 |
9,015 | jitesoft/php-math | src/Matrix.php | Matrix.getAdjoinMatrix | public function getAdjoinMatrix() : Matrix {
$matrix = new static();
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$subMatrix = MatrixMath::getSubMatrix($this->toArray(), $i, $j);
$matrix[$i][$j] = MatrixMath::calculateDeterminant($subMatrix);
}
}
return $matrix;
} | php | public function getAdjoinMatrix() : Matrix {
$matrix = new static();
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$subMatrix = MatrixMath::getSubMatrix($this->toArray(), $i, $j);
$matrix[$i][$j] = MatrixMath::calculateDeterminant($subMatrix);
}
}
return $matrix;
} | [
"public",
"function",
"getAdjoinMatrix",
"(",
")",
":",
"Matrix",
"{",
"$",
"matrix",
"=",
"new",
"static",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"ROWS",
";",
"$",
"i",
"++",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"static",
"::",
"COLUMNS",
";",
"$",
"j",
"++",
")",
"{",
"$",
"subMatrix",
"=",
"MatrixMath",
"::",
"getSubMatrix",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
",",
"$",
"i",
",",
"$",
"j",
")",
";",
"$",
"matrix",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"MatrixMath",
"::",
"calculateDeterminant",
"(",
"$",
"subMatrix",
")",
";",
"}",
"}",
"return",
"$",
"matrix",
";",
"}"
] | Get the minors matrix of the matrix.
@return Matrix | [
"Get",
"the",
"minors",
"matrix",
"of",
"the",
"matrix",
"."
] | 1775055e5a14ef30c7df0deeb1fe1ff0775bb581 | https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/Matrix.php#L76-L85 |
9,016 | jitesoft/php-math | src/Matrix.php | Matrix.transpose | public function transpose() {
$cpy = new static();
$cpy->copy($this);
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$this[$i][$j] = $cpy[$j][$i];
}
}
} | php | public function transpose() {
$cpy = new static();
$cpy->copy($this);
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$this[$i][$j] = $cpy[$j][$i];
}
}
} | [
"public",
"function",
"transpose",
"(",
")",
"{",
"$",
"cpy",
"=",
"new",
"static",
"(",
")",
";",
"$",
"cpy",
"->",
"copy",
"(",
"$",
"this",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"ROWS",
";",
"$",
"i",
"++",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"static",
"::",
"COLUMNS",
";",
"$",
"j",
"++",
")",
"{",
"$",
"this",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"$",
"cpy",
"[",
"$",
"j",
"]",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"}"
] | Transpose the matrix. | [
"Transpose",
"the",
"matrix",
"."
] | 1775055e5a14ef30c7df0deeb1fe1ff0775bb581 | https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/Matrix.php#L90-L100 |
9,017 | jitesoft/php-math | src/Matrix.php | Matrix.inverse | public function inverse() {
$determinant = $this->determinant();
if ($determinant == 0) { // If 0, there is no inverse.
return;
}
$adj = $this->getAdjoinMatrix();
for ($i=0; $i<static::ROWS; $i++) {
$sign = ($i%2 === 1) ? -1 : 1;
for ($j=0; $j<static::COLUMNS; $j++) {
$adj[$i][$j] = $sign * $adj[$i][$j];
$sign = -$sign;
}
}
$this->copy($adj);
$this->transpose();
$div = 1 / $determinant;
$this->mul($div);
} | php | public function inverse() {
$determinant = $this->determinant();
if ($determinant == 0) { // If 0, there is no inverse.
return;
}
$adj = $this->getAdjoinMatrix();
for ($i=0; $i<static::ROWS; $i++) {
$sign = ($i%2 === 1) ? -1 : 1;
for ($j=0; $j<static::COLUMNS; $j++) {
$adj[$i][$j] = $sign * $adj[$i][$j];
$sign = -$sign;
}
}
$this->copy($adj);
$this->transpose();
$div = 1 / $determinant;
$this->mul($div);
} | [
"public",
"function",
"inverse",
"(",
")",
"{",
"$",
"determinant",
"=",
"$",
"this",
"->",
"determinant",
"(",
")",
";",
"if",
"(",
"$",
"determinant",
"==",
"0",
")",
"{",
"// If 0, there is no inverse.",
"return",
";",
"}",
"$",
"adj",
"=",
"$",
"this",
"->",
"getAdjoinMatrix",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"ROWS",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sign",
"=",
"(",
"$",
"i",
"%",
"2",
"===",
"1",
")",
"?",
"-",
"1",
":",
"1",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"static",
"::",
"COLUMNS",
";",
"$",
"j",
"++",
")",
"{",
"$",
"adj",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"$",
"sign",
"*",
"$",
"adj",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
";",
"$",
"sign",
"=",
"-",
"$",
"sign",
";",
"}",
"}",
"$",
"this",
"->",
"copy",
"(",
"$",
"adj",
")",
";",
"$",
"this",
"->",
"transpose",
"(",
")",
";",
"$",
"div",
"=",
"1",
"/",
"$",
"determinant",
";",
"$",
"this",
"->",
"mul",
"(",
"$",
"div",
")",
";",
"}"
] | Inverse the matrix. | [
"Inverse",
"the",
"matrix",
"."
] | 1775055e5a14ef30c7df0deeb1fe1ff0775bb581 | https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/Matrix.php#L165-L184 |
9,018 | jitesoft/php-math | src/Matrix.php | Matrix.copy | protected function copy(Matrix $matrix) {
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$this->vectors[$i][$j] = $matrix[$i][$j];
}
}
} | php | protected function copy(Matrix $matrix) {
for ($i=0; $i<static::ROWS; $i++) {
for ($j=0; $j<static::COLUMNS; $j++) {
$this->vectors[$i][$j] = $matrix[$i][$j];
}
}
} | [
"protected",
"function",
"copy",
"(",
"Matrix",
"$",
"matrix",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"ROWS",
";",
"$",
"i",
"++",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"static",
"::",
"COLUMNS",
";",
"$",
"j",
"++",
")",
"{",
"$",
"this",
"->",
"vectors",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"$",
"matrix",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
";",
"}",
"}",
"}"
] | Copy the matrix to another matrix.
@param Matrix $matrix | [
"Copy",
"the",
"matrix",
"to",
"another",
"matrix",
"."
] | 1775055e5a14ef30c7df0deeb1fe1ff0775bb581 | https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/Matrix.php#L218-L224 |
9,019 | hametuha/hametwoo | src/Hametuha/HametWoo.php | HametWoo.template_fallback | public function template_fallback( $template, $template_name, $template_path ) {
if ( ! file_exists( $template ) ) {
// Woops, no template. Does hametwoo has it?
$fallback = self::root_dir() . '/templates/' . $template_name;
if ( file_exists( $fallback ) ) {
$template = $fallback;
}
}
return $template;
} | php | public function template_fallback( $template, $template_name, $template_path ) {
if ( ! file_exists( $template ) ) {
// Woops, no template. Does hametwoo has it?
$fallback = self::root_dir() . '/templates/' . $template_name;
if ( file_exists( $fallback ) ) {
$template = $fallback;
}
}
return $template;
} | [
"public",
"function",
"template_fallback",
"(",
"$",
"template",
",",
"$",
"template_name",
",",
"$",
"template_path",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"template",
")",
")",
"{",
"// Woops, no template. Does hametwoo has it?",
"$",
"fallback",
"=",
"self",
"::",
"root_dir",
"(",
")",
".",
"'/templates/'",
".",
"$",
"template_name",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fallback",
")",
")",
"{",
"$",
"template",
"=",
"$",
"fallback",
";",
"}",
"}",
"return",
"$",
"template",
";",
"}"
] | Add hametwoo dir to template.
@param string $template File path.
@param string $template_name Template name. e.g. email/cancel-order.php
@param string $template_path Template base name. Default `woocommerce`.
@return string | [
"Add",
"hametwoo",
"dir",
"to",
"template",
"."
] | bcd5948ea53d6ca2181873a9f9d0d221c346592e | https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo.php#L38-L47 |
9,020 | hametuha/hametwoo | src/Hametuha/HametWoo.php | HametWoo.send_mail | public function send_mail( $mail_id, $arguments = [] ) {
$mailers = WC()->mailer()->get_emails();
foreach ( $mailers as $mailer ) {
/* @var \WC_Email $mailer */
if ( $mail_id == $mailer->id ) {
if ( $arguments ) {
call_user_func_array( [ $mailer, 'trigger' ], $arguments );
} else {
$mailer->trigger();
}
}
}
} | php | public function send_mail( $mail_id, $arguments = [] ) {
$mailers = WC()->mailer()->get_emails();
foreach ( $mailers as $mailer ) {
/* @var \WC_Email $mailer */
if ( $mail_id == $mailer->id ) {
if ( $arguments ) {
call_user_func_array( [ $mailer, 'trigger' ], $arguments );
} else {
$mailer->trigger();
}
}
}
} | [
"public",
"function",
"send_mail",
"(",
"$",
"mail_id",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"mailers",
"=",
"WC",
"(",
")",
"->",
"mailer",
"(",
")",
"->",
"get_emails",
"(",
")",
";",
"foreach",
"(",
"$",
"mailers",
"as",
"$",
"mailer",
")",
"{",
"/* @var \\WC_Email $mailer */",
"if",
"(",
"$",
"mail_id",
"==",
"$",
"mailer",
"->",
"id",
")",
"{",
"if",
"(",
"$",
"arguments",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"mailer",
",",
"'trigger'",
"]",
",",
"$",
"arguments",
")",
";",
"}",
"else",
"{",
"$",
"mailer",
"->",
"trigger",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Send email short hand.
@param string $mail_id Mail ID.
@param array $arguments Argument passed to $mailer->trigger. | [
"Send",
"email",
"short",
"hand",
"."
] | bcd5948ea53d6ca2181873a9f9d0d221c346592e | https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo.php#L64-L76 |
9,021 | bkdotcom/Toolbox | src/Email.php | Email.addressesGet | public static function addressesGet($addresses)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$return = array();
if (!is_array($addresses)) {
$addresses = self::addressParse($addresses);
}
foreach ($addresses as $k => $v) {
if (is_array($v)) {
// parsed address
if (!empty($v['name'])) {
$return[ $v['email'] ] = $v['name'];
} else {
$return[] = $v['email'];
}
} elseif (is_int($k)) {
$v = self::addressParse($v);
$v = array_shift($v);
// $this->debug->log($k, $v);
if (!empty($v['name'])) {
$return[ $v['email'] ] = $v['name'];
} else {
$return[] = $v['email'];
}
} else {
// email => name
$return[$k] = $v;
}
}
// $this->debug->groupEnd();
return $return;
} | php | public static function addressesGet($addresses)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$return = array();
if (!is_array($addresses)) {
$addresses = self::addressParse($addresses);
}
foreach ($addresses as $k => $v) {
if (is_array($v)) {
// parsed address
if (!empty($v['name'])) {
$return[ $v['email'] ] = $v['name'];
} else {
$return[] = $v['email'];
}
} elseif (is_int($k)) {
$v = self::addressParse($v);
$v = array_shift($v);
// $this->debug->log($k, $v);
if (!empty($v['name'])) {
$return[ $v['email'] ] = $v['name'];
} else {
$return[] = $v['email'];
}
} else {
// email => name
$return[$k] = $v;
}
}
// $this->debug->groupEnd();
return $return;
} | [
"public",
"static",
"function",
"addressesGet",
"(",
"$",
"addresses",
")",
"{",
"// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"addresses",
")",
")",
"{",
"$",
"addresses",
"=",
"self",
"::",
"addressParse",
"(",
"$",
"addresses",
")",
";",
"}",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"// parsed address",
"if",
"(",
"!",
"empty",
"(",
"$",
"v",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"$",
"v",
"[",
"'email'",
"]",
"]",
"=",
"$",
"v",
"[",
"'name'",
"]",
";",
"}",
"else",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"v",
"[",
"'email'",
"]",
";",
"}",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"k",
")",
")",
"{",
"$",
"v",
"=",
"self",
"::",
"addressParse",
"(",
"$",
"v",
")",
";",
"$",
"v",
"=",
"array_shift",
"(",
"$",
"v",
")",
";",
"// $this->debug->log($k, $v);",
"if",
"(",
"!",
"empty",
"(",
"$",
"v",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"return",
"[",
"$",
"v",
"[",
"'email'",
"]",
"]",
"=",
"$",
"v",
"[",
"'name'",
"]",
";",
"}",
"else",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"v",
"[",
"'email'",
"]",
";",
"}",
"}",
"else",
"{",
"// email => name",
"$",
"return",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"// $this->debug->groupEnd();",
"return",
"$",
"return",
";",
"}"
] | Get address array from passed address string or addresses
@param mixed $addresses address / addresses
@return array (email => name, x => email) | [
"Get",
"address",
"array",
"from",
"passed",
"address",
"string",
"or",
"addresses"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Email.php#L96-L127 |
9,022 | bkdotcom/Toolbox | src/Email.php | Email.addressBuildString | public static function addressBuildString($addresses)
{
$addresses = self::addressesGet($addresses);
$addressesNew = array();
foreach ($addresses as $k => $v) {
$name = null;
if (is_int($k)) {
$address = $v;
} else {
$name = $v;
$address = $k;
}
if (!isset($_SERVER['WINDIR']) && $name) {
if (strpos($name, ',')) {
$name = addcslashes($name, '()');
$name = '"'.$name.'"';
}
$address = $name.' <'.$address.'>';
}
$addressesNew[] = $address;
}
return implode(', ', $addressesNew);
} | php | public static function addressBuildString($addresses)
{
$addresses = self::addressesGet($addresses);
$addressesNew = array();
foreach ($addresses as $k => $v) {
$name = null;
if (is_int($k)) {
$address = $v;
} else {
$name = $v;
$address = $k;
}
if (!isset($_SERVER['WINDIR']) && $name) {
if (strpos($name, ',')) {
$name = addcslashes($name, '()');
$name = '"'.$name.'"';
}
$address = $name.' <'.$address.'>';
}
$addressesNew[] = $address;
}
return implode(', ', $addressesNew);
} | [
"public",
"static",
"function",
"addressBuildString",
"(",
"$",
"addresses",
")",
"{",
"$",
"addresses",
"=",
"self",
"::",
"addressesGet",
"(",
"$",
"addresses",
")",
";",
"$",
"addressesNew",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"name",
"=",
"null",
";",
"if",
"(",
"is_int",
"(",
"$",
"k",
")",
")",
"{",
"$",
"address",
"=",
"$",
"v",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"v",
";",
"$",
"address",
"=",
"$",
"k",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"'WINDIR'",
"]",
")",
"&&",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"','",
")",
")",
"{",
"$",
"name",
"=",
"addcslashes",
"(",
"$",
"name",
",",
"'()'",
")",
";",
"$",
"name",
"=",
"'\"'",
".",
"$",
"name",
".",
"'\"'",
";",
"}",
"$",
"address",
"=",
"$",
"name",
".",
"' <'",
".",
"$",
"address",
".",
"'>'",
";",
"}",
"$",
"addressesNew",
"[",
"]",
"=",
"$",
"address",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"addressesNew",
")",
";",
"}"
] | Returns email address string
@param mixed $addresses addresses string or array
@return string | [
"Returns",
"email",
"address",
"string"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Email.php#L136-L158 |
9,023 | bkdotcom/Toolbox | src/Email.php | Email.addressParse | public static function addressParse($addressString)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
// $this->debug->log('addressString', $addressString);
$pattern = '/^(?:"?((?:[^"\\\\]|\\\\.)+)"?\s)?' // name
.'<?([a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4})>?$/i'; // email
$addresses = str_getcsv($addressString);
// $this->debug->log('addresses', $addresses);
$result = array();
foreach ($addresses as $address) {
$address = trim($address);
if (preg_match($pattern, $address, $matches)) {
$item = array();
if ($matches[1] != '') {
$item['name'] = stripcslashes($matches[1]);
}
$item['email'] = $matches[2];
$result[] = $item;
}
}
// $this->debug->groupEnd();
return $result;
} | php | public static function addressParse($addressString)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
// $this->debug->log('addressString', $addressString);
$pattern = '/^(?:"?((?:[^"\\\\]|\\\\.)+)"?\s)?' // name
.'<?([a-z0-9._%-]+@[a-z0-9.-]+\\.[a-z]{2,4})>?$/i'; // email
$addresses = str_getcsv($addressString);
// $this->debug->log('addresses', $addresses);
$result = array();
foreach ($addresses as $address) {
$address = trim($address);
if (preg_match($pattern, $address, $matches)) {
$item = array();
if ($matches[1] != '') {
$item['name'] = stripcslashes($matches[1]);
}
$item['email'] = $matches[2];
$result[] = $item;
}
}
// $this->debug->groupEnd();
return $result;
} | [
"public",
"static",
"function",
"addressParse",
"(",
"$",
"addressString",
")",
"{",
"// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);",
"// $this->debug->log('addressString', $addressString);",
"$",
"pattern",
"=",
"'/^(?:\"?((?:[^\"\\\\\\\\]|\\\\\\\\.)+)\"?\\s)?'",
"// name",
".",
"'<?([a-z0-9._%-]+@[a-z0-9.-]+\\\\.[a-z]{2,4})>?$/i'",
";",
"// email",
"$",
"addresses",
"=",
"str_getcsv",
"(",
"$",
"addressString",
")",
";",
"// $this->debug->log('addresses', $addresses);",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"address",
")",
"{",
"$",
"address",
"=",
"trim",
"(",
"$",
"address",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"address",
",",
"$",
"matches",
")",
")",
"{",
"$",
"item",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"matches",
"[",
"1",
"]",
"!=",
"''",
")",
"{",
"$",
"item",
"[",
"'name'",
"]",
"=",
"stripcslashes",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"$",
"item",
"[",
"'email'",
"]",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"// $this->debug->groupEnd();",
"return",
"$",
"result",
";",
"}"
] | parse address string
@param string $addressString rfc-822 address list
@return array (name & email)
@see http://stackoverflow.com/questions/6609195/parse-rfc-822-compliant-addresses-in-a-to-header | [
"parse",
"address",
"string"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Email.php#L168-L190 |
9,024 | bkdotcom/Toolbox | src/Email.php | Email.addressValidate | public static function addressValidate($email)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$return = false;
$regex = '/^'
.'[a-z0-9_]+([_\.-][a-z0-9]+)*' // user
.'@'
.'([a-z0-9]+([\.-][a-z0-9]+)*)+' // domain
.'(\.[a-z]{2,})' // sld, tld
.'$/i';
$email = trim($email);
if (preg_match($regex, $email, $matches)) {
// $this->debug->log('properly formatted');
$hostname = strtolower($matches[2].$matches[4]);
$ipaddress = gethostbyname($hostname); // A record
// $this->debug->log('hostname', $hostname);
// $this->debug->log('ipaddress', $ipaddress);
$return = $email;
if ($ipaddress != $hostname) {
// $this->debug->log('A record', $ipaddress);
} elseif ($mxrecord = getmxrr($hostname, $mxhosts)) {
// $this->debug->log('getmxrr('.$hostname.')', $mxrecord, $mxhosts);
} elseif (strpos($_SERVER['SERVER_NAME'], $hostname)) {
// $this->debug->log('email domain matches server domain');
} else {
// $this->debug->log('warn', 'unable to verify');
$return = false;
}
}
// $this->debug->groupEnd();
return $return;
} | php | public static function addressValidate($email)
{
// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$return = false;
$regex = '/^'
.'[a-z0-9_]+([_\.-][a-z0-9]+)*' // user
.'@'
.'([a-z0-9]+([\.-][a-z0-9]+)*)+' // domain
.'(\.[a-z]{2,})' // sld, tld
.'$/i';
$email = trim($email);
if (preg_match($regex, $email, $matches)) {
// $this->debug->log('properly formatted');
$hostname = strtolower($matches[2].$matches[4]);
$ipaddress = gethostbyname($hostname); // A record
// $this->debug->log('hostname', $hostname);
// $this->debug->log('ipaddress', $ipaddress);
$return = $email;
if ($ipaddress != $hostname) {
// $this->debug->log('A record', $ipaddress);
} elseif ($mxrecord = getmxrr($hostname, $mxhosts)) {
// $this->debug->log('getmxrr('.$hostname.')', $mxrecord, $mxhosts);
} elseif (strpos($_SERVER['SERVER_NAME'], $hostname)) {
// $this->debug->log('email domain matches server domain');
} else {
// $this->debug->log('warn', 'unable to verify');
$return = false;
}
}
// $this->debug->groupEnd();
return $return;
} | [
"public",
"static",
"function",
"addressValidate",
"(",
"$",
"email",
")",
"{",
"// $this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);",
"$",
"return",
"=",
"false",
";",
"$",
"regex",
"=",
"'/^'",
".",
"'[a-z0-9_]+([_\\.-][a-z0-9]+)*'",
"// user",
".",
"'@'",
".",
"'([a-z0-9]+([\\.-][a-z0-9]+)*)+'",
"// domain",
".",
"'(\\.[a-z]{2,})'",
"// sld, tld",
".",
"'$/i'",
";",
"$",
"email",
"=",
"trim",
"(",
"$",
"email",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"email",
",",
"$",
"matches",
")",
")",
"{",
"// $this->debug->log('properly formatted');",
"$",
"hostname",
"=",
"strtolower",
"(",
"$",
"matches",
"[",
"2",
"]",
".",
"$",
"matches",
"[",
"4",
"]",
")",
";",
"$",
"ipaddress",
"=",
"gethostbyname",
"(",
"$",
"hostname",
")",
";",
"// A record",
"// $this->debug->log('hostname', $hostname);",
"// $this->debug->log('ipaddress', $ipaddress);",
"$",
"return",
"=",
"$",
"email",
";",
"if",
"(",
"$",
"ipaddress",
"!=",
"$",
"hostname",
")",
"{",
"// $this->debug->log('A record', $ipaddress);",
"}",
"elseif",
"(",
"$",
"mxrecord",
"=",
"getmxrr",
"(",
"$",
"hostname",
",",
"$",
"mxhosts",
")",
")",
"{",
"// $this->debug->log('getmxrr('.$hostname.')', $mxrecord, $mxhosts);",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
",",
"$",
"hostname",
")",
")",
"{",
"// $this->debug->log('email domain matches server domain');",
"}",
"else",
"{",
"// $this->debug->log('warn', 'unable to verify');",
"$",
"return",
"=",
"false",
";",
"}",
"}",
"// $this->debug->groupEnd();",
"return",
"$",
"return",
";",
"}"
] | validate an email addrses
@param string $email email address
@return string|boolean returns false if invalid | [
"validate",
"an",
"email",
"addrses"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Email.php#L199-L230 |
9,025 | n0m4dz/laracasa | Zend/Gdata/Gapps/GroupQuery.php | Zend_Gdata_Gapps_GroupQuery.setDirectOnly | public function setDirectOnly($value)
{
if ($value !== null) {
if($value == true) {
$this->_params['directOnly'] = 'true';
} else {
$this->_params['directOnly'] = 'false';
}
} else {
unset($this->_params['directOnly']);
}
} | php | public function setDirectOnly($value)
{
if ($value !== null) {
if($value == true) {
$this->_params['directOnly'] = 'true';
} else {
$this->_params['directOnly'] = 'false';
}
} else {
unset($this->_params['directOnly']);
}
} | [
"public",
"function",
"setDirectOnly",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"_params",
"[",
"'directOnly'",
"]",
"=",
"'true'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_params",
"[",
"'directOnly'",
"]",
"=",
"'false'",
";",
"}",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'directOnly'",
"]",
")",
";",
"}",
"}"
] | Sets the query parameter directOnly
@param bool $value | [
"Sets",
"the",
"query",
"parameter",
"directOnly"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Gapps/GroupQuery.php#L137-L148 |
9,026 | kiler129/CherryHttp | src/Http/Response/ResponseCode.php | ResponseCode.getReasonPhraseByCode | public static function getReasonPhraseByCode($code)
{
if (isset(self::$codesDescription[$code])) {
return self::$codesDescription[$code];
}
$group = self::getGroupFromCode($code);
return self::getReasonPhraseByGroup($group);
} | php | public static function getReasonPhraseByCode($code)
{
if (isset(self::$codesDescription[$code])) {
return self::$codesDescription[$code];
}
$group = self::getGroupFromCode($code);
return self::getReasonPhraseByGroup($group);
} | [
"public",
"static",
"function",
"getReasonPhraseByCode",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"codesDescription",
"[",
"$",
"code",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"codesDescription",
"[",
"$",
"code",
"]",
";",
"}",
"$",
"group",
"=",
"self",
"::",
"getGroupFromCode",
"(",
"$",
"code",
")",
";",
"return",
"self",
"::",
"getReasonPhraseByGroup",
"(",
"$",
"group",
")",
";",
"}"
] | Provides description for IANA registered HTTP codes.
If not registered code was specified respective group description is returned.
@param int $code
@return string | [
"Provides",
"description",
"for",
"IANA",
"registered",
"HTTP",
"codes",
".",
"If",
"not",
"registered",
"code",
"was",
"specified",
"respective",
"group",
"description",
"is",
"returned",
"."
] | 05927f26183cbd6fd5ccb0853befecdea279308d | https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/Http/Response/ResponseCode.php#L236-L245 |
9,027 | dazarobbo/Cola | src/BitSet.php | BitSet.fromBinaryString | protected function fromBinaryString($str){
if(!(\is_string($str) && \preg_match('/^[01]+$/', $str))){
throw new \InvalidArgumentException('$str is not a binary string');
}
for($i = 0, $l = \strlen($str); $i < $l; ++$i){
$this->_List->pushFront($str[$i] === '1' ? true : false);
}
} | php | protected function fromBinaryString($str){
if(!(\is_string($str) && \preg_match('/^[01]+$/', $str))){
throw new \InvalidArgumentException('$str is not a binary string');
}
for($i = 0, $l = \strlen($str); $i < $l; ++$i){
$this->_List->pushFront($str[$i] === '1' ? true : false);
}
} | [
"protected",
"function",
"fromBinaryString",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"(",
"\\",
"is_string",
"(",
"$",
"str",
")",
"&&",
"\\",
"preg_match",
"(",
"'/^[01]+$/'",
",",
"$",
"str",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$str is not a binary string'",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"l",
"=",
"\\",
"strlen",
"(",
"$",
"str",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"_List",
"->",
"pushFront",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
"===",
"'1'",
"?",
"true",
":",
"false",
")",
";",
"}",
"}"
] | Sets bits from a binary string
@param string $str
@throws \InvalidArgumentException | [
"Sets",
"bits",
"from",
"a",
"binary",
"string"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L74-L84 |
9,028 | dazarobbo/Cola | src/BitSet.php | BitSet.flip | public function flip($pos = null){
if(\is_int($pos)){
$this->_List[$pos] = !$this->_List[$pos];
}
else{
$this->_List = $this->_List->map(function($v){
return !$v;
});
}
} | php | public function flip($pos = null){
if(\is_int($pos)){
$this->_List[$pos] = !$this->_List[$pos];
}
else{
$this->_List = $this->_List->map(function($v){
return !$v;
});
}
} | [
"public",
"function",
"flip",
"(",
"$",
"pos",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"pos",
")",
")",
"{",
"$",
"this",
"->",
"_List",
"[",
"$",
"pos",
"]",
"=",
"!",
"$",
"this",
"->",
"_List",
"[",
"$",
"pos",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_List",
"=",
"$",
"this",
"->",
"_List",
"->",
"map",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"!",
"$",
"v",
";",
"}",
")",
";",
"}",
"}"
] | Flips all bits or one specific bit by position
@param int $pos optional | [
"Flips",
"all",
"bits",
"or",
"one",
"specific",
"bit",
"by",
"position"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L116-L127 |
9,029 | dazarobbo/Cola | src/BitSet.php | BitSet.logicalAnd | public function logicalAnd(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
$new[$i] = isset($this[$i], $other[$i])
? ($this[$i] && $other[$i])
: false;
}
return $new;
} | php | public function logicalAnd(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
$new[$i] = isset($this[$i], $other[$i])
? ($this[$i] && $other[$i])
: false;
}
return $new;
} | [
"public",
"function",
"logicalAnd",
"(",
"self",
"$",
"other",
")",
"{",
"$",
"l",
"=",
"\\",
"max",
"(",
"array",
"(",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"other",
"->",
"count",
"(",
")",
")",
")",
";",
"$",
"new",
"=",
"new",
"static",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"isset",
"(",
"$",
"this",
"[",
"$",
"i",
"]",
",",
"$",
"other",
"[",
"$",
"i",
"]",
")",
"?",
"(",
"$",
"this",
"[",
"$",
"i",
"]",
"&&",
"$",
"other",
"[",
"$",
"i",
"]",
")",
":",
"false",
";",
"}",
"return",
"$",
"new",
";",
"}"
] | Returns a new BitSet after ANDing this set with another
@param self $other
@return \static | [
"Returns",
"a",
"new",
"BitSet",
"after",
"ANDing",
"this",
"set",
"with",
"another"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L134-L147 |
9,030 | dazarobbo/Cola | src/BitSet.php | BitSet.logicalOr | public function logicalOr(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
if(isset($this[$i]) && $other[$i]){
$new[$i] = true;
}
else if(isset($other[$i]) && $other[$i]){
$new[$i] = true;
}
else{
$new[$i] = false;
}
}
return $new;
} | php | public function logicalOr(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
if(isset($this[$i]) && $other[$i]){
$new[$i] = true;
}
else if(isset($other[$i]) && $other[$i]){
$new[$i] = true;
}
else{
$new[$i] = false;
}
}
return $new;
} | [
"public",
"function",
"logicalOr",
"(",
"self",
"$",
"other",
")",
"{",
"$",
"l",
"=",
"\\",
"max",
"(",
"array",
"(",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"other",
"->",
"count",
"(",
")",
")",
")",
";",
"$",
"new",
"=",
"new",
"static",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"i",
"]",
")",
"&&",
"$",
"other",
"[",
"$",
"i",
"]",
")",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"other",
"[",
"$",
"i",
"]",
")",
"&&",
"$",
"other",
"[",
"$",
"i",
"]",
")",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"new",
";",
"}"
] | Returns a new BitSet after ORing this set with another
@param self $other
@return \static | [
"Returns",
"a",
"new",
"BitSet",
"after",
"ORing",
"this",
"set",
"with",
"another"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L154-L175 |
9,031 | dazarobbo/Cola | src/BitSet.php | BitSet.logicalXor | public function logicalXor(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
if(isset($this[$i], $other[$i])){
$new[$i] = (bool)($this[$i] ^ $other[$i]);
}
else{
$new[$i] = false;
}
}
return $new;
} | php | public function logicalXor(self $other){
$l = \max(array($this->count(), $other->count()));
$new = new static();
for($i = 0; $i < $l; ++$i){
if(isset($this[$i], $other[$i])){
$new[$i] = (bool)($this[$i] ^ $other[$i]);
}
else{
$new[$i] = false;
}
}
return $new;
} | [
"public",
"function",
"logicalXor",
"(",
"self",
"$",
"other",
")",
"{",
"$",
"l",
"=",
"\\",
"max",
"(",
"array",
"(",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"other",
"->",
"count",
"(",
")",
")",
")",
";",
"$",
"new",
"=",
"new",
"static",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"i",
"]",
",",
"$",
"other",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"(",
"bool",
")",
"(",
"$",
"this",
"[",
"$",
"i",
"]",
"^",
"$",
"other",
"[",
"$",
"i",
"]",
")",
";",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"i",
"]",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"new",
";",
"}"
] | Returns a new BitSet after XORing this set with another
@param self $other
@return \static | [
"Returns",
"a",
"new",
"BitSet",
"after",
"XORing",
"this",
"set",
"with",
"another"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L182-L200 |
9,032 | dazarobbo/Cola | src/BitSet.php | BitSet.reset | public function reset($pos = null){
if(\is_int($pos)){
$this->offsetSet($pos, false);
}
else{
$this->_List = ArrayList::repeat(false, $this->count());
}
} | php | public function reset($pos = null){
if(\is_int($pos)){
$this->offsetSet($pos, false);
}
else{
$this->_List = ArrayList::repeat(false, $this->count());
}
} | [
"public",
"function",
"reset",
"(",
"$",
"pos",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"pos",
")",
")",
"{",
"$",
"this",
"->",
"offsetSet",
"(",
"$",
"pos",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_List",
"=",
"ArrayList",
"::",
"repeat",
"(",
"false",
",",
"$",
"this",
"->",
"count",
"(",
")",
")",
";",
"}",
"}"
] | Resets all bits or one specific bit by position
@param int $pos optional | [
"Resets",
"all",
"bits",
"or",
"one",
"specific",
"bit",
"by",
"position"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L245-L254 |
9,033 | dazarobbo/Cola | src/BitSet.php | BitSet.set | public function set($pos, $value){
if(!\is_bool($value)){
throw new \InvalidArgumentException('$value is not a bool');
}
$this->offsetSet($pos, $value);
} | php | public function set($pos, $value){
if(!\is_bool($value)){
throw new \InvalidArgumentException('$value is not a bool');
}
$this->offsetSet($pos, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\\",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$value is not a bool'",
")",
";",
"}",
"$",
"this",
"->",
"offsetSet",
"(",
"$",
"pos",
",",
"$",
"value",
")",
";",
"}"
] | Sets a specific bit
@param int $pos
@param bool $value | [
"Sets",
"a",
"specific",
"bit"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitSet.php#L261-L269 |
9,034 | SetBased/php-abc-phing | src/Task/OptimizeCssTask.php | OptimizeCssTask.minimizeResource | protected function minimizeResource(string $resource, ?string $fullPathName): string
{
// If $theFullPathName is not set $resource is concatenation of 2 or more optimized CSS file. There is no need to
// convert relative paths and minimized $resource again. Moreover, it is not possible to convert relative paths
// since $resource can be a concatenation of CSS files from different subdirectories.
if (isset($fullPathName))
{
$css = $this->convertRelativePaths($resource, $fullPathName);
list($std_out, $std_err) = $this->runProcess($this->minifyCommand, $css);
if ($std_err) $this->logInfo($std_err);
$ret = $std_out;
}
else
{
$ret = $resource;
}
return $ret;
} | php | protected function minimizeResource(string $resource, ?string $fullPathName): string
{
// If $theFullPathName is not set $resource is concatenation of 2 or more optimized CSS file. There is no need to
// convert relative paths and minimized $resource again. Moreover, it is not possible to convert relative paths
// since $resource can be a concatenation of CSS files from different subdirectories.
if (isset($fullPathName))
{
$css = $this->convertRelativePaths($resource, $fullPathName);
list($std_out, $std_err) = $this->runProcess($this->minifyCommand, $css);
if ($std_err) $this->logInfo($std_err);
$ret = $std_out;
}
else
{
$ret = $resource;
}
return $ret;
} | [
"protected",
"function",
"minimizeResource",
"(",
"string",
"$",
"resource",
",",
"?",
"string",
"$",
"fullPathName",
")",
":",
"string",
"{",
"// If $theFullPathName is not set $resource is concatenation of 2 or more optimized CSS file. There is no need to",
"// convert relative paths and minimized $resource again. Moreover, it is not possible to convert relative paths",
"// since $resource can be a concatenation of CSS files from different subdirectories.",
"if",
"(",
"isset",
"(",
"$",
"fullPathName",
")",
")",
"{",
"$",
"css",
"=",
"$",
"this",
"->",
"convertRelativePaths",
"(",
"$",
"resource",
",",
"$",
"fullPathName",
")",
";",
"list",
"(",
"$",
"std_out",
",",
"$",
"std_err",
")",
"=",
"$",
"this",
"->",
"runProcess",
"(",
"$",
"this",
"->",
"minifyCommand",
",",
"$",
"css",
")",
";",
"if",
"(",
"$",
"std_err",
")",
"$",
"this",
"->",
"logInfo",
"(",
"$",
"std_err",
")",
";",
"$",
"ret",
"=",
"$",
"std_out",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"resource",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Minimizes CSS code.
@param string $resource The CSS code.
@param string|null $fullPathName The full pathname of the CSS file.
@return string The minimized CSS code. | [
"Minimizes",
"CSS",
"code",
"."
] | eb3d337ceafa7c1ae0caa5b70074dfea03d94017 | https://github.com/SetBased/php-abc-phing/blob/eb3d337ceafa7c1ae0caa5b70074dfea03d94017/src/Task/OptimizeCssTask.php#L77-L98 |
9,035 | SetBased/php-abc-phing | src/Task/OptimizeCssTask.php | OptimizeCssTask.convertRelativePaths | private function convertRelativePaths($css, $fullPathName)
{
// Note: URLs like url(test/test(1).jpg) i.e. URL with ( or ) in name, or not supported.
// The pcre.backtrack_limit option can trigger a NULL return, with no errors. To prevent we reach this limit we
// split the CSS into an array of lines.
$lines = explode("\n", $css);
$lines = preg_replace_callback('/(url\([\'"]?)(([^()]|(?R))+)([\'"]?\))/i',
function ($matches) use ($fullPathName) {
return $matches[1].Url::combine($this->getPathInResources($fullPathName), $matches[2]).$matches[4];
},
$lines);
if ($lines===null)
{
$this->logError("Converting relative paths failed for '%s'", $fullPathName);
}
return implode("\n", $lines);
} | php | private function convertRelativePaths($css, $fullPathName)
{
// Note: URLs like url(test/test(1).jpg) i.e. URL with ( or ) in name, or not supported.
// The pcre.backtrack_limit option can trigger a NULL return, with no errors. To prevent we reach this limit we
// split the CSS into an array of lines.
$lines = explode("\n", $css);
$lines = preg_replace_callback('/(url\([\'"]?)(([^()]|(?R))+)([\'"]?\))/i',
function ($matches) use ($fullPathName) {
return $matches[1].Url::combine($this->getPathInResources($fullPathName), $matches[2]).$matches[4];
},
$lines);
if ($lines===null)
{
$this->logError("Converting relative paths failed for '%s'", $fullPathName);
}
return implode("\n", $lines);
} | [
"private",
"function",
"convertRelativePaths",
"(",
"$",
"css",
",",
"$",
"fullPathName",
")",
"{",
"// Note: URLs like url(test/test(1).jpg) i.e. URL with ( or ) in name, or not supported.",
"// The pcre.backtrack_limit option can trigger a NULL return, with no errors. To prevent we reach this limit we",
"// split the CSS into an array of lines.",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"css",
")",
";",
"$",
"lines",
"=",
"preg_replace_callback",
"(",
"'/(url\\([\\'\"]?)(([^()]|(?R))+)([\\'\"]?\\))/i'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"fullPathName",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
".",
"Url",
"::",
"combine",
"(",
"$",
"this",
"->",
"getPathInResources",
"(",
"$",
"fullPathName",
")",
",",
"$",
"matches",
"[",
"2",
"]",
")",
".",
"$",
"matches",
"[",
"4",
"]",
";",
"}",
",",
"$",
"lines",
")",
";",
"if",
"(",
"$",
"lines",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"logError",
"(",
"\"Converting relative paths failed for '%s'\"",
",",
"$",
"fullPathName",
")",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
";",
"}"
] | In CSS code replace relative paths with absolute paths.
@param string $css The CSS code.
@param string $fullPathName The full pathname of the CSS file.
@return string The modified CSS code. | [
"In",
"CSS",
"code",
"replace",
"relative",
"paths",
"with",
"absolute",
"paths",
"."
] | eb3d337ceafa7c1ae0caa5b70074dfea03d94017 | https://github.com/SetBased/php-abc-phing/blob/eb3d337ceafa7c1ae0caa5b70074dfea03d94017/src/Task/OptimizeCssTask.php#L264-L284 |
9,036 | air-php/view | src/ViewFactory.php | ViewFactory.find | protected function find($fileName)
{
$fileName = $fileName . '.' . $this->fileExtension;
foreach ($this->viewPaths as $path) {
if (file_exists($path . $fileName)) {
return realpath($path . $fileName);
}
}
throw new \Exception("View $fileName not found.");
} | php | protected function find($fileName)
{
$fileName = $fileName . '.' . $this->fileExtension;
foreach ($this->viewPaths as $path) {
if (file_exists($path . $fileName)) {
return realpath($path . $fileName);
}
}
throw new \Exception("View $fileName not found.");
} | [
"protected",
"function",
"find",
"(",
"$",
"fileName",
")",
"{",
"$",
"fileName",
"=",
"$",
"fileName",
".",
"'.'",
".",
"$",
"this",
"->",
"fileExtension",
";",
"foreach",
"(",
"$",
"this",
"->",
"viewPaths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
".",
"$",
"fileName",
")",
")",
"{",
"return",
"realpath",
"(",
"$",
"path",
".",
"$",
"fileName",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"View $fileName not found.\"",
")",
";",
"}"
] | Locates a view file and returns its full path.
@param string $fileName The file name.
@return string|false The location of the file, or false if it cannot be found.
@throws \Exception | [
"Locates",
"a",
"view",
"file",
"and",
"returns",
"its",
"full",
"path",
"."
] | b234ab3ab78ff59d5267e84dbac095b36ecb991a | https://github.com/air-php/view/blob/b234ab3ab78ff59d5267e84dbac095b36ecb991a/src/ViewFactory.php#L63-L74 |
9,037 | cerad/jwt | JwtCoder.php | JwtCoder.sign | protected function sign($msg, $key, $method = 'HS256')
{
if (empty(self::$methods[$method])) {
throw new \DomainException('Algorithm not supported');
}
list($function, $algo) = self::$methods[$method];
switch($function)
{
case 'hash_hmac': return hash_hmac($algo, $msg, $key, true);
case 'openssl':
$signature = '';
$success = openssl_sign($msg, $signature, $key, $algo);
if(!$success) {
throw new \DomainException("OpenSSL unable to sign data");
}
return $signature;
}
return ''; // Should not get here
} | php | protected function sign($msg, $key, $method = 'HS256')
{
if (empty(self::$methods[$method])) {
throw new \DomainException('Algorithm not supported');
}
list($function, $algo) = self::$methods[$method];
switch($function)
{
case 'hash_hmac': return hash_hmac($algo, $msg, $key, true);
case 'openssl':
$signature = '';
$success = openssl_sign($msg, $signature, $key, $algo);
if(!$success) {
throw new \DomainException("OpenSSL unable to sign data");
}
return $signature;
}
return ''; // Should not get here
} | [
"protected",
"function",
"sign",
"(",
"$",
"msg",
",",
"$",
"key",
",",
"$",
"method",
"=",
"'HS256'",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"methods",
"[",
"$",
"method",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Algorithm not supported'",
")",
";",
"}",
"list",
"(",
"$",
"function",
",",
"$",
"algo",
")",
"=",
"self",
"::",
"$",
"methods",
"[",
"$",
"method",
"]",
";",
"switch",
"(",
"$",
"function",
")",
"{",
"case",
"'hash_hmac'",
":",
"return",
"hash_hmac",
"(",
"$",
"algo",
",",
"$",
"msg",
",",
"$",
"key",
",",
"true",
")",
";",
"case",
"'openssl'",
":",
"$",
"signature",
"=",
"''",
";",
"$",
"success",
"=",
"openssl_sign",
"(",
"$",
"msg",
",",
"$",
"signature",
",",
"$",
"key",
",",
"$",
"algo",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"\"OpenSSL unable to sign data\"",
")",
";",
"}",
"return",
"$",
"signature",
";",
"}",
"return",
"''",
";",
"// Should not get here",
"}"
] | Sign a string with a given key and algorithm.
@param string $msg The message to sign
@param string|resource $key The secret key
@param string $method The signing algorithm. Supported algorithms
are 'HS256', 'HS384', 'HS512' and 'RS256'
@return string An encrypted message
@throws \DomainException Unsupported algorithm was specified | [
"Sign",
"a",
"string",
"with",
"a",
"given",
"key",
"and",
"algorithm",
"."
] | ec878f0ff3b87cc4ada7d3a36e4f3ed935e32aff | https://github.com/cerad/jwt/blob/ec878f0ff3b87cc4ada7d3a36e4f3ed935e32aff/JwtCoder.php#L125-L145 |
9,038 | cerad/jwt | JwtCoder.php | JwtCoder.verifySignature | protected function verifySignature($msg, $signature, $key, $method = 'HS256')
{
if (empty(self::$methods[$method])) {
throw new \DomainException('Algorithm not supported');
}
list($function, $algo) = self::$methods[$method];
switch($function) {
case 'openssl':
$success = openssl_verify($msg, $signature, $key, $algo);
if(!$success) {
throw new \DomainException("OpenSSL unable to verify data: " . openssl_error_string());
}
return $signature;
case 'hash_hmac':
default:
return $signature === hash_hmac($algo, $msg, $key, true);
}
} | php | protected function verifySignature($msg, $signature, $key, $method = 'HS256')
{
if (empty(self::$methods[$method])) {
throw new \DomainException('Algorithm not supported');
}
list($function, $algo) = self::$methods[$method];
switch($function) {
case 'openssl':
$success = openssl_verify($msg, $signature, $key, $algo);
if(!$success) {
throw new \DomainException("OpenSSL unable to verify data: " . openssl_error_string());
}
return $signature;
case 'hash_hmac':
default:
return $signature === hash_hmac($algo, $msg, $key, true);
}
} | [
"protected",
"function",
"verifySignature",
"(",
"$",
"msg",
",",
"$",
"signature",
",",
"$",
"key",
",",
"$",
"method",
"=",
"'HS256'",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"methods",
"[",
"$",
"method",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Algorithm not supported'",
")",
";",
"}",
"list",
"(",
"$",
"function",
",",
"$",
"algo",
")",
"=",
"self",
"::",
"$",
"methods",
"[",
"$",
"method",
"]",
";",
"switch",
"(",
"$",
"function",
")",
"{",
"case",
"'openssl'",
":",
"$",
"success",
"=",
"openssl_verify",
"(",
"$",
"msg",
",",
"$",
"signature",
",",
"$",
"key",
",",
"$",
"algo",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"\"OpenSSL unable to verify data: \"",
".",
"openssl_error_string",
"(",
")",
")",
";",
"}",
"return",
"$",
"signature",
";",
"case",
"'hash_hmac'",
":",
"default",
":",
"return",
"$",
"signature",
"===",
"hash_hmac",
"(",
"$",
"algo",
",",
"$",
"msg",
",",
"$",
"key",
",",
"true",
")",
";",
"}",
"}"
] | Verify a signature with the mesage, key and method. Not all methods
are symmetric, so we must have a separate verify and sign method.
@param string $msg the original message
@param string $signature
@param string|resource $key for HS*, a string key works. for RS*, must be a resource of an openssl public key
@param string $method
@return bool
@throws \DomainException Invalid Algorithm or OpenSSL failure | [
"Verify",
"a",
"signature",
"with",
"the",
"mesage",
"key",
"and",
"method",
".",
"Not",
"all",
"methods",
"are",
"symmetric",
"so",
"we",
"must",
"have",
"a",
"separate",
"verify",
"and",
"sign",
"method",
"."
] | ec878f0ff3b87cc4ada7d3a36e4f3ed935e32aff | https://github.com/cerad/jwt/blob/ec878f0ff3b87cc4ada7d3a36e4f3ed935e32aff/JwtCoder.php#L157-L175 |
9,039 | harvestcloud/CoreBundle | Repository/ProductRepository.php | ProductRepository.findForSearchFilter | public function findForSearchFilter(ProductFilter $filter, OrderCollection $orderCollection = null)
{
$qb = $this->getEntityManager()->createQueryBuilder()
->from('HarvestCloudCoreBundle:Product', 'p')
->select('p')
->addSelect('GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance')
->setParameter('latitude', $filter->getLatitude())
->setParameter('longitude', $filter->getLongitude())
->orderBy('distance')
->setMaxResults(20)
;
if ($filter->getRange())
{
$qb->where('GEO(p.latitude = :latitude, p.longitude = :longitude) <= :range');
$qb->setParameter('range', $filter->getRange());
}
if ($filter->getCategory())
{
$qb->join('p.category', 'c');
$qb->andWhere('c.lft >= :lft');
$qb->andWhere('c.rgt <= :rgt');
$qb->setParameter('lft', $filter->getCategory()->getLft());
$qb->setParameter('rgt', $filter->getCategory()->getRgt());
}
$qb->andWhere('p.quantity_available > 0');
$q = $qb->getQuery();
$products = $q->execute();
if ($orderCollection)
{
// Set quantity in cart
$lineItemQuantities = $orderCollection->getLineItemQuantitiesIndexedByProductId();
foreach ($products as $product)
{
$id = $product[0]->getId();
if (array_key_exists($id, $lineItemQuantities))
{
$product[0]->setQuantityInCart($lineItemQuantities[$id]);
}
}
}
return $products;
} | php | public function findForSearchFilter(ProductFilter $filter, OrderCollection $orderCollection = null)
{
$qb = $this->getEntityManager()->createQueryBuilder()
->from('HarvestCloudCoreBundle:Product', 'p')
->select('p')
->addSelect('GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance')
->setParameter('latitude', $filter->getLatitude())
->setParameter('longitude', $filter->getLongitude())
->orderBy('distance')
->setMaxResults(20)
;
if ($filter->getRange())
{
$qb->where('GEO(p.latitude = :latitude, p.longitude = :longitude) <= :range');
$qb->setParameter('range', $filter->getRange());
}
if ($filter->getCategory())
{
$qb->join('p.category', 'c');
$qb->andWhere('c.lft >= :lft');
$qb->andWhere('c.rgt <= :rgt');
$qb->setParameter('lft', $filter->getCategory()->getLft());
$qb->setParameter('rgt', $filter->getCategory()->getRgt());
}
$qb->andWhere('p.quantity_available > 0');
$q = $qb->getQuery();
$products = $q->execute();
if ($orderCollection)
{
// Set quantity in cart
$lineItemQuantities = $orderCollection->getLineItemQuantitiesIndexedByProductId();
foreach ($products as $product)
{
$id = $product[0]->getId();
if (array_key_exists($id, $lineItemQuantities))
{
$product[0]->setQuantityInCart($lineItemQuantities[$id]);
}
}
}
return $products;
} | [
"public",
"function",
"findForSearchFilter",
"(",
"ProductFilter",
"$",
"filter",
",",
"OrderCollection",
"$",
"orderCollection",
"=",
"null",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
"->",
"from",
"(",
"'HarvestCloudCoreBundle:Product'",
",",
"'p'",
")",
"->",
"select",
"(",
"'p'",
")",
"->",
"addSelect",
"(",
"'GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance'",
")",
"->",
"setParameter",
"(",
"'latitude'",
",",
"$",
"filter",
"->",
"getLatitude",
"(",
")",
")",
"->",
"setParameter",
"(",
"'longitude'",
",",
"$",
"filter",
"->",
"getLongitude",
"(",
")",
")",
"->",
"orderBy",
"(",
"'distance'",
")",
"->",
"setMaxResults",
"(",
"20",
")",
";",
"if",
"(",
"$",
"filter",
"->",
"getRange",
"(",
")",
")",
"{",
"$",
"qb",
"->",
"where",
"(",
"'GEO(p.latitude = :latitude, p.longitude = :longitude) <= :range'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'range'",
",",
"$",
"filter",
"->",
"getRange",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"filter",
"->",
"getCategory",
"(",
")",
")",
"{",
"$",
"qb",
"->",
"join",
"(",
"'p.category'",
",",
"'c'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'c.lft >= :lft'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'c.rgt <= :rgt'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'lft'",
",",
"$",
"filter",
"->",
"getCategory",
"(",
")",
"->",
"getLft",
"(",
")",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"'rgt'",
",",
"$",
"filter",
"->",
"getCategory",
"(",
")",
"->",
"getRgt",
"(",
")",
")",
";",
"}",
"$",
"qb",
"->",
"andWhere",
"(",
"'p.quantity_available > 0'",
")",
";",
"$",
"q",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
";",
"$",
"products",
"=",
"$",
"q",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"orderCollection",
")",
"{",
"// Set quantity in cart",
"$",
"lineItemQuantities",
"=",
"$",
"orderCollection",
"->",
"getLineItemQuantitiesIndexedByProductId",
"(",
")",
";",
"foreach",
"(",
"$",
"products",
"as",
"$",
"product",
")",
"{",
"$",
"id",
"=",
"$",
"product",
"[",
"0",
"]",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"lineItemQuantities",
")",
")",
"{",
"$",
"product",
"[",
"0",
"]",
"->",
"setQuantityInCart",
"(",
"$",
"lineItemQuantities",
"[",
"$",
"id",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"products",
";",
"}"
] | Find Products for a given filter
@author Tom Haskins-Vaughan <[email protected]>
@since 2012-04-15
@todo Create SearchFilter class
@param ProductFilter $filter
@param OrderCollection $orderCollection | [
"Find",
"Products",
"for",
"a",
"given",
"filter"
] | f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc | https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Repository/ProductRepository.php#L32-L83 |
9,040 | harvestcloud/CoreBundle | Repository/ProductRepository.php | ProductRepository.BaseGeoProductQuery | public function BaseGeoProductQuery(LatLng $latLng)
{
$products = $this->getEntityManager()->createQueryBuilder()
->from('HarvestCloudCoreBundle:Product', 'p')
->select('p')
->addSelect('GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance')
->setParameter('latitude', $latitude)
->setParameter('longitude', $longitude)
->orderBy('distance')
->where('GEO(p.latitude = :latitude, p.longitude = :longitude) <= 50')
->getQuery()
->execute();
return $products;
} | php | public function BaseGeoProductQuery(LatLng $latLng)
{
$products = $this->getEntityManager()->createQueryBuilder()
->from('HarvestCloudCoreBundle:Product', 'p')
->select('p')
->addSelect('GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance')
->setParameter('latitude', $latitude)
->setParameter('longitude', $longitude)
->orderBy('distance')
->where('GEO(p.latitude = :latitude, p.longitude = :longitude) <= 50')
->getQuery()
->execute();
return $products;
} | [
"public",
"function",
"BaseGeoProductQuery",
"(",
"LatLng",
"$",
"latLng",
")",
"{",
"$",
"products",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
"->",
"from",
"(",
"'HarvestCloudCoreBundle:Product'",
",",
"'p'",
")",
"->",
"select",
"(",
"'p'",
")",
"->",
"addSelect",
"(",
"'GEO(p.latitude = :latitude, p.longitude = :longitude) AS distance'",
")",
"->",
"setParameter",
"(",
"'latitude'",
",",
"$",
"latitude",
")",
"->",
"setParameter",
"(",
"'longitude'",
",",
"$",
"longitude",
")",
"->",
"orderBy",
"(",
"'distance'",
")",
"->",
"where",
"(",
"'GEO(p.latitude = :latitude, p.longitude = :longitude) <= 50'",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"products",
";",
"}"
] | Base Geographical Product Query
@author Tom Haskins-Vaughan <[email protected]>
@since 2012-04-15
@todo Create SearchFilter class
@param LatLng $latLng | [
"Base",
"Geographical",
"Product",
"Query"
] | f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc | https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Repository/ProductRepository.php#L94-L108 |
9,041 | springimport/magento2-module-restapi-filters | Controller/Rest.php | Rest.getDeploymentConfig | private function getDeploymentConfig()
{
if (!$this->deploymentConfig instanceof \Magento\Framework\App\DeploymentConfig) {
$this->deploymentConfig = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\DeploymentConfig');
}
return $this->deploymentConfig;
} | php | private function getDeploymentConfig()
{
if (!$this->deploymentConfig instanceof \Magento\Framework\App\DeploymentConfig) {
$this->deploymentConfig = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\DeploymentConfig');
}
return $this->deploymentConfig;
} | [
"private",
"function",
"getDeploymentConfig",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deploymentConfig",
"instanceof",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"App",
"\\",
"DeploymentConfig",
")",
"{",
"$",
"this",
"->",
"deploymentConfig",
"=",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"App",
"\\",
"ObjectManager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"'Magento\\Framework\\App\\DeploymentConfig'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"deploymentConfig",
";",
"}"
] | Get deployment config
@return DeploymentConfig | [
"Get",
"deployment",
"config"
] | 7206ac0ab20e8d435578be0e09e484a4b14f29a9 | https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Controller/Rest.php#L92-L99 |
9,042 | springimport/magento2-module-restapi-filters | Controller/Rest.php | Rest.processApiRequest | protected function processApiRequest()
{
$inputParams = $this->getInputParamsResolver()->resolve();
$route = $this->getInputParamsResolver()->getRoute();
$serviceMethodName = $route->getServiceMethod();
$serviceClassName = $route->getServiceClass();
$service = $this->_objectManager->get($serviceClassName);
/** @var \Magento\Framework\Api\AbstractExtensibleObject $outputData */
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
$outputData = $this->serviceOutputProcessor->process(
$outputData,
$serviceClassName,
$serviceMethodName
);
$filters = $this->getFilters();
if ($filters && is_array($outputData)) {
foreach ($filters as $filterClassName) {
$outputData = $this->applyFilter($filterClassName, $outputData);
}
}
$header = $this->getDeploymentConfig()->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT);
if ($header) {
$this->_response->setHeader('X-Frame-Options', $header);
}
$this->_response->prepareResponse($outputData);
} | php | protected function processApiRequest()
{
$inputParams = $this->getInputParamsResolver()->resolve();
$route = $this->getInputParamsResolver()->getRoute();
$serviceMethodName = $route->getServiceMethod();
$serviceClassName = $route->getServiceClass();
$service = $this->_objectManager->get($serviceClassName);
/** @var \Magento\Framework\Api\AbstractExtensibleObject $outputData */
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
$outputData = $this->serviceOutputProcessor->process(
$outputData,
$serviceClassName,
$serviceMethodName
);
$filters = $this->getFilters();
if ($filters && is_array($outputData)) {
foreach ($filters as $filterClassName) {
$outputData = $this->applyFilter($filterClassName, $outputData);
}
}
$header = $this->getDeploymentConfig()->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT);
if ($header) {
$this->_response->setHeader('X-Frame-Options', $header);
}
$this->_response->prepareResponse($outputData);
} | [
"protected",
"function",
"processApiRequest",
"(",
")",
"{",
"$",
"inputParams",
"=",
"$",
"this",
"->",
"getInputParamsResolver",
"(",
")",
"->",
"resolve",
"(",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"getInputParamsResolver",
"(",
")",
"->",
"getRoute",
"(",
")",
";",
"$",
"serviceMethodName",
"=",
"$",
"route",
"->",
"getServiceMethod",
"(",
")",
";",
"$",
"serviceClassName",
"=",
"$",
"route",
"->",
"getServiceClass",
"(",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"_objectManager",
"->",
"get",
"(",
"$",
"serviceClassName",
")",
";",
"/** @var \\Magento\\Framework\\Api\\AbstractExtensibleObject $outputData */",
"$",
"outputData",
"=",
"call_user_func_array",
"(",
"[",
"$",
"service",
",",
"$",
"serviceMethodName",
"]",
",",
"$",
"inputParams",
")",
";",
"$",
"outputData",
"=",
"$",
"this",
"->",
"serviceOutputProcessor",
"->",
"process",
"(",
"$",
"outputData",
",",
"$",
"serviceClassName",
",",
"$",
"serviceMethodName",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"getFilters",
"(",
")",
";",
"if",
"(",
"$",
"filters",
"&&",
"is_array",
"(",
"$",
"outputData",
")",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filterClassName",
")",
"{",
"$",
"outputData",
"=",
"$",
"this",
"->",
"applyFilter",
"(",
"$",
"filterClassName",
",",
"$",
"outputData",
")",
";",
"}",
"}",
"$",
"header",
"=",
"$",
"this",
"->",
"getDeploymentConfig",
"(",
")",
"->",
"get",
"(",
"ConfigOptionsListConstants",
"::",
"CONFIG_PATH_X_FRAME_OPT",
")",
";",
"if",
"(",
"$",
"header",
")",
"{",
"$",
"this",
"->",
"_response",
"->",
"setHeader",
"(",
"'X-Frame-Options'",
",",
"$",
"header",
")",
";",
"}",
"$",
"this",
"->",
"_response",
"->",
"prepareResponse",
"(",
"$",
"outputData",
")",
";",
"}"
] | Execute API request
@return void
@throws AuthorizationException
@throws \Magento\Framework\Exception\InputException
@throws \Magento\Framework\Webapi\Exception | [
"Execute",
"API",
"request"
] | 7206ac0ab20e8d435578be0e09e484a4b14f29a9 | https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Controller/Rest.php#L109-L136 |
9,043 | springimport/magento2-module-restapi-filters | Controller/Rest.php | Rest.getInputParamsResolver | private function getInputParamsResolver()
{
if ($this->inputParamsResolver === null) {
$this->inputParamsResolver = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Webapi\Controller\Rest\InputParamsResolver::class);
}
return $this->inputParamsResolver;
} | php | private function getInputParamsResolver()
{
if ($this->inputParamsResolver === null) {
$this->inputParamsResolver = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Webapi\Controller\Rest\InputParamsResolver::class);
}
return $this->inputParamsResolver;
} | [
"private",
"function",
"getInputParamsResolver",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inputParamsResolver",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"inputParamsResolver",
"=",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"App",
"\\",
"ObjectManager",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"\\",
"Magento",
"\\",
"Webapi",
"\\",
"Controller",
"\\",
"Rest",
"\\",
"InputParamsResolver",
"::",
"class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"inputParamsResolver",
";",
"}"
] | The getter function to get InputParamsResolver object
@return \Magento\Webapi\Controller\Rest\InputParamsResolver
@deprecated | [
"The",
"getter",
"function",
"to",
"get",
"InputParamsResolver",
"object"
] | 7206ac0ab20e8d435578be0e09e484a4b14f29a9 | https://github.com/springimport/magento2-module-restapi-filters/blob/7206ac0ab20e8d435578be0e09e484a4b14f29a9/Controller/Rest.php#L174-L181 |
9,044 | Etenil/atlatl | src/core.php | Core.php_error_handler | public function php_error_handler($errno, $errstr, $errfile, $errline)
{
$e = new \Exception($errstr, $errno);
call_user_func($this->error50x, $e);
} | php | public function php_error_handler($errno, $errstr, $errfile, $errline)
{
$e = new \Exception($errstr, $errno);
call_user_func($this->error50x, $e);
} | [
"public",
"function",
"php_error_handler",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"$",
"e",
"=",
"new",
"\\",
"Exception",
"(",
"$",
"errstr",
",",
"$",
"errno",
")",
";",
"call_user_func",
"(",
"$",
"this",
"->",
"error50x",
",",
"$",
"e",
")",
";",
"}"
] | Wrapper that converts PHP errors to exceptions and passes them
to the standard error50x handler. | [
"Wrapper",
"that",
"converts",
"PHP",
"errors",
"to",
"exceptions",
"and",
"passes",
"them",
"to",
"the",
"standard",
"error50x",
"handler",
"."
] | fe7ae0d1a68821c9156074a6df74ddd3d6c0316a | https://github.com/Etenil/atlatl/blob/fe7ae0d1a68821c9156074a6df74ddd3d6c0316a/src/core.php#L106-L110 |
9,045 | Etenil/atlatl | src/core.php | Core.setPrefix | public function setPrefix($prefix)
{
// We ensure that the prefix is properly formatted. It
// must start with a '/' and end without one.
if($prefix != "") {
if($prefix[0] != '/') {
$prefix = '/' . $prefix;
}
if($prefix[strlen($prefix) - 1] == '/') {
$prefix = substr($prefix, 0, strlen($prefix) - 1);
}
}
$this->prefix = $prefix;
return $this;
} | php | public function setPrefix($prefix)
{
// We ensure that the prefix is properly formatted. It
// must start with a '/' and end without one.
if($prefix != "") {
if($prefix[0] != '/') {
$prefix = '/' . $prefix;
}
if($prefix[strlen($prefix) - 1] == '/') {
$prefix = substr($prefix, 0, strlen($prefix) - 1);
}
}
$this->prefix = $prefix;
return $this;
} | [
"public",
"function",
"setPrefix",
"(",
"$",
"prefix",
")",
"{",
"// We ensure that the prefix is properly formatted. It",
"// must start with a '/' and end without one.",
"if",
"(",
"$",
"prefix",
"!=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"prefix",
"[",
"0",
"]",
"!=",
"'/'",
")",
"{",
"$",
"prefix",
"=",
"'/'",
".",
"$",
"prefix",
";",
"}",
"if",
"(",
"$",
"prefix",
"[",
"strlen",
"(",
"$",
"prefix",
")",
"-",
"1",
"]",
"==",
"'/'",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"prefix",
",",
"0",
",",
"strlen",
"(",
"$",
"prefix",
")",
"-",
"1",
")",
";",
"}",
"}",
"$",
"this",
"->",
"prefix",
"=",
"$",
"prefix",
";",
"return",
"$",
"this",
";",
"}"
] | Changes the URL prefix to work from.
@param string $prefix is the URL prefix to use, for instance "/glue".
@return this object (you can make a call chain). | [
"Changes",
"the",
"URL",
"prefix",
"to",
"work",
"from",
"."
] | fe7ae0d1a68821c9156074a6df74ddd3d6c0316a | https://github.com/Etenil/atlatl/blob/fe7ae0d1a68821c9156074a6df74ddd3d6c0316a/src/core.php#L137-L152 |
9,046 | Etenil/atlatl | src/core.php | Core.serve | function serve(array $urls)
{
$_SESSION['toto'] = 'prout';
$response = null;
// Registering PHP error handlers.
set_error_handler(array($this, 'php_error_handler'), E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR);
try {
$handler = $this->route($urls);
$response = $this->process($handler);
$this->display($response);
}
catch(HttpRedirect $r) {
$response = Injector::give('Response');
$response->setHeader('Location', $r->getUrl());
}
catch(HTTPClientError $e) {
$response = call_user_func($this->error40x, $e);
}
catch(HTTPServerError $e) {
$response = call_user_func($this->error50x, $e);
}
// Generic HTTP status response.
catch(HTTPStatus $s) {
$response = Injector::give('Response', $s->getMessage(), $s->getCode());
}
// Generic error.
catch(\Exception $e) {
$response = call_user_func($this->error50x, $e);
}
} | php | function serve(array $urls)
{
$_SESSION['toto'] = 'prout';
$response = null;
// Registering PHP error handlers.
set_error_handler(array($this, 'php_error_handler'), E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR);
try {
$handler = $this->route($urls);
$response = $this->process($handler);
$this->display($response);
}
catch(HttpRedirect $r) {
$response = Injector::give('Response');
$response->setHeader('Location', $r->getUrl());
}
catch(HTTPClientError $e) {
$response = call_user_func($this->error40x, $e);
}
catch(HTTPServerError $e) {
$response = call_user_func($this->error50x, $e);
}
// Generic HTTP status response.
catch(HTTPStatus $s) {
$response = Injector::give('Response', $s->getMessage(), $s->getCode());
}
// Generic error.
catch(\Exception $e) {
$response = call_user_func($this->error50x, $e);
}
} | [
"function",
"serve",
"(",
"array",
"$",
"urls",
")",
"{",
"$",
"_SESSION",
"[",
"'toto'",
"]",
"=",
"'prout'",
";",
"$",
"response",
"=",
"null",
";",
"// Registering PHP error handlers.",
"set_error_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'php_error_handler'",
")",
",",
"E_ERROR",
"|",
"E_PARSE",
"|",
"E_CORE_ERROR",
"|",
"E_COMPILE_ERROR",
")",
";",
"try",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"route",
"(",
"$",
"urls",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"process",
"(",
"$",
"handler",
")",
";",
"$",
"this",
"->",
"display",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"HttpRedirect",
"$",
"r",
")",
"{",
"$",
"response",
"=",
"Injector",
"::",
"give",
"(",
"'Response'",
")",
";",
"$",
"response",
"->",
"setHeader",
"(",
"'Location'",
",",
"$",
"r",
"->",
"getUrl",
"(",
")",
")",
";",
"}",
"catch",
"(",
"HTTPClientError",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"error40x",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"HTTPServerError",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"error50x",
",",
"$",
"e",
")",
";",
"}",
"// Generic HTTP status response.",
"catch",
"(",
"HTTPStatus",
"$",
"s",
")",
"{",
"$",
"response",
"=",
"Injector",
"::",
"give",
"(",
"'Response'",
",",
"$",
"s",
"->",
"getMessage",
"(",
")",
",",
"$",
"s",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"// Generic error.",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"error50x",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Serves the requests.
@param array $urls is an associative arrays of regexes and
callbacks for routing. | [
"Serves",
"the",
"requests",
"."
] | fe7ae0d1a68821c9156074a6df74ddd3d6c0316a | https://github.com/Etenil/atlatl/blob/fe7ae0d1a68821c9156074a6df74ddd3d6c0316a/src/core.php#L159-L190 |
9,047 | Etenil/atlatl | src/core.php | Core.display | protected function display($response) {
// TODO get rid of backwards compat here.
if($response->alteredSession()) {
$this->request->setAllSession($response->getAllSession());
}
if($response->alteredCookies()) {
$this->request->setAllCookies($response->getAllCookies());
}
$this->request->commitSessionAndCookies();
if(is_object($response)) {
$response->compile();
} else {
echo $response;
}
} | php | protected function display($response) {
// TODO get rid of backwards compat here.
if($response->alteredSession()) {
$this->request->setAllSession($response->getAllSession());
}
if($response->alteredCookies()) {
$this->request->setAllCookies($response->getAllCookies());
}
$this->request->commitSessionAndCookies();
if(is_object($response)) {
$response->compile();
} else {
echo $response;
}
} | [
"protected",
"function",
"display",
"(",
"$",
"response",
")",
"{",
"// TODO get rid of backwards compat here.",
"if",
"(",
"$",
"response",
"->",
"alteredSession",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"setAllSession",
"(",
"$",
"response",
"->",
"getAllSession",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"alteredCookies",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"setAllCookies",
"(",
"$",
"response",
"->",
"getAllCookies",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"request",
"->",
"commitSessionAndCookies",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"response",
")",
")",
"{",
"$",
"response",
"->",
"compile",
"(",
")",
";",
"}",
"else",
"{",
"echo",
"$",
"response",
";",
"}",
"}"
] | Processes the returned object from a handler. | [
"Processes",
"the",
"returned",
"object",
"from",
"a",
"handler",
"."
] | fe7ae0d1a68821c9156074a6df74ddd3d6c0316a | https://github.com/Etenil/atlatl/blob/fe7ae0d1a68821c9156074a6df74ddd3d6c0316a/src/core.php#L195-L209 |
9,048 | Etenil/atlatl | src/core.php | Core.route | protected function route(array $urls) {
$path = $this->server->getRoute();
$call = false; // This will store the controller and method to call
$matches = array(); // And this the extracted parameters.
// First we search for specific method routes.
$method_routes = preg_grep('/^' . $this->server->getMethod() . ':/i', array_keys($urls));
foreach($method_routes as $route) {
$method = $this->server->getMethod() . ':';
$clean_route = substr($route, strlen($method));
if(preg_match('%^'. $clean_route .'/?$%i',
$this->server->getRoute(), $matches)) {
$call = $urls[$route];
break;
}
}
// Do we need to try generic routes?
if(!$call) {
foreach($urls as $regex => $proto) {
if(preg_match('%^'. $regex .'/?$%i',
$this->server->getRoute(), $matches)) {
$call = $proto;
break;
}
}
}
// If we don't have a call at this point, that's a 404.
if(!$call) {
throw new NoRouteException("URL, ".$this->server->getWholeRoute().", not found.");
}
return array('call' => $call, 'params' => $matches);
} | php | protected function route(array $urls) {
$path = $this->server->getRoute();
$call = false; // This will store the controller and method to call
$matches = array(); // And this the extracted parameters.
// First we search for specific method routes.
$method_routes = preg_grep('/^' . $this->server->getMethod() . ':/i', array_keys($urls));
foreach($method_routes as $route) {
$method = $this->server->getMethod() . ':';
$clean_route = substr($route, strlen($method));
if(preg_match('%^'. $clean_route .'/?$%i',
$this->server->getRoute(), $matches)) {
$call = $urls[$route];
break;
}
}
// Do we need to try generic routes?
if(!$call) {
foreach($urls as $regex => $proto) {
if(preg_match('%^'. $regex .'/?$%i',
$this->server->getRoute(), $matches)) {
$call = $proto;
break;
}
}
}
// If we don't have a call at this point, that's a 404.
if(!$call) {
throw new NoRouteException("URL, ".$this->server->getWholeRoute().", not found.");
}
return array('call' => $call, 'params' => $matches);
} | [
"protected",
"function",
"route",
"(",
"array",
"$",
"urls",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"server",
"->",
"getRoute",
"(",
")",
";",
"$",
"call",
"=",
"false",
";",
"// This will store the controller and method to call",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"// And this the extracted parameters.",
"// First we search for specific method routes.",
"$",
"method_routes",
"=",
"preg_grep",
"(",
"'/^'",
".",
"$",
"this",
"->",
"server",
"->",
"getMethod",
"(",
")",
".",
"':/i'",
",",
"array_keys",
"(",
"$",
"urls",
")",
")",
";",
"foreach",
"(",
"$",
"method_routes",
"as",
"$",
"route",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"server",
"->",
"getMethod",
"(",
")",
".",
"':'",
";",
"$",
"clean_route",
"=",
"substr",
"(",
"$",
"route",
",",
"strlen",
"(",
"$",
"method",
")",
")",
";",
"if",
"(",
"preg_match",
"(",
"'%^'",
".",
"$",
"clean_route",
".",
"'/?$%i'",
",",
"$",
"this",
"->",
"server",
"->",
"getRoute",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"call",
"=",
"$",
"urls",
"[",
"$",
"route",
"]",
";",
"break",
";",
"}",
"}",
"// Do we need to try generic routes?",
"if",
"(",
"!",
"$",
"call",
")",
"{",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"regex",
"=>",
"$",
"proto",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'%^'",
".",
"$",
"regex",
".",
"'/?$%i'",
",",
"$",
"this",
"->",
"server",
"->",
"getRoute",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"call",
"=",
"$",
"proto",
";",
"break",
";",
"}",
"}",
"}",
"// If we don't have a call at this point, that's a 404.",
"if",
"(",
"!",
"$",
"call",
")",
"{",
"throw",
"new",
"NoRouteException",
"(",
"\"URL, \"",
".",
"$",
"this",
"->",
"server",
"->",
"getWholeRoute",
"(",
")",
".",
"\", not found.\"",
")",
";",
"}",
"return",
"array",
"(",
"'call'",
"=>",
"$",
"call",
",",
"'params'",
"=>",
"$",
"matches",
")",
";",
"}"
] | Does the actual URL routing.
The main method of the Core class.
@param array $urls The regex-based url to class mapping
@throws NoHandlerException Thrown if corresponding class is not found
@throws NoRouteException Thrown if no match is found
@throws BadMethodCallException Thrown if a corresponding GET,POST is not found | [
"Does",
"the",
"actual",
"URL",
"routing",
"."
] | fe7ae0d1a68821c9156074a6df74ddd3d6c0316a | https://github.com/Etenil/atlatl/blob/fe7ae0d1a68821c9156074a6df74ddd3d6c0316a/src/core.php#L222-L258 |
9,049 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.parse | public static function parse(string $uri): Uri
{
preg_match(static::URI_PATTERN, $uri, $matches);
$components = static::componentsFromMatches($matches);
$scheme = $components['scheme'];
$authority = $components['authority'];
$path = $components['path'];
$query = $components['query'];
$fragment = $components['fragment'];
return new static($path, $scheme, $authority, $query, $fragment);
} | php | public static function parse(string $uri): Uri
{
preg_match(static::URI_PATTERN, $uri, $matches);
$components = static::componentsFromMatches($matches);
$scheme = $components['scheme'];
$authority = $components['authority'];
$path = $components['path'];
$query = $components['query'];
$fragment = $components['fragment'];
return new static($path, $scheme, $authority, $query, $fragment);
} | [
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"uri",
")",
":",
"Uri",
"{",
"preg_match",
"(",
"static",
"::",
"URI_PATTERN",
",",
"$",
"uri",
",",
"$",
"matches",
")",
";",
"$",
"components",
"=",
"static",
"::",
"componentsFromMatches",
"(",
"$",
"matches",
")",
";",
"$",
"scheme",
"=",
"$",
"components",
"[",
"'scheme'",
"]",
";",
"$",
"authority",
"=",
"$",
"components",
"[",
"'authority'",
"]",
";",
"$",
"path",
"=",
"$",
"components",
"[",
"'path'",
"]",
";",
"$",
"query",
"=",
"$",
"components",
"[",
"'query'",
"]",
";",
"$",
"fragment",
"=",
"$",
"components",
"[",
"'fragment'",
"]",
";",
"return",
"new",
"static",
"(",
"$",
"path",
",",
"$",
"scheme",
",",
"$",
"authority",
",",
"$",
"query",
",",
"$",
"fragment",
")",
";",
"}"
] | Creates instance from a URI string
@param string $uri A URI string
@return Uri
@throws DomainException When the URI string is invalid | [
"Creates",
"instance",
"from",
"a",
"URI",
"string"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L199-L211 |
9,050 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.resolve | public static function resolve($base, string $reference, bool $strict = true): Uri
{
if (!($base instanceof self)) {
$base = static::parse($base);
}
preg_match(static::URI_PATTERN, $reference, $matches);
$ref = static::componentsFromMatches($matches);
// http://tools.ietf.org/html/rfc3986#section-5.2.2
// A non-strict parser may ignore a scheme in the reference if it is
// identical to the base URI's scheme
if (!$strict && ($ref['scheme'] !== null && $base->scheme() === $ref['scheme'])) {
$ref['scheme'] = null;
}
if ($ref['scheme'] !== null) {
$scheme = $ref['scheme'];
$authority = $ref['authority'];
$path = static::removeDotSegments($ref['path']);
$query = $ref['query'];
} else {
// http://tools.ietf.org/html/rfc3986#section-3.3
// In addition, a URI reference (Section 4.1) may be a
// relative-path reference, in which case the first path segment
// cannot contain a colon (":") character.
// START: extra check for colon in first segment
$segments = explode('/', trim($ref['path'], '/'));
if (isset($segments[0]) && strpos($segments[0], ':') !== false) {
$message = sprintf('First segment in reference (%s) cannot contain a colon (":")', $reference);
throw new DomainException($message);
}
// END: extra check for colon in first segment
if ($ref['authority'] !== null) {
$authority = $ref['authority'];
$path = static::removeDotSegments($ref['path']);
$query = $ref['query'];
} else {
if ($ref['path'] === '') {
$path = $base->path();
if ($ref['query'] !== null) {
$query = $ref['query'];
} else {
$query = $base->query();
}
} else {
if ($ref['path'][0] === '/') {
$path = static::removeDotSegments($ref['path']);
} else {
$path = static::mergePaths($base, $ref['path']);
$path = static::removeDotSegments($path);
}
$query = $ref['query'];
}
$authority = $base->authority();
}
$scheme = $base->scheme();
}
$fragment = $ref['fragment'];
return new static($path, $scheme, $authority, $query, $fragment);
} | php | public static function resolve($base, string $reference, bool $strict = true): Uri
{
if (!($base instanceof self)) {
$base = static::parse($base);
}
preg_match(static::URI_PATTERN, $reference, $matches);
$ref = static::componentsFromMatches($matches);
// http://tools.ietf.org/html/rfc3986#section-5.2.2
// A non-strict parser may ignore a scheme in the reference if it is
// identical to the base URI's scheme
if (!$strict && ($ref['scheme'] !== null && $base->scheme() === $ref['scheme'])) {
$ref['scheme'] = null;
}
if ($ref['scheme'] !== null) {
$scheme = $ref['scheme'];
$authority = $ref['authority'];
$path = static::removeDotSegments($ref['path']);
$query = $ref['query'];
} else {
// http://tools.ietf.org/html/rfc3986#section-3.3
// In addition, a URI reference (Section 4.1) may be a
// relative-path reference, in which case the first path segment
// cannot contain a colon (":") character.
// START: extra check for colon in first segment
$segments = explode('/', trim($ref['path'], '/'));
if (isset($segments[0]) && strpos($segments[0], ':') !== false) {
$message = sprintf('First segment in reference (%s) cannot contain a colon (":")', $reference);
throw new DomainException($message);
}
// END: extra check for colon in first segment
if ($ref['authority'] !== null) {
$authority = $ref['authority'];
$path = static::removeDotSegments($ref['path']);
$query = $ref['query'];
} else {
if ($ref['path'] === '') {
$path = $base->path();
if ($ref['query'] !== null) {
$query = $ref['query'];
} else {
$query = $base->query();
}
} else {
if ($ref['path'][0] === '/') {
$path = static::removeDotSegments($ref['path']);
} else {
$path = static::mergePaths($base, $ref['path']);
$path = static::removeDotSegments($path);
}
$query = $ref['query'];
}
$authority = $base->authority();
}
$scheme = $base->scheme();
}
$fragment = $ref['fragment'];
return new static($path, $scheme, $authority, $query, $fragment);
} | [
"public",
"static",
"function",
"resolve",
"(",
"$",
"base",
",",
"string",
"$",
"reference",
",",
"bool",
"$",
"strict",
"=",
"true",
")",
":",
"Uri",
"{",
"if",
"(",
"!",
"(",
"$",
"base",
"instanceof",
"self",
")",
")",
"{",
"$",
"base",
"=",
"static",
"::",
"parse",
"(",
"$",
"base",
")",
";",
"}",
"preg_match",
"(",
"static",
"::",
"URI_PATTERN",
",",
"$",
"reference",
",",
"$",
"matches",
")",
";",
"$",
"ref",
"=",
"static",
"::",
"componentsFromMatches",
"(",
"$",
"matches",
")",
";",
"// http://tools.ietf.org/html/rfc3986#section-5.2.2",
"// A non-strict parser may ignore a scheme in the reference if it is",
"// identical to the base URI's scheme",
"if",
"(",
"!",
"$",
"strict",
"&&",
"(",
"$",
"ref",
"[",
"'scheme'",
"]",
"!==",
"null",
"&&",
"$",
"base",
"->",
"scheme",
"(",
")",
"===",
"$",
"ref",
"[",
"'scheme'",
"]",
")",
")",
"{",
"$",
"ref",
"[",
"'scheme'",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"ref",
"[",
"'scheme'",
"]",
"!==",
"null",
")",
"{",
"$",
"scheme",
"=",
"$",
"ref",
"[",
"'scheme'",
"]",
";",
"$",
"authority",
"=",
"$",
"ref",
"[",
"'authority'",
"]",
";",
"$",
"path",
"=",
"static",
"::",
"removeDotSegments",
"(",
"$",
"ref",
"[",
"'path'",
"]",
")",
";",
"$",
"query",
"=",
"$",
"ref",
"[",
"'query'",
"]",
";",
"}",
"else",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.3",
"// In addition, a URI reference (Section 4.1) may be a",
"// relative-path reference, in which case the first path segment",
"// cannot contain a colon (\":\") character.",
"// START: extra check for colon in first segment",
"$",
"segments",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"ref",
"[",
"'path'",
"]",
",",
"'/'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"segments",
"[",
"0",
"]",
")",
"&&",
"strpos",
"(",
"$",
"segments",
"[",
"0",
"]",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'First segment in reference (%s) cannot contain a colon (\":\")'",
",",
"$",
"reference",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"// END: extra check for colon in first segment",
"if",
"(",
"$",
"ref",
"[",
"'authority'",
"]",
"!==",
"null",
")",
"{",
"$",
"authority",
"=",
"$",
"ref",
"[",
"'authority'",
"]",
";",
"$",
"path",
"=",
"static",
"::",
"removeDotSegments",
"(",
"$",
"ref",
"[",
"'path'",
"]",
")",
";",
"$",
"query",
"=",
"$",
"ref",
"[",
"'query'",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"ref",
"[",
"'path'",
"]",
"===",
"''",
")",
"{",
"$",
"path",
"=",
"$",
"base",
"->",
"path",
"(",
")",
";",
"if",
"(",
"$",
"ref",
"[",
"'query'",
"]",
"!==",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"ref",
"[",
"'query'",
"]",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"$",
"base",
"->",
"query",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"ref",
"[",
"'path'",
"]",
"[",
"0",
"]",
"===",
"'/'",
")",
"{",
"$",
"path",
"=",
"static",
"::",
"removeDotSegments",
"(",
"$",
"ref",
"[",
"'path'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"static",
"::",
"mergePaths",
"(",
"$",
"base",
",",
"$",
"ref",
"[",
"'path'",
"]",
")",
";",
"$",
"path",
"=",
"static",
"::",
"removeDotSegments",
"(",
"$",
"path",
")",
";",
"}",
"$",
"query",
"=",
"$",
"ref",
"[",
"'query'",
"]",
";",
"}",
"$",
"authority",
"=",
"$",
"base",
"->",
"authority",
"(",
")",
";",
"}",
"$",
"scheme",
"=",
"$",
"base",
"->",
"scheme",
"(",
")",
";",
"}",
"$",
"fragment",
"=",
"$",
"ref",
"[",
"'fragment'",
"]",
";",
"return",
"new",
"static",
"(",
"$",
"path",
",",
"$",
"scheme",
",",
"$",
"authority",
",",
"$",
"query",
",",
"$",
"fragment",
")",
";",
"}"
] | Creates instance from a base URI and relative reference
@link http://tools.ietf.org/html/rfc3986#section-5.2
@param Uri|string $base A Uri instance or string
@param string $reference A relative URI reference
@param bool $strict Whether or not to enable strict parsing
@return Uri
@throws DomainException When the base or reference are invalid | [
"Creates",
"instance",
"from",
"a",
"base",
"URI",
"and",
"relative",
"reference"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L226-L287 |
9,051 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.fromArray | public static function fromArray(array $components): Uri
{
$scheme = $components['scheme'] ?? null;
$authority = $components['authority'] ?? null;
$path = $components['path'] ?? '';
$query = $components['query'] ?? null;
$fragment = $components['fragment'] ?? null;
return new static($path, $scheme, $authority, $query, $fragment);
} | php | public static function fromArray(array $components): Uri
{
$scheme = $components['scheme'] ?? null;
$authority = $components['authority'] ?? null;
$path = $components['path'] ?? '';
$query = $components['query'] ?? null;
$fragment = $components['fragment'] ?? null;
return new static($path, $scheme, $authority, $query, $fragment);
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"components",
")",
":",
"Uri",
"{",
"$",
"scheme",
"=",
"$",
"components",
"[",
"'scheme'",
"]",
"??",
"null",
";",
"$",
"authority",
"=",
"$",
"components",
"[",
"'authority'",
"]",
"??",
"null",
";",
"$",
"path",
"=",
"$",
"components",
"[",
"'path'",
"]",
"??",
"''",
";",
"$",
"query",
"=",
"$",
"components",
"[",
"'query'",
"]",
"??",
"null",
";",
"$",
"fragment",
"=",
"$",
"components",
"[",
"'fragment'",
"]",
"??",
"null",
";",
"return",
"new",
"static",
"(",
"$",
"path",
",",
"$",
"scheme",
",",
"$",
"authority",
",",
"$",
"query",
",",
"$",
"fragment",
")",
";",
"}"
] | Creates instance from components
The following key names should hold their respective values:
* scheme
* authority
* path
* query
* fragment
@param array $components The components
@return Uri
@throws DomainException When components are missing or invalid | [
"Creates",
"instance",
"from",
"components"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L306-L315 |
9,052 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.display | public function display(): string
{
$output = sprintf('%s:', $this->scheme);
if ($this->authority !== null) {
$output .= sprintf('//%s', $this->host);
if ($this->port !== null) {
$output .= sprintf(':%d', $this->port);
}
}
$output .= $this->path;
if ($this->query !== null) {
$output .= sprintf('?%s', $this->query);
}
if ($this->fragment !== null) {
$output .= sprintf('#%s', $this->fragment);
}
return $output;
} | php | public function display(): string
{
$output = sprintf('%s:', $this->scheme);
if ($this->authority !== null) {
$output .= sprintf('//%s', $this->host);
if ($this->port !== null) {
$output .= sprintf(':%d', $this->port);
}
}
$output .= $this->path;
if ($this->query !== null) {
$output .= sprintf('?%s', $this->query);
}
if ($this->fragment !== null) {
$output .= sprintf('#%s', $this->fragment);
}
return $output;
} | [
"public",
"function",
"display",
"(",
")",
":",
"string",
"{",
"$",
"output",
"=",
"sprintf",
"(",
"'%s:'",
",",
"$",
"this",
"->",
"scheme",
")",
";",
"if",
"(",
"$",
"this",
"->",
"authority",
"!==",
"null",
")",
"{",
"$",
"output",
".=",
"sprintf",
"(",
"'//%s'",
",",
"$",
"this",
"->",
"host",
")",
";",
"if",
"(",
"$",
"this",
"->",
"port",
"!==",
"null",
")",
"{",
"$",
"output",
".=",
"sprintf",
"(",
"':%d'",
",",
"$",
"this",
"->",
"port",
")",
";",
"}",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"path",
";",
"if",
"(",
"$",
"this",
"->",
"query",
"!==",
"null",
")",
"{",
"$",
"output",
".=",
"sprintf",
"(",
"'?%s'",
",",
"$",
"this",
"->",
"query",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fragment",
"!==",
"null",
")",
"{",
"$",
"output",
".=",
"sprintf",
"(",
"'#%s'",
",",
"$",
"this",
"->",
"fragment",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Retrieves string representation without user info
@return string | [
"Retrieves",
"string",
"representation",
"without",
"user",
"info"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L438-L456 |
9,053 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.componentsFromMatches | protected static function componentsFromMatches(array $matches): array
{
// http://tools.ietf.org/html/rfc3986#section-5.3
// Note that we are careful to preserve the distinction between a
// component that is undefined, meaning that its separator was not
// present in the reference, and a component that is empty, meaning
// that the separator was present and was immediately followed by the
// next component separator or the end of the reference.
if (isset($matches[2]) && $matches[2]) {
$scheme = $matches[1] ?? '';
} else {
$scheme = null;
}
if (isset($matches[3]) && $matches[3]) {
$authority = $matches[4] ?? '';
} else {
$authority = null;
}
$path = $matches[5] ?? '';
if (isset($matches[6]) && $matches[6]) {
$query = $matches[7] ?? '';
} else {
$query = null;
}
if (isset($matches[8]) && $matches[8]) {
$fragment = $matches[9] ?? '';
} else {
$fragment = null;
}
return [
'scheme' => $scheme,
'authority' => $authority,
'path' => $path,
'query' => $query,
'fragment' => $fragment
];
} | php | protected static function componentsFromMatches(array $matches): array
{
// http://tools.ietf.org/html/rfc3986#section-5.3
// Note that we are careful to preserve the distinction between a
// component that is undefined, meaning that its separator was not
// present in the reference, and a component that is empty, meaning
// that the separator was present and was immediately followed by the
// next component separator or the end of the reference.
if (isset($matches[2]) && $matches[2]) {
$scheme = $matches[1] ?? '';
} else {
$scheme = null;
}
if (isset($matches[3]) && $matches[3]) {
$authority = $matches[4] ?? '';
} else {
$authority = null;
}
$path = $matches[5] ?? '';
if (isset($matches[6]) && $matches[6]) {
$query = $matches[7] ?? '';
} else {
$query = null;
}
if (isset($matches[8]) && $matches[8]) {
$fragment = $matches[9] ?? '';
} else {
$fragment = null;
}
return [
'scheme' => $scheme,
'authority' => $authority,
'path' => $path,
'query' => $query,
'fragment' => $fragment
];
} | [
"protected",
"static",
"function",
"componentsFromMatches",
"(",
"array",
"$",
"matches",
")",
":",
"array",
"{",
"// http://tools.ietf.org/html/rfc3986#section-5.3",
"// Note that we are careful to preserve the distinction between a",
"// component that is undefined, meaning that its separator was not",
"// present in the reference, and a component that is empty, meaning",
"// that the separator was present and was immediately followed by the",
"// next component separator or the end of the reference.",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"&&",
"$",
"matches",
"[",
"2",
"]",
")",
"{",
"$",
"scheme",
"=",
"$",
"matches",
"[",
"1",
"]",
"??",
"''",
";",
"}",
"else",
"{",
"$",
"scheme",
"=",
"null",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
"&&",
"$",
"matches",
"[",
"3",
"]",
")",
"{",
"$",
"authority",
"=",
"$",
"matches",
"[",
"4",
"]",
"??",
"''",
";",
"}",
"else",
"{",
"$",
"authority",
"=",
"null",
";",
"}",
"$",
"path",
"=",
"$",
"matches",
"[",
"5",
"]",
"??",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"6",
"]",
")",
"&&",
"$",
"matches",
"[",
"6",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"matches",
"[",
"7",
"]",
"??",
"''",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"null",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"8",
"]",
")",
"&&",
"$",
"matches",
"[",
"8",
"]",
")",
"{",
"$",
"fragment",
"=",
"$",
"matches",
"[",
"9",
"]",
"??",
"''",
";",
"}",
"else",
"{",
"$",
"fragment",
"=",
"null",
";",
"}",
"return",
"[",
"'scheme'",
"=>",
"$",
"scheme",
",",
"'authority'",
"=>",
"$",
"authority",
",",
"'path'",
"=>",
"$",
"path",
",",
"'query'",
"=>",
"$",
"query",
",",
"'fragment'",
"=>",
"$",
"fragment",
"]",
";",
"}"
] | Exchanges URI_PATTERN matches for components
@param array $matches The regex matches
@return array | [
"Exchanges",
"URI_PATTERN",
"matches",
"for",
"components"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L487-L524 |
9,054 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.parseAuthority | protected static function parseAuthority(?string $authority): array
{
if ($authority === null) {
return [
'userInfo' => null,
'host' => null,
'port' => null
];
}
preg_match(static::AUTHORITY_PATTERN, $authority, $matches);
$userInfo = isset($matches[1]) && $matches[1] ? $matches[1] : null;
$host = isset($matches[2]) && $matches[2] ? $matches[2] : '';
$port = isset($matches[3]) && $matches[3] ? ((int) $matches[3]) : null;
return [
'userInfo' => $userInfo,
'host' => $host,
'port' => $port
];
} | php | protected static function parseAuthority(?string $authority): array
{
if ($authority === null) {
return [
'userInfo' => null,
'host' => null,
'port' => null
];
}
preg_match(static::AUTHORITY_PATTERN, $authority, $matches);
$userInfo = isset($matches[1]) && $matches[1] ? $matches[1] : null;
$host = isset($matches[2]) && $matches[2] ? $matches[2] : '';
$port = isset($matches[3]) && $matches[3] ? ((int) $matches[3]) : null;
return [
'userInfo' => $userInfo,
'host' => $host,
'port' => $port
];
} | [
"protected",
"static",
"function",
"parseAuthority",
"(",
"?",
"string",
"$",
"authority",
")",
":",
"array",
"{",
"if",
"(",
"$",
"authority",
"===",
"null",
")",
"{",
"return",
"[",
"'userInfo'",
"=>",
"null",
",",
"'host'",
"=>",
"null",
",",
"'port'",
"=>",
"null",
"]",
";",
"}",
"preg_match",
"(",
"static",
"::",
"AUTHORITY_PATTERN",
",",
"$",
"authority",
",",
"$",
"matches",
")",
";",
"$",
"userInfo",
"=",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"&&",
"$",
"matches",
"[",
"1",
"]",
"?",
"$",
"matches",
"[",
"1",
"]",
":",
"null",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"&&",
"$",
"matches",
"[",
"2",
"]",
"?",
"$",
"matches",
"[",
"2",
"]",
":",
"''",
";",
"$",
"port",
"=",
"isset",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
"&&",
"$",
"matches",
"[",
"3",
"]",
"?",
"(",
"(",
"int",
")",
"$",
"matches",
"[",
"3",
"]",
")",
":",
"null",
";",
"return",
"[",
"'userInfo'",
"=>",
"$",
"userInfo",
",",
"'host'",
"=>",
"$",
"host",
",",
"'port'",
"=>",
"$",
"port",
"]",
";",
"}"
] | Parses authority component into parts
@param string|null $authority The authority
@return array | [
"Parses",
"authority",
"component",
"into",
"parts"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L533-L554 |
9,055 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.buildAuthority | protected static function buildAuthority(?string $userInfo, ?string $host, ?int $port): ?string
{
if ($host === null) {
return null;
}
$authority = '';
if ($userInfo !== null) {
$authority .= sprintf('%s@', $userInfo);
}
$authority .= $host;
if ($port !== null) {
$authority .= sprintf(':%d', $port);
}
return $authority;
} | php | protected static function buildAuthority(?string $userInfo, ?string $host, ?int $port): ?string
{
if ($host === null) {
return null;
}
$authority = '';
if ($userInfo !== null) {
$authority .= sprintf('%s@', $userInfo);
}
$authority .= $host;
if ($port !== null) {
$authority .= sprintf(':%d', $port);
}
return $authority;
} | [
"protected",
"static",
"function",
"buildAuthority",
"(",
"?",
"string",
"$",
"userInfo",
",",
"?",
"string",
"$",
"host",
",",
"?",
"int",
"$",
"port",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"host",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"authority",
"=",
"''",
";",
"if",
"(",
"$",
"userInfo",
"!==",
"null",
")",
"{",
"$",
"authority",
".=",
"sprintf",
"(",
"'%s@'",
",",
"$",
"userInfo",
")",
";",
"}",
"$",
"authority",
".=",
"$",
"host",
";",
"if",
"(",
"$",
"port",
"!==",
"null",
")",
"{",
"$",
"authority",
".=",
"sprintf",
"(",
"':%d'",
",",
"$",
"port",
")",
";",
"}",
"return",
"$",
"authority",
";",
"}"
] | Builds authority from parts
@param string|null $userInfo The user info
@param string|null $host The host
@param int|null $port The port
@return string|null | [
"Builds",
"authority",
"from",
"parts"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L565-L582 |
9,056 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizeScheme | protected static function normalizeScheme(?string $scheme): string
{
if (!static::isValidScheme($scheme)) {
$message = sprintf('Invalid URI scheme: %s', VarPrinter::toString($scheme));
throw new DomainException($message);
}
return strtolower($scheme);
} | php | protected static function normalizeScheme(?string $scheme): string
{
if (!static::isValidScheme($scheme)) {
$message = sprintf('Invalid URI scheme: %s', VarPrinter::toString($scheme));
throw new DomainException($message);
}
return strtolower($scheme);
} | [
"protected",
"static",
"function",
"normalizeScheme",
"(",
"?",
"string",
"$",
"scheme",
")",
":",
"string",
"{",
"if",
"(",
"!",
"static",
"::",
"isValidScheme",
"(",
"$",
"scheme",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid URI scheme: %s'",
",",
"VarPrinter",
"::",
"toString",
"(",
"$",
"scheme",
")",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"return",
"strtolower",
"(",
"$",
"scheme",
")",
";",
"}"
] | Validates and normalizes the scheme
@param string|null $scheme The scheme
@return string
@throws DomainException When the scheme is invalid | [
"Validates",
"and",
"normalizes",
"the",
"scheme"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L593-L601 |
9,057 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizePath | protected static function normalizePath(string $path): string
{
if (!static::isValidPath($path)) {
$message = sprintf('Invalid URI path: %s', $path);
throw new DomainException($message);
}
$path = static::removeDotSegments($path);
return static::encodePath(static::decode($path, static::UNRESERVED_SET));
} | php | protected static function normalizePath(string $path): string
{
if (!static::isValidPath($path)) {
$message = sprintf('Invalid URI path: %s', $path);
throw new DomainException($message);
}
$path = static::removeDotSegments($path);
return static::encodePath(static::decode($path, static::UNRESERVED_SET));
} | [
"protected",
"static",
"function",
"normalizePath",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"if",
"(",
"!",
"static",
"::",
"isValidPath",
"(",
"$",
"path",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid URI path: %s'",
",",
"$",
"path",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"$",
"path",
"=",
"static",
"::",
"removeDotSegments",
"(",
"$",
"path",
")",
";",
"return",
"static",
"::",
"encodePath",
"(",
"static",
"::",
"decode",
"(",
"$",
"path",
",",
"static",
"::",
"UNRESERVED_SET",
")",
")",
";",
"}"
] | Validates and normalizes the path
@param string $path The path
@return string
@throws DomainException When the path is invalid | [
"Validates",
"and",
"normalizes",
"the",
"path"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L612-L622 |
9,058 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizeQuery | protected static function normalizeQuery(?string $query): ?string
{
if ($query === null) {
return null;
}
if (!static::isValidQuery($query)) {
$message = sprintf('Invalid URI query: %s', $query);
throw new DomainException($message);
}
return static::encodeQuery(static::decode($query, static::UNRESERVED_SET));
} | php | protected static function normalizeQuery(?string $query): ?string
{
if ($query === null) {
return null;
}
if (!static::isValidQuery($query)) {
$message = sprintf('Invalid URI query: %s', $query);
throw new DomainException($message);
}
return static::encodeQuery(static::decode($query, static::UNRESERVED_SET));
} | [
"protected",
"static",
"function",
"normalizeQuery",
"(",
"?",
"string",
"$",
"query",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"query",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"isValidQuery",
"(",
"$",
"query",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid URI query: %s'",
",",
"$",
"query",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"return",
"static",
"::",
"encodeQuery",
"(",
"static",
"::",
"decode",
"(",
"$",
"query",
",",
"static",
"::",
"UNRESERVED_SET",
")",
")",
";",
"}"
] | Validates and normalizes the query
@param string|null $query The query
@return string|null
@throws DomainException When the query is invalid | [
"Validates",
"and",
"normalizes",
"the",
"query"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L633-L645 |
9,059 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizeFragment | protected static function normalizeFragment(?string $fragment): ?string
{
if ($fragment === null) {
return null;
}
if (!static::isValidFragment($fragment)) {
$message = sprintf('Invalid URI fragment: %s', $fragment);
throw new DomainException($message);
}
return static::encodeFragment(static::decode($fragment, static::UNRESERVED_SET));
} | php | protected static function normalizeFragment(?string $fragment): ?string
{
if ($fragment === null) {
return null;
}
if (!static::isValidFragment($fragment)) {
$message = sprintf('Invalid URI fragment: %s', $fragment);
throw new DomainException($message);
}
return static::encodeFragment(static::decode($fragment, static::UNRESERVED_SET));
} | [
"protected",
"static",
"function",
"normalizeFragment",
"(",
"?",
"string",
"$",
"fragment",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"fragment",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"isValidFragment",
"(",
"$",
"fragment",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid URI fragment: %s'",
",",
"$",
"fragment",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"return",
"static",
"::",
"encodeFragment",
"(",
"static",
"::",
"decode",
"(",
"$",
"fragment",
",",
"static",
"::",
"UNRESERVED_SET",
")",
")",
";",
"}"
] | Validates and normalizes the fragment
@param string|null $fragment The fragment
@return string|null
@throws DomainException When the fragment is invalid | [
"Validates",
"and",
"normalizes",
"the",
"fragment"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L656-L668 |
9,060 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizeUserInfo | protected static function normalizeUserInfo(?string $userInfo): ?string
{
if ($userInfo === null) {
return null;
}
if (!static::isValidUserInfo($userInfo)) {
$message = sprintf('Invalid user info: %s', $userInfo);
throw new DomainException($message);
}
return static::encodeUserInfo(static::decode($userInfo, static::UNRESERVED_SET));
} | php | protected static function normalizeUserInfo(?string $userInfo): ?string
{
if ($userInfo === null) {
return null;
}
if (!static::isValidUserInfo($userInfo)) {
$message = sprintf('Invalid user info: %s', $userInfo);
throw new DomainException($message);
}
return static::encodeUserInfo(static::decode($userInfo, static::UNRESERVED_SET));
} | [
"protected",
"static",
"function",
"normalizeUserInfo",
"(",
"?",
"string",
"$",
"userInfo",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"userInfo",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"isValidUserInfo",
"(",
"$",
"userInfo",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid user info: %s'",
",",
"$",
"userInfo",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"return",
"static",
"::",
"encodeUserInfo",
"(",
"static",
"::",
"decode",
"(",
"$",
"userInfo",
",",
"static",
"::",
"UNRESERVED_SET",
")",
")",
";",
"}"
] | Validates and normalizes the user info
@param string|null $userInfo The user info
@return string|null
@throws DomainException When the user info is invalid | [
"Validates",
"and",
"normalizes",
"the",
"user",
"info"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L679-L691 |
9,061 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizeHost | protected static function normalizeHost(?string $host): ?string
{
if ($host === null) {
return null;
}
if ($host === '') {
return '';
}
if (!static::isValidHost($host)) {
$message = sprintf('Invalid host: %s', $host);
throw new DomainException($message);
}
// Although host is case-insensitive, producers and normalizers should
// use lowercase for registered names and hexadecimal addresses for the
// sake of uniformity, while only using uppercase letters for
// percent-encodings.
$host = mb_strtolower($host, 'UTF-8');
return static::encodeHost(static::decode($host, static::UNRESERVED_SET));
} | php | protected static function normalizeHost(?string $host): ?string
{
if ($host === null) {
return null;
}
if ($host === '') {
return '';
}
if (!static::isValidHost($host)) {
$message = sprintf('Invalid host: %s', $host);
throw new DomainException($message);
}
// Although host is case-insensitive, producers and normalizers should
// use lowercase for registered names and hexadecimal addresses for the
// sake of uniformity, while only using uppercase letters for
// percent-encodings.
$host = mb_strtolower($host, 'UTF-8');
return static::encodeHost(static::decode($host, static::UNRESERVED_SET));
} | [
"protected",
"static",
"function",
"normalizeHost",
"(",
"?",
"string",
"$",
"host",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"host",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"host",
"===",
"''",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"isValidHost",
"(",
"$",
"host",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Invalid host: %s'",
",",
"$",
"host",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"// Although host is case-insensitive, producers and normalizers should",
"// use lowercase for registered names and hexadecimal addresses for the",
"// sake of uniformity, while only using uppercase letters for",
"// percent-encodings.",
"$",
"host",
"=",
"mb_strtolower",
"(",
"$",
"host",
",",
"'UTF-8'",
")",
";",
"return",
"static",
"::",
"encodeHost",
"(",
"static",
"::",
"decode",
"(",
"$",
"host",
",",
"static",
"::",
"UNRESERVED_SET",
")",
")",
";",
"}"
] | Validates and normalizes the host
@param string|null $host The host
@return string|null
@throws DomainException When the host is invalid | [
"Validates",
"and",
"normalizes",
"the",
"host"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L702-L724 |
9,062 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.normalizePort | protected static function normalizePort(?int $port, ?string $scheme): ?int
{
if ($port === null) {
return null;
}
if ($scheme && isset(static::$defaultPorts[$scheme]) && ($port == static::$defaultPorts[$scheme])) {
return null;
}
return $port;
} | php | protected static function normalizePort(?int $port, ?string $scheme): ?int
{
if ($port === null) {
return null;
}
if ($scheme && isset(static::$defaultPorts[$scheme]) && ($port == static::$defaultPorts[$scheme])) {
return null;
}
return $port;
} | [
"protected",
"static",
"function",
"normalizePort",
"(",
"?",
"int",
"$",
"port",
",",
"?",
"string",
"$",
"scheme",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"port",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"scheme",
"&&",
"isset",
"(",
"static",
"::",
"$",
"defaultPorts",
"[",
"$",
"scheme",
"]",
")",
"&&",
"(",
"$",
"port",
"==",
"static",
"::",
"$",
"defaultPorts",
"[",
"$",
"scheme",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"port",
";",
"}"
] | Validates and normalizes the port
@param int|null $port The port
@param string|null $scheme The scheme
@return int|null | [
"Validates",
"and",
"normalizes",
"the",
"port"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L734-L745 |
9,063 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encodePath | protected static function encodePath(string $path): string
{
// http://tools.ietf.org/html/rfc3986#section-3.3
// 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 / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/';
return static::encode($path, $excluded);
} | php | protected static function encodePath(string $path): string
{
// http://tools.ietf.org/html/rfc3986#section-3.3
// 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 / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/';
return static::encode($path, $excluded);
} | [
"protected",
"static",
"function",
"encodePath",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.3",
"// 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 / \":\" / \"@\"",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
".",
"':@\\/'",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"path",
",",
"$",
"excluded",
")",
";",
"}"
] | Encodes the path
@param string $path The path
@return string | [
"Encodes",
"the",
"path"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L754-L776 |
9,064 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encodeQuery | protected static function encodeQuery(string $query): string
{
// http://tools.ietf.org/html/rfc3986#section-3.4
// query = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/\?';
return static::encode($query, $excluded);
} | php | protected static function encodeQuery(string $query): string
{
// http://tools.ietf.org/html/rfc3986#section-3.4
// query = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/\?';
return static::encode($query, $excluded);
} | [
"protected",
"static",
"function",
"encodeQuery",
"(",
"string",
"$",
"query",
")",
":",
"string",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.4",
"// query = *( pchar / \"/\" / \"?\" )",
"// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
".",
"':@\\/\\?'",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"query",
",",
"$",
"excluded",
")",
";",
"}"
] | Encodes the query
@param string $query The query
@return string | [
"Encodes",
"the",
"query"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L785-L793 |
9,065 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encodeFragment | protected static function encodeFragment(string $fragment): string
{
// http://tools.ietf.org/html/rfc3986#section-3.5
// fragment = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/\?';
return static::encode($fragment, $excluded);
} | php | protected static function encodeFragment(string $fragment): string
{
// http://tools.ietf.org/html/rfc3986#section-3.5
// fragment = *( pchar / "/" / "?" )
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/\?';
return static::encode($fragment, $excluded);
} | [
"protected",
"static",
"function",
"encodeFragment",
"(",
"string",
"$",
"fragment",
")",
":",
"string",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.5",
"// fragment = *( pchar / \"/\" / \"?\" )",
"// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
".",
"':@\\/\\?'",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"fragment",
",",
"$",
"excluded",
")",
";",
"}"
] | Encodes the fragment
@param string $fragment The fragment
@return string | [
"Encodes",
"the",
"fragment"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L802-L810 |
9,066 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encodeUserInfo | protected static function encodeUserInfo(string $userInfo): string
{
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':';
return static::encode($userInfo, $excluded);
} | php | protected static function encodeUserInfo(string $userInfo): string
{
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':';
return static::encode($userInfo, $excluded);
} | [
"protected",
"static",
"function",
"encodeUserInfo",
"(",
"string",
"$",
"userInfo",
")",
":",
"string",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.2.1",
"// userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
".",
"':'",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"userInfo",
",",
"$",
"excluded",
")",
";",
"}"
] | Encodes the user info
@param string $userInfo The user info
@return string | [
"Encodes",
"the",
"user",
"info"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L819-L826 |
9,067 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encodeHost | protected static function encodeHost(string $host): string
{
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// IP-literal = "[" ( IPv6address / IPvFuture ) "]"
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
if ($host[0] === '[') {
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.'\[\]:';
return static::encode($host, $excluded);
}
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// NOTE: characters in IPv4 address are all in the unreserved set
// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
// reg-name = *( unreserved / pct-encoded / sub-delims )
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET;
return static::encode($host, $excluded);
} | php | protected static function encodeHost(string $host): string
{
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// IP-literal = "[" ( IPv6address / IPvFuture ) "]"
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
if ($host[0] === '[') {
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.'\[\]:';
return static::encode($host, $excluded);
}
// http://tools.ietf.org/html/rfc3986#section-3.2.2
// NOTE: characters in IPv4 address are all in the unreserved set
// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
// reg-name = *( unreserved / pct-encoded / sub-delims )
$excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET;
return static::encode($host, $excluded);
} | [
"protected",
"static",
"function",
"encodeHost",
"(",
"string",
"$",
"host",
")",
":",
"string",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.2.2",
"// IP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"",
"// IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )",
"if",
"(",
"$",
"host",
"[",
"0",
"]",
"===",
"'['",
")",
"{",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
".",
"'\\[\\]:'",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"host",
",",
"$",
"excluded",
")",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.2.2",
"// NOTE: characters in IPv4 address are all in the unreserved set",
"// IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet",
"// reg-name = *( unreserved / pct-encoded / sub-delims )",
"$",
"excluded",
"=",
"static",
"::",
"UNRESERVED_SET",
".",
"static",
"::",
"SUB_DELIMS_SET",
";",
"return",
"static",
"::",
"encode",
"(",
"$",
"host",
",",
"$",
"excluded",
")",
";",
"}"
] | Encodes the host
@param string $host The host
@return string | [
"Encodes",
"the",
"host"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L835-L853 |
9,068 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.encode | protected static function encode(string $component, string $excluded): string
{
return preg_replace_callback(static::encodingRegex($excluded), function (array $matches) {
return rawurlencode($matches[0]);
}, $component);
} | php | protected static function encode(string $component, string $excluded): string
{
return preg_replace_callback(static::encodingRegex($excluded), function (array $matches) {
return rawurlencode($matches[0]);
}, $component);
} | [
"protected",
"static",
"function",
"encode",
"(",
"string",
"$",
"component",
",",
"string",
"$",
"excluded",
")",
":",
"string",
"{",
"return",
"preg_replace_callback",
"(",
"static",
"::",
"encodingRegex",
"(",
"$",
"excluded",
")",
",",
"function",
"(",
"array",
"$",
"matches",
")",
"{",
"return",
"rawurlencode",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"component",
")",
";",
"}"
] | Encodes a component
@codeCoverageIgnore
@param string $component The component
@param string $excluded The set of excluded characters
@return string | [
"Encodes",
"a",
"component"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L865-L870 |
9,069 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.decode | protected static function decode(string $component, string $allowed): string
{
$allowed = sprintf('/[%s]/', $allowed);
$encoded = sprintf('/%s/', static::PCT_ENCODED_SET);
return preg_replace_callback($encoded, function ($matches) use ($allowed) {
$char = rawurldecode($matches[0]);
if (preg_match($allowed, $char)) {
return $char;
}
return strtoupper($matches[0]);
}, $component);
} | php | protected static function decode(string $component, string $allowed): string
{
$allowed = sprintf('/[%s]/', $allowed);
$encoded = sprintf('/%s/', static::PCT_ENCODED_SET);
return preg_replace_callback($encoded, function ($matches) use ($allowed) {
$char = rawurldecode($matches[0]);
if (preg_match($allowed, $char)) {
return $char;
}
return strtoupper($matches[0]);
}, $component);
} | [
"protected",
"static",
"function",
"decode",
"(",
"string",
"$",
"component",
",",
"string",
"$",
"allowed",
")",
":",
"string",
"{",
"$",
"allowed",
"=",
"sprintf",
"(",
"'/[%s]/'",
",",
"$",
"allowed",
")",
";",
"$",
"encoded",
"=",
"sprintf",
"(",
"'/%s/'",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"preg_replace_callback",
"(",
"$",
"encoded",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"allowed",
")",
"{",
"$",
"char",
"=",
"rawurldecode",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"allowed",
",",
"$",
"char",
")",
")",
"{",
"return",
"$",
"char",
";",
"}",
"return",
"strtoupper",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"component",
")",
";",
"}"
] | Decodes a component
@param string $component The component
@param string $allowed The set of allowed characters
@return string | [
"Decodes",
"a",
"component"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L880-L894 |
9,070 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.removeDotSegments | protected static function removeDotSegments(string $path): string
{
$output = '';
while ($path) {
if ('..' == $path || '.' == $path) {
break;
}
switch (true) {
case ('./' == substr($path, 0, 2)):
$path = substr($path, 2);
break;
case ('../' == substr($path, 0, 3)):
$path = substr($path, 3);
break;
case ('/./' == substr($path, 0, 3)):
$path = substr($path, 2);
break;
case ('/../' == substr($path, 0, 4)):
$path = '/'.substr($path, 4);
$pos = strrpos($output, '/', -1);
if ($pos !== false) {
$output = substr($output, 0, $pos);
}
break;
case ('/..' == substr($path, 0, 3) && (in_array(substr($path, 3, 1), [false, '', '/'], true))):
$path = '/'.substr($path, 3);
$pos = strrpos($output, '/', -1);
if ($pos !== false) {
$output = substr($output, 0, $pos);
}
break;
case ('/.' == substr($path, 0, 2) && (in_array(substr($path, 2, 1), [false, '', '/'], true))):
$path = '/'.substr($path, 2);
break;
default:
$nextSlash = strpos($path, '/', 1);
if (false === $nextSlash) {
$segment = $path;
} else {
$segment = substr($path, 0, $nextSlash);
}
$output .= $segment;
$path = substr($path, strlen($segment));
break;
}
}
return $output;
} | php | protected static function removeDotSegments(string $path): string
{
$output = '';
while ($path) {
if ('..' == $path || '.' == $path) {
break;
}
switch (true) {
case ('./' == substr($path, 0, 2)):
$path = substr($path, 2);
break;
case ('../' == substr($path, 0, 3)):
$path = substr($path, 3);
break;
case ('/./' == substr($path, 0, 3)):
$path = substr($path, 2);
break;
case ('/../' == substr($path, 0, 4)):
$path = '/'.substr($path, 4);
$pos = strrpos($output, '/', -1);
if ($pos !== false) {
$output = substr($output, 0, $pos);
}
break;
case ('/..' == substr($path, 0, 3) && (in_array(substr($path, 3, 1), [false, '', '/'], true))):
$path = '/'.substr($path, 3);
$pos = strrpos($output, '/', -1);
if ($pos !== false) {
$output = substr($output, 0, $pos);
}
break;
case ('/.' == substr($path, 0, 2) && (in_array(substr($path, 2, 1), [false, '', '/'], true))):
$path = '/'.substr($path, 2);
break;
default:
$nextSlash = strpos($path, '/', 1);
if (false === $nextSlash) {
$segment = $path;
} else {
$segment = substr($path, 0, $nextSlash);
}
$output .= $segment;
$path = substr($path, strlen($segment));
break;
}
}
return $output;
} | [
"protected",
"static",
"function",
"removeDotSegments",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"$",
"output",
"=",
"''",
";",
"while",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"'..'",
"==",
"$",
"path",
"||",
"'.'",
"==",
"$",
"path",
")",
"{",
"break",
";",
"}",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"'./'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"2",
")",
")",
":",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"2",
")",
";",
"break",
";",
"case",
"(",
"'../'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"3",
")",
")",
":",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"3",
")",
";",
"break",
";",
"case",
"(",
"'/./'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"3",
")",
")",
":",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"2",
")",
";",
"break",
";",
"case",
"(",
"'/../'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"4",
")",
")",
":",
"$",
"path",
"=",
"'/'",
".",
"substr",
"(",
"$",
"path",
",",
"4",
")",
";",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"output",
",",
"'/'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"$",
"output",
"=",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"$",
"pos",
")",
";",
"}",
"break",
";",
"case",
"(",
"'/..'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"3",
")",
"&&",
"(",
"in_array",
"(",
"substr",
"(",
"$",
"path",
",",
"3",
",",
"1",
")",
",",
"[",
"false",
",",
"''",
",",
"'/'",
"]",
",",
"true",
")",
")",
")",
":",
"$",
"path",
"=",
"'/'",
".",
"substr",
"(",
"$",
"path",
",",
"3",
")",
";",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"output",
",",
"'/'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"$",
"output",
"=",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"$",
"pos",
")",
";",
"}",
"break",
";",
"case",
"(",
"'/.'",
"==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"2",
")",
"&&",
"(",
"in_array",
"(",
"substr",
"(",
"$",
"path",
",",
"2",
",",
"1",
")",
",",
"[",
"false",
",",
"''",
",",
"'/'",
"]",
",",
"true",
")",
")",
")",
":",
"$",
"path",
"=",
"'/'",
".",
"substr",
"(",
"$",
"path",
",",
"2",
")",
";",
"break",
";",
"default",
":",
"$",
"nextSlash",
"=",
"strpos",
"(",
"$",
"path",
",",
"'/'",
",",
"1",
")",
";",
"if",
"(",
"false",
"===",
"$",
"nextSlash",
")",
"{",
"$",
"segment",
"=",
"$",
"path",
";",
"}",
"else",
"{",
"$",
"segment",
"=",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"$",
"nextSlash",
")",
";",
"}",
"$",
"output",
".=",
"$",
"segment",
";",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"strlen",
"(",
"$",
"segment",
")",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Removes dot segments
Algorithm based on section 5.2.4 of RFC 3986.
@link http://tools.ietf.org/html/rfc3986#section-5.2.4
@param string $path The input path
@return string | [
"Removes",
"dot",
"segments"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L907-L955 |
9,071 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.mergePaths | protected static function mergePaths(Uri $baseUri, string $relative): string
{
$basePath = $baseUri->path();
if ($baseUri->authority() !== null && $basePath === '') {
return sprintf('/%s', $relative);
}
$last = strrpos($basePath, '/');
if ($last !== false) {
return sprintf('%s/%s', substr($basePath, 0, $last), $relative);
}
return $relative;
} | php | protected static function mergePaths(Uri $baseUri, string $relative): string
{
$basePath = $baseUri->path();
if ($baseUri->authority() !== null && $basePath === '') {
return sprintf('/%s', $relative);
}
$last = strrpos($basePath, '/');
if ($last !== false) {
return sprintf('%s/%s', substr($basePath, 0, $last), $relative);
}
return $relative;
} | [
"protected",
"static",
"function",
"mergePaths",
"(",
"Uri",
"$",
"baseUri",
",",
"string",
"$",
"relative",
")",
":",
"string",
"{",
"$",
"basePath",
"=",
"$",
"baseUri",
"->",
"path",
"(",
")",
";",
"if",
"(",
"$",
"baseUri",
"->",
"authority",
"(",
")",
"!==",
"null",
"&&",
"$",
"basePath",
"===",
"''",
")",
"{",
"return",
"sprintf",
"(",
"'/%s'",
",",
"$",
"relative",
")",
";",
"}",
"$",
"last",
"=",
"strrpos",
"(",
"$",
"basePath",
",",
"'/'",
")",
";",
"if",
"(",
"$",
"last",
"!==",
"false",
")",
"{",
"return",
"sprintf",
"(",
"'%s/%s'",
",",
"substr",
"(",
"$",
"basePath",
",",
"0",
",",
"$",
"last",
")",
",",
"$",
"relative",
")",
";",
"}",
"return",
"$",
"relative",
";",
"}"
] | Merges a base URI and relative path
@link http://tools.ietf.org/html/rfc3986#section-5.2.3
@param Uri $baseUri The base Uri instance
@param string $relative The relative path
@return string | [
"Merges",
"a",
"base",
"URI",
"and",
"relative",
"path"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L967-L982 |
9,072 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidScheme | protected static function isValidScheme(?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;
}
return !!preg_match(static::SCHEME_PATTERN, $scheme);
} | php | protected static function isValidScheme(?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;
}
return !!preg_match(static::SCHEME_PATTERN, $scheme);
} | [
"protected",
"static",
"function",
"isValidScheme",
"(",
"?",
"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",
";",
"}",
"return",
"!",
"!",
"preg_match",
"(",
"static",
"::",
"SCHEME_PATTERN",
",",
"$",
"scheme",
")",
";",
"}"
] | Checks if a scheme is valid
@param string|null $scheme The scheme
@return bool | [
"Checks",
"if",
"a",
"scheme",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L991-L1001 |
9,073 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidPath | protected static function isValidPath(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;
}
// http://tools.ietf.org/html/rfc3986#section-3.3
// 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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $path);
} | php | protected static function isValidPath(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;
}
// http://tools.ietf.org/html/rfc3986#section-3.3
// 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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $path);
} | [
"protected",
"static",
"function",
"isValidPath",
"(",
"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",
";",
"}",
"// http://tools.ietf.org/html/rfc3986#section-3.3",
"// 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/'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
")",
";",
"}"
] | Checks if a path is valid
@param string $path The path
@return bool | [
"Checks",
"if",
"a",
"path",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1010-L1044 |
9,074 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidQuery | protected static function isValidQuery(?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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $query);
} | php | protected static function isValidQuery(?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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $query);
} | [
"protected",
"static",
"function",
"isValidQuery",
"(",
"?",
"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/'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"query",
")",
";",
"}"
] | Checks if a query is valid
@param string|null $query The query
@return bool | [
"Checks",
"if",
"a",
"query",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1053-L1070 |
9,075 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidFragment | protected static function isValidFragment(?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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $fragment);
} | php | protected static function isValidFragment(?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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $fragment);
} | [
"protected",
"static",
"function",
"isValidFragment",
"(",
"?",
"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/'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"fragment",
")",
";",
"}"
] | Checks if a fragment is valid
@param string|null $fragment The fragment
@return bool | [
"Checks",
"if",
"a",
"fragment",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1079-L1096 |
9,076 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidUserInfo | protected static function isValidUserInfo(string $userInfo): bool
{
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$pattern = sprintf(
'/\A(?:[%s%s:]|(?:%s))*\z/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $userInfo);
} | php | protected static function isValidUserInfo(string $userInfo): bool
{
// http://tools.ietf.org/html/rfc3986#section-3.2.1
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
$pattern = sprintf(
'/\A(?:[%s%s:]|(?:%s))*\z/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $userInfo);
} | [
"protected",
"static",
"function",
"isValidUserInfo",
"(",
"string",
"$",
"userInfo",
")",
":",
"bool",
"{",
"// http://tools.ietf.org/html/rfc3986#section-3.2.1",
"// userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A(?:[%s%s:]|(?:%s))*\\z/'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"userInfo",
")",
";",
"}"
] | Checks if user info is valid
@param string $userInfo The user info
@return bool | [
"Checks",
"if",
"user",
"info",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1105-L1117 |
9,077 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidHost | protected static function isValidHost(string $host): bool
{
// 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 static::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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $host);
} | php | protected static function isValidHost(string $host): bool
{
// 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 static::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/',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET,
static::PCT_ENCODED_SET
);
return !!preg_match($pattern, $host);
} | [
"protected",
"static",
"function",
"isValidHost",
"(",
"string",
"$",
"host",
")",
":",
"bool",
"{",
"// 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",
"static",
"::",
"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/'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
",",
"static",
"::",
"PCT_ENCODED_SET",
")",
";",
"return",
"!",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"host",
")",
";",
"}"
] | Checks if a host is valid
@param string $host The host
@return bool | [
"Checks",
"if",
"a",
"host",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1126-L1153 |
9,078 | novuso/common | src/Domain/Value/Identifier/Uri.php | Uri.isValidIpLiteral | protected static function isValidIpLiteral(string $ip): bool
{
// outer brackets
$length = strlen($ip);
if ($ip[0] !== '[' || $ip[$length - 1] !== ']') {
return false;
}
// remove brackets
$ip = substr($ip, 1, $length - 2);
// starts with "v" (case-insensitive)
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
$pattern = sprintf(
'/\A[v](?:[a-f0-9]+)\.[%s%s:]+\z/i',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET
);
if (preg_match($pattern, $ip)) {
return true;
}
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
} | php | protected static function isValidIpLiteral(string $ip): bool
{
// outer brackets
$length = strlen($ip);
if ($ip[0] !== '[' || $ip[$length - 1] !== ']') {
return false;
}
// remove brackets
$ip = substr($ip, 1, $length - 2);
// starts with "v" (case-insensitive)
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
$pattern = sprintf(
'/\A[v](?:[a-f0-9]+)\.[%s%s:]+\z/i',
static::UNRESERVED_SET,
static::SUB_DELIMS_SET
);
if (preg_match($pattern, $ip)) {
return true;
}
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
} | [
"protected",
"static",
"function",
"isValidIpLiteral",
"(",
"string",
"$",
"ip",
")",
":",
"bool",
"{",
"// outer brackets",
"$",
"length",
"=",
"strlen",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"ip",
"[",
"0",
"]",
"!==",
"'['",
"||",
"$",
"ip",
"[",
"$",
"length",
"-",
"1",
"]",
"!==",
"']'",
")",
"{",
"return",
"false",
";",
"}",
"// remove brackets",
"$",
"ip",
"=",
"substr",
"(",
"$",
"ip",
",",
"1",
",",
"$",
"length",
"-",
"2",
")",
";",
"// starts with \"v\" (case-insensitive)",
"// IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/\\A[v](?:[a-f0-9]+)\\.[%s%s:]+\\z/i'",
",",
"static",
"::",
"UNRESERVED_SET",
",",
"static",
"::",
"SUB_DELIMS_SET",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"ip",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"filter_var",
"(",
"$",
"ip",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV6",
")",
"!==",
"false",
";",
"}"
] | Checks if a IP literal is valid
@param string $ip The IP literal
@return bool | [
"Checks",
"if",
"a",
"IP",
"literal",
"is",
"valid"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Uri.php#L1162-L1185 |
9,079 | joomla-framework/mediawiki-api | src/Search.php | Search.search | public function search($srsearch, array $srnamespace = null, $srwhat = null, array $srinfo = null, array $srprop = null,
$srredirects = null, $sroffest = null, $srlimit = null
)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($srsearch))
{
$path .= '&srsearch=' . $srsearch;
}
if (isset($srnamespace))
{
$path .= '&srnamespace=' . $this->buildParameter($srnamespace);
}
if (isset($srwhat))
{
$path .= '&srwhat=' . $srwhat;
}
if (isset($srinfo))
{
$path .= '&srinfo=' . $this->buildParameter($srinfo);
}
if (isset($srprop))
{
$path .= '&srprop=' . $this->buildParameter($srprop);
}
if ($srredirects)
{
$path .= '&srredirects=';
}
if (isset($sroffest))
{
$path .= '&sroffest=' . $sroffest;
}
if (isset($srlimit))
{
$path .= '&srlimit=' . $srlimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
} | php | public function search($srsearch, array $srnamespace = null, $srwhat = null, array $srinfo = null, array $srprop = null,
$srredirects = null, $sroffest = null, $srlimit = null
)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($srsearch))
{
$path .= '&srsearch=' . $srsearch;
}
if (isset($srnamespace))
{
$path .= '&srnamespace=' . $this->buildParameter($srnamespace);
}
if (isset($srwhat))
{
$path .= '&srwhat=' . $srwhat;
}
if (isset($srinfo))
{
$path .= '&srinfo=' . $this->buildParameter($srinfo);
}
if (isset($srprop))
{
$path .= '&srprop=' . $this->buildParameter($srprop);
}
if ($srredirects)
{
$path .= '&srredirects=';
}
if (isset($sroffest))
{
$path .= '&sroffest=' . $sroffest;
}
if (isset($srlimit))
{
$path .= '&srlimit=' . $srlimit;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
} | [
"public",
"function",
"search",
"(",
"$",
"srsearch",
",",
"array",
"$",
"srnamespace",
"=",
"null",
",",
"$",
"srwhat",
"=",
"null",
",",
"array",
"$",
"srinfo",
"=",
"null",
",",
"array",
"$",
"srprop",
"=",
"null",
",",
"$",
"srredirects",
"=",
"null",
",",
"$",
"sroffest",
"=",
"null",
",",
"$",
"srlimit",
"=",
"null",
")",
"{",
"// Build the request.",
"$",
"path",
"=",
"'?action=query&list=search'",
";",
"if",
"(",
"isset",
"(",
"$",
"srsearch",
")",
")",
"{",
"$",
"path",
".=",
"'&srsearch='",
".",
"$",
"srsearch",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"srnamespace",
")",
")",
"{",
"$",
"path",
".=",
"'&srnamespace='",
".",
"$",
"this",
"->",
"buildParameter",
"(",
"$",
"srnamespace",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"srwhat",
")",
")",
"{",
"$",
"path",
".=",
"'&srwhat='",
".",
"$",
"srwhat",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"srinfo",
")",
")",
"{",
"$",
"path",
".=",
"'&srinfo='",
".",
"$",
"this",
"->",
"buildParameter",
"(",
"$",
"srinfo",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"srprop",
")",
")",
"{",
"$",
"path",
".=",
"'&srprop='",
".",
"$",
"this",
"->",
"buildParameter",
"(",
"$",
"srprop",
")",
";",
"}",
"if",
"(",
"$",
"srredirects",
")",
"{",
"$",
"path",
".=",
"'&srredirects='",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"sroffest",
")",
")",
"{",
"$",
"path",
".=",
"'&sroffest='",
".",
"$",
"sroffest",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"srlimit",
")",
")",
"{",
"$",
"path",
".=",
"'&srlimit='",
".",
"$",
"srlimit",
";",
"}",
"// Send the request.",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
";",
"return",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"response",
")",
";",
"}"
] | Method to perform a full text search.
@param string $srsearch Search for all page titles (or content) that has this value.
@param array $srnamespace The namespace(s) to enumerate.
@param string $srwhat Search inside the text or titles.
@param array $srinfo What metadata to return.
@param array $srprop What properties to return.
@param boolean $srredirects Include redirect pages in the search.
@param integer $sroffest Use this value to continue paging.
@param integer $srlimit How many total pages to return.
@return object
@since 1.0 | [
"Method",
"to",
"perform",
"a",
"full",
"text",
"search",
"."
] | 8855d51b61d5518bd92a0806fbd3098f4e063619 | https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Search.php#L34-L85 |
9,080 | joomla-framework/mediawiki-api | src/Search.php | Search.openSearch | public function openSearch($search, $limit = null, array $namespace = null, $suggest = null, $format = null)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($search))
{
$path .= '&search=' . $search;
}
if (isset($limit))
{
$path .= '&limit=' . $limit;
}
if (isset($namespace))
{
$path .= '&namespace=' . $this->buildParameter($namespace);
}
if (isset($suggest))
{
$path .= '&suggest=' . $suggest;
}
if (isset($format))
{
$path .= '&format=' . $format;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
} | php | public function openSearch($search, $limit = null, array $namespace = null, $suggest = null, $format = null)
{
// Build the request.
$path = '?action=query&list=search';
if (isset($search))
{
$path .= '&search=' . $search;
}
if (isset($limit))
{
$path .= '&limit=' . $limit;
}
if (isset($namespace))
{
$path .= '&namespace=' . $this->buildParameter($namespace);
}
if (isset($suggest))
{
$path .= '&suggest=' . $suggest;
}
if (isset($format))
{
$path .= '&format=' . $format;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
} | [
"public",
"function",
"openSearch",
"(",
"$",
"search",
",",
"$",
"limit",
"=",
"null",
",",
"array",
"$",
"namespace",
"=",
"null",
",",
"$",
"suggest",
"=",
"null",
",",
"$",
"format",
"=",
"null",
")",
"{",
"// Build the request.",
"$",
"path",
"=",
"'?action=query&list=search'",
";",
"if",
"(",
"isset",
"(",
"$",
"search",
")",
")",
"{",
"$",
"path",
".=",
"'&search='",
".",
"$",
"search",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"path",
".=",
"'&limit='",
".",
"$",
"limit",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"path",
".=",
"'&namespace='",
".",
"$",
"this",
"->",
"buildParameter",
"(",
"$",
"namespace",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"suggest",
")",
")",
"{",
"$",
"path",
".=",
"'&suggest='",
".",
"$",
"suggest",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"format",
")",
")",
"{",
"$",
"path",
".=",
"'&format='",
".",
"$",
"format",
";",
"}",
"// Send the request.",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"path",
")",
")",
";",
"return",
"$",
"this",
"->",
"validateResponse",
"(",
"$",
"response",
")",
";",
"}"
] | Method to search the wiki using opensearch protocol.
@param string $search Search string.
@param integer $limit Maximum amount of results to return.
@param array $namespace Namespaces to search.
@param string $suggest Do nothing if $wgEnableOpenSearchSuggest is false.
@param string $format Output format.
@return object
@since 1.0 | [
"Method",
"to",
"search",
"the",
"wiki",
"using",
"opensearch",
"protocol",
"."
] | 8855d51b61d5518bd92a0806fbd3098f4e063619 | https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Search.php#L100-L134 |
9,081 | jmpantoja/planb-utils | src/DS/Queue/AbstractQueue.php | AbstractQueue.push | public function push($value): QueueInterface
{
$this->resolver->value(function ($value): void {
$this->items->push($value);
}, $value);
return $this;
} | php | public function push($value): QueueInterface
{
$this->resolver->value(function ($value): void {
$this->items->push($value);
}, $value);
return $this;
} | [
"public",
"function",
"push",
"(",
"$",
"value",
")",
":",
"QueueInterface",
"{",
"$",
"this",
"->",
"resolver",
"->",
"value",
"(",
"function",
"(",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"items",
"->",
"push",
"(",
"$",
"value",
")",
";",
"}",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Pushes one value onto the top of the queue.
@param mixed $value
@return \PlanB\DS\Queue\QueueInterface | [
"Pushes",
"one",
"value",
"onto",
"the",
"top",
"of",
"the",
"queue",
"."
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Queue/AbstractQueue.php#L82-L90 |
9,082 | webriq/core | module/Customize/src/Grid/Customize/Model/Rpc.php | Rpc.isSelectorAvailable | public function isSelectorAvailable( $selector,
$fields = array(),
$rootId = null )
{
if ( is_scalar( $fields ) )
{
$media = (string) $fields;
$id = null;
}
else
{
$fields = (object) $fields;
$media = empty( $fields->media ) ? '' : $fields->media;
$rootId = empty( $fields->rootParagraphId ) ? null : (int) $fields->rootParagraphId;
$id = empty( $fields->id ) ? null : (int) $fields->id;
}
if ( $this->getRuleMapper()
->isSelectorExists( $selector, $media, $rootId, $id ) )
{
return static::SELECTOR_TAKEN;
}
$matches = array();
if ( preg_match( '/#paragraph-(\\d+)/', $selector, $matches ) )
{
if ( ! $this->getParagraphMapper()
->isParagraphIdExists( $matches[1] ) )
{
return static::SELECTOR_PARAGRAPH_NOT_EXISTS;
}
}
return static::SUCCESS;
} | php | public function isSelectorAvailable( $selector,
$fields = array(),
$rootId = null )
{
if ( is_scalar( $fields ) )
{
$media = (string) $fields;
$id = null;
}
else
{
$fields = (object) $fields;
$media = empty( $fields->media ) ? '' : $fields->media;
$rootId = empty( $fields->rootParagraphId ) ? null : (int) $fields->rootParagraphId;
$id = empty( $fields->id ) ? null : (int) $fields->id;
}
if ( $this->getRuleMapper()
->isSelectorExists( $selector, $media, $rootId, $id ) )
{
return static::SELECTOR_TAKEN;
}
$matches = array();
if ( preg_match( '/#paragraph-(\\d+)/', $selector, $matches ) )
{
if ( ! $this->getParagraphMapper()
->isParagraphIdExists( $matches[1] ) )
{
return static::SELECTOR_PARAGRAPH_NOT_EXISTS;
}
}
return static::SUCCESS;
} | [
"public",
"function",
"isSelectorAvailable",
"(",
"$",
"selector",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"rootId",
"=",
"null",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"media",
"=",
"(",
"string",
")",
"$",
"fields",
";",
"$",
"id",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"fields",
"=",
"(",
"object",
")",
"$",
"fields",
";",
"$",
"media",
"=",
"empty",
"(",
"$",
"fields",
"->",
"media",
")",
"?",
"''",
":",
"$",
"fields",
"->",
"media",
";",
"$",
"rootId",
"=",
"empty",
"(",
"$",
"fields",
"->",
"rootParagraphId",
")",
"?",
"null",
":",
"(",
"int",
")",
"$",
"fields",
"->",
"rootParagraphId",
";",
"$",
"id",
"=",
"empty",
"(",
"$",
"fields",
"->",
"id",
")",
"?",
"null",
":",
"(",
"int",
")",
"$",
"fields",
"->",
"id",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getRuleMapper",
"(",
")",
"->",
"isSelectorExists",
"(",
"$",
"selector",
",",
"$",
"media",
",",
"$",
"rootId",
",",
"$",
"id",
")",
")",
"{",
"return",
"static",
"::",
"SELECTOR_TAKEN",
";",
"}",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/#paragraph-(\\\\d+)/'",
",",
"$",
"selector",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getParagraphMapper",
"(",
")",
"->",
"isParagraphIdExists",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"static",
"::",
"SELECTOR_PARAGRAPH_NOT_EXISTS",
";",
"}",
"}",
"return",
"static",
"::",
"SUCCESS",
";",
"}"
] | Is selector available
@param string $email
@param array|object|string $fields [optional]
@param int|null $rootId [optional]
@return string | [
"Is",
"selector",
"available"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rpc.php#L109-L144 |
9,083 | mchorse/crystal-edge.php | src/FileSystemExtract.php | FileSystemExtract.extract | public function extract()
{
$iterator = new \RecursiveDirectoryIterator($this->path);
$iterator = new \RecursiveIteratorIterator($iterator);
$pages = [];
$files = iterator_to_array($iterator);
$files = array_filter($files, function($file)
{
return $file->isFile();
});
foreach($files as $path)
{
$pages[$this->exclude($path)] = compact('path');
}
return $pages;
} | php | public function extract()
{
$iterator = new \RecursiveDirectoryIterator($this->path);
$iterator = new \RecursiveIteratorIterator($iterator);
$pages = [];
$files = iterator_to_array($iterator);
$files = array_filter($files, function($file)
{
return $file->isFile();
});
foreach($files as $path)
{
$pages[$this->exclude($path)] = compact('path');
}
return $pages;
} | [
"public",
"function",
"extract",
"(",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"path",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"iterator",
")",
";",
"$",
"pages",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"iterator_to_array",
"(",
"$",
"iterator",
")",
";",
"$",
"files",
"=",
"array_filter",
"(",
"$",
"files",
",",
"function",
"(",
"$",
"file",
")",
"{",
"return",
"$",
"file",
"->",
"isFile",
"(",
")",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"path",
")",
"{",
"$",
"pages",
"[",
"$",
"this",
"->",
"exclude",
"(",
"$",
"path",
")",
"]",
"=",
"compact",
"(",
"'path'",
")",
";",
"}",
"return",
"$",
"pages",
";",
"}"
] | Extract web pages from file system from given path | [
"Extract",
"web",
"pages",
"from",
"file",
"system",
"from",
"given",
"path"
] | b030f3a124be9ac0b76ed180ca31035180ab9321 | https://github.com/mchorse/crystal-edge.php/blob/b030f3a124be9ac0b76ed180ca31035180ab9321/src/FileSystemExtract.php#L28-L46 |
9,084 | erickmcarvalho/likepdo | src/LikePDO/LikePDO.php | LikePDO.beginTransaction | public function beginTransaction()
{
if($this->supportTransaction == false)
{
throw new LikePDOException("This driver doesn't support transactions");
return false;
}
elseif($this->inTransaction == true)
{
throw new LikePDOException("There is already an active transaction");
return false;
}
else
{
if(!$this->driver->beginTransaction())
{
throw new LikePDOException("Failed to begin transaction");
return false;
}
return true;
}
} | php | public function beginTransaction()
{
if($this->supportTransaction == false)
{
throw new LikePDOException("This driver doesn't support transactions");
return false;
}
elseif($this->inTransaction == true)
{
throw new LikePDOException("There is already an active transaction");
return false;
}
else
{
if(!$this->driver->beginTransaction())
{
throw new LikePDOException("Failed to begin transaction");
return false;
}
return true;
}
} | [
"public",
"function",
"beginTransaction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportTransaction",
"==",
"false",
")",
"{",
"throw",
"new",
"LikePDOException",
"(",
"\"This driver doesn't support transactions\"",
")",
";",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"inTransaction",
"==",
"true",
")",
"{",
"throw",
"new",
"LikePDOException",
"(",
"\"There is already an active transaction\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"driver",
"->",
"beginTransaction",
"(",
")",
")",
"{",
"throw",
"new",
"LikePDOException",
"(",
"\"Failed to begin transaction\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"}"
] | Initiates a transaction
@return boolean | [
"Initiates",
"a",
"transaction"
] | 469f82f63d98fbabacdcdc27cb770b112428e4e5 | https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/LikePDO.php#L167-L189 |
9,085 | erickmcarvalho/likepdo | src/LikePDO/LikePDO.php | LikePDO.errorInfo | public function errorInfo()
{
return array
(
0 => $this->driver->getSQLState(),
1 => $this->driver->getErrorCode(),
2 => $this->driver->getLastMessage()
);
} | php | public function errorInfo()
{
return array
(
0 => $this->driver->getSQLState(),
1 => $this->driver->getErrorCode(),
2 => $this->driver->getLastMessage()
);
} | [
"public",
"function",
"errorInfo",
"(",
")",
"{",
"return",
"array",
"(",
"0",
"=>",
"$",
"this",
"->",
"driver",
"->",
"getSQLState",
"(",
")",
",",
"1",
"=>",
"$",
"this",
"->",
"driver",
"->",
"getErrorCode",
"(",
")",
",",
"2",
"=>",
"$",
"this",
"->",
"driver",
"->",
"getLastMessage",
"(",
")",
")",
";",
"}"
] | Fetch extended error information associated with the last operation on the database handle
@return array Array of error information about the last operation performed by this database handle. | [
"Fetch",
"extended",
"error",
"information",
"associated",
"with",
"the",
"last",
"operation",
"on",
"the",
"database",
"handle"
] | 469f82f63d98fbabacdcdc27cb770b112428e4e5 | https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/LikePDO.php#L230-L238 |
9,086 | erickmcarvalho/likepdo | src/LikePDO/LikePDO.php | LikePDO.getAvailableDrivers | public function getAvailableDrivers()
{
$drivers = array();
if(count($this->drivers) > 0)
{
foreach($this->drivers as $driver)
{
if(class_exists("LikePDO\\Drivers\\".$driver."Driver"))
{
$drivers[] = $driver;
}
}
}
return $drivers;
} | php | public function getAvailableDrivers()
{
$drivers = array();
if(count($this->drivers) > 0)
{
foreach($this->drivers as $driver)
{
if(class_exists("LikePDO\\Drivers\\".$driver."Driver"))
{
$drivers[] = $driver;
}
}
}
return $drivers;
} | [
"public",
"function",
"getAvailableDrivers",
"(",
")",
"{",
"$",
"drivers",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"drivers",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"drivers",
"as",
"$",
"driver",
")",
"{",
"if",
"(",
"class_exists",
"(",
"\"LikePDO\\\\Drivers\\\\\"",
".",
"$",
"driver",
".",
"\"Driver\"",
")",
")",
"{",
"$",
"drivers",
"[",
"]",
"=",
"$",
"driver",
";",
"}",
"}",
"}",
"return",
"$",
"drivers",
";",
"}"
] | Return an array of available LikePDO drivers
@return array | [
"Return",
"an",
"array",
"of",
"available",
"LikePDO",
"drivers"
] | 469f82f63d98fbabacdcdc27cb770b112428e4e5 | https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/LikePDO.php#L276-L292 |
9,087 | erickmcarvalho/likepdo | src/LikePDO/LikePDO.php | LikePDO.query | public function query($statement, $fetch_type = NULL, $fetch_arga = NULL, $fetch_argb = NULL)
{
if(!$fetch_type)
$fetch_type = LikePDO::FETCH_ASSOC;
$statement = new LikePDOStatement($statement, $this);
$statement->setFetchMode($fetch_type, $fetch_arga, $fetch_argb);
$statement->execute();
return $statement->fetchAll();
} | php | public function query($statement, $fetch_type = NULL, $fetch_arga = NULL, $fetch_argb = NULL)
{
if(!$fetch_type)
$fetch_type = LikePDO::FETCH_ASSOC;
$statement = new LikePDOStatement($statement, $this);
$statement->setFetchMode($fetch_type, $fetch_arga, $fetch_argb);
$statement->execute();
return $statement->fetchAll();
} | [
"public",
"function",
"query",
"(",
"$",
"statement",
",",
"$",
"fetch_type",
"=",
"NULL",
",",
"$",
"fetch_arga",
"=",
"NULL",
",",
"$",
"fetch_argb",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"fetch_type",
")",
"$",
"fetch_type",
"=",
"LikePDO",
"::",
"FETCH_ASSOC",
";",
"$",
"statement",
"=",
"new",
"LikePDOStatement",
"(",
"$",
"statement",
",",
"$",
"this",
")",
";",
"$",
"statement",
"->",
"setFetchMode",
"(",
"$",
"fetch_type",
",",
"$",
"fetch_arga",
",",
"$",
"fetch_argb",
")",
";",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"statement",
"->",
"fetchAll",
"(",
")",
";",
"}"
] | Executes an SQL statement, returning a result set as a LikePDOStatement object
@param string $statement - The SQL statement to prepare and execute.
@param integer $fetch_type - LikePDO::FETCH_COLUMN / LikePDO::FETCH_CLASS / LikePDO::FETCH_INTO [default -> NULL]
@param mixed $fetch_arga - [int $colno] / [string $classname] / [object $object]
@param mixed $fetch_argb - [array $ctorargs] | [
"Executes",
"an",
"SQL",
"statement",
"returning",
"a",
"result",
"set",
"as",
"a",
"LikePDOStatement",
"object"
] | 469f82f63d98fbabacdcdc27cb770b112428e4e5 | https://github.com/erickmcarvalho/likepdo/blob/469f82f63d98fbabacdcdc27cb770b112428e4e5/src/LikePDO/LikePDO.php#L336-L346 |
9,088 | devbr/tools | Cli/Optimizer.php | Optimizer.jssCompiler | private function jssCompiler($config)
{
if (!isset($config->filename)) {
echo "ERROR!!\n";
return false;
}
$content = "var JSS = Array();\n";
$width = 4096;
//CSS
if (isset($config->css)) {
$tmp = $this->minify(false,
$config->css,
$this->yuicompressor,
$this->config->baseDir);
$tmp = explode("\n", str_replace("'", "\'", $tmp));
foreach ($tmp as $k => $v) {
$v = trim($v);
if ($v == '') {
continue;
}
if (substr($v, -1) == '\\') {
$v .= '\\';
}
$content .= 'JSS['.$k.'] = \''.$v."';\n";
}
}
//Função para montagem do STYLE
$content .= 'for(var i in JSS){var etmp=document.createElement("STYLE");etmp.type="text/css";etmp.innerHTML=JSS[i];document.head.appendChild(etmp);}document.getElementsByClassName("container")[0].style.display="block";document.getElementById("loader").style.display="none";'."\n";
//Javascripts
if (isset($config->js)) {
$content .= $this->minify(false,
$config->js,
$this->yuicompressor,
$this->config->baseDir);
}
file_put_contents($config->filename, $content);
echo "\n\n Saving: ".$config->filename."\n";
} | php | private function jssCompiler($config)
{
if (!isset($config->filename)) {
echo "ERROR!!\n";
return false;
}
$content = "var JSS = Array();\n";
$width = 4096;
//CSS
if (isset($config->css)) {
$tmp = $this->minify(false,
$config->css,
$this->yuicompressor,
$this->config->baseDir);
$tmp = explode("\n", str_replace("'", "\'", $tmp));
foreach ($tmp as $k => $v) {
$v = trim($v);
if ($v == '') {
continue;
}
if (substr($v, -1) == '\\') {
$v .= '\\';
}
$content .= 'JSS['.$k.'] = \''.$v."';\n";
}
}
//Função para montagem do STYLE
$content .= 'for(var i in JSS){var etmp=document.createElement("STYLE");etmp.type="text/css";etmp.innerHTML=JSS[i];document.head.appendChild(etmp);}document.getElementsByClassName("container")[0].style.display="block";document.getElementById("loader").style.display="none";'."\n";
//Javascripts
if (isset($config->js)) {
$content .= $this->minify(false,
$config->js,
$this->yuicompressor,
$this->config->baseDir);
}
file_put_contents($config->filename, $content);
echo "\n\n Saving: ".$config->filename."\n";
} | [
"private",
"function",
"jssCompiler",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"->",
"filename",
")",
")",
"{",
"echo",
"\"ERROR!!\\n\"",
";",
"return",
"false",
";",
"}",
"$",
"content",
"=",
"\"var JSS = Array();\\n\"",
";",
"$",
"width",
"=",
"4096",
";",
"//CSS",
"if",
"(",
"isset",
"(",
"$",
"config",
"->",
"css",
")",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"minify",
"(",
"false",
",",
"$",
"config",
"->",
"css",
",",
"$",
"this",
"->",
"yuicompressor",
",",
"$",
"this",
"->",
"config",
"->",
"baseDir",
")",
";",
"$",
"tmp",
"=",
"explode",
"(",
"\"\\n\"",
",",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"tmp",
")",
")",
";",
"foreach",
"(",
"$",
"tmp",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"v",
"=",
"trim",
"(",
"$",
"v",
")",
";",
"if",
"(",
"$",
"v",
"==",
"''",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"v",
",",
"-",
"1",
")",
"==",
"'\\\\'",
")",
"{",
"$",
"v",
".=",
"'\\\\'",
";",
"}",
"$",
"content",
".=",
"'JSS['",
".",
"$",
"k",
".",
"'] = \\''",
".",
"$",
"v",
".",
"\"';\\n\"",
";",
"}",
"}",
"//Função para montagem do STYLE",
"$",
"content",
".=",
"'for(var i in JSS){var etmp=document.createElement(\"STYLE\");etmp.type=\"text/css\";etmp.innerHTML=JSS[i];document.head.appendChild(etmp);}document.getElementsByClassName(\"container\")[0].style.display=\"block\";document.getElementById(\"loader\").style.display=\"none\";'",
".",
"\"\\n\"",
";",
"//Javascripts",
"if",
"(",
"isset",
"(",
"$",
"config",
"->",
"js",
")",
")",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"minify",
"(",
"false",
",",
"$",
"config",
"->",
"js",
",",
"$",
"this",
"->",
"yuicompressor",
",",
"$",
"this",
"->",
"config",
"->",
"baseDir",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"config",
"->",
"filename",
",",
"$",
"content",
")",
";",
"echo",
"\"\\n\\n Saving: \"",
".",
"$",
"config",
"->",
"filename",
".",
"\"\\n\"",
";",
"}"
] | Jointer JS & CSS
@param object $config configuration data
@return void save file | [
"Jointer",
"JS",
"&",
"CSS"
] | f23f35172143b4ab2f45db37274fcc94d32e20e8 | https://github.com/devbr/tools/blob/f23f35172143b4ab2f45db37274fcc94d32e20e8/Cli/Optimizer.php#L199-L245 |
9,089 | phlexible/phlexible | src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php | FolderController.renameAction | public function renameAction(Request $request)
{
$volumeId = $request->get('site_id');
$folderId = $request->get('folder_id');
$folderName = $request->get('folder_name');
$volume = $this->getVolume($volumeId);
$folder = $volume->findFolder($folderId);
$volume->renameFolder($folder, $folderName, $this->getUser()->getId());
return new ResultResponse(true, 'Folder renamed.', [
'folder_name' => $folderName,
]);
} | php | public function renameAction(Request $request)
{
$volumeId = $request->get('site_id');
$folderId = $request->get('folder_id');
$folderName = $request->get('folder_name');
$volume = $this->getVolume($volumeId);
$folder = $volume->findFolder($folderId);
$volume->renameFolder($folder, $folderName, $this->getUser()->getId());
return new ResultResponse(true, 'Folder renamed.', [
'folder_name' => $folderName,
]);
} | [
"public",
"function",
"renameAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"volumeId",
"=",
"$",
"request",
"->",
"get",
"(",
"'site_id'",
")",
";",
"$",
"folderId",
"=",
"$",
"request",
"->",
"get",
"(",
"'folder_id'",
")",
";",
"$",
"folderName",
"=",
"$",
"request",
"->",
"get",
"(",
"'folder_name'",
")",
";",
"$",
"volume",
"=",
"$",
"this",
"->",
"getVolume",
"(",
"$",
"volumeId",
")",
";",
"$",
"folder",
"=",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"folderId",
")",
";",
"$",
"volume",
"->",
"renameFolder",
"(",
"$",
"folder",
",",
"$",
"folderName",
",",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"'Folder renamed.'",
",",
"[",
"'folder_name'",
"=>",
"$",
"folderName",
",",
"]",
")",
";",
"}"
] | Rename folder.
@param Request $request
@return ResultResponse
@Route("/rename", name="mediamanager_folder_rename") | [
"Rename",
"folder",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php#L288-L302 |
9,090 | phlexible/phlexible | src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php | FolderController.moveAction | public function moveAction(Request $request)
{
$volumeId = $request->get('site_id');
$targetId = $request->get('target_id');
$sourceId = $request->get('source_id');
$volume = $this->getVolume($volumeId);
$folder = $volume->findFolder($sourceId);
$targetFolder = $volume->findFolder($targetId);
$volume->moveFolder($folder, $targetFolder, $this->getUser()->getId());
return new ResultResponse(true);
} | php | public function moveAction(Request $request)
{
$volumeId = $request->get('site_id');
$targetId = $request->get('target_id');
$sourceId = $request->get('source_id');
$volume = $this->getVolume($volumeId);
$folder = $volume->findFolder($sourceId);
$targetFolder = $volume->findFolder($targetId);
$volume->moveFolder($folder, $targetFolder, $this->getUser()->getId());
return new ResultResponse(true);
} | [
"public",
"function",
"moveAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"volumeId",
"=",
"$",
"request",
"->",
"get",
"(",
"'site_id'",
")",
";",
"$",
"targetId",
"=",
"$",
"request",
"->",
"get",
"(",
"'target_id'",
")",
";",
"$",
"sourceId",
"=",
"$",
"request",
"->",
"get",
"(",
"'source_id'",
")",
";",
"$",
"volume",
"=",
"$",
"this",
"->",
"getVolume",
"(",
"$",
"volumeId",
")",
";",
"$",
"folder",
"=",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"sourceId",
")",
";",
"$",
"targetFolder",
"=",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"targetId",
")",
";",
"$",
"volume",
"->",
"moveFolder",
"(",
"$",
"folder",
",",
"$",
"targetFolder",
",",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
")",
";",
"}"
] | Move folder.
@param Request $request
@return ResultResponse
@Route("/move", name="mediamanager_folder_move") | [
"Move",
"folder",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php#L337-L350 |
9,091 | phlexible/phlexible | src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php | FolderController.propertiesAction | public function propertiesAction(Request $request)
{
$folderId = $request->get('folder_id');
$volumeManager = $this->get('phlexible_media_manager.volume_manager');
$volume = $volumeManager->getByFolderId($folderId);
try {
$folder = $volume->findFolder($folderId);
$calculator = new SizeCalculator();
$calculatedSize = $calculator->calculate($volume, $folder);
$data = [
'title' => $folder->getName(),
'type' => 'folder',
'path' => '/'.$folder->getPath(),
'size' => $calculatedSize->getSize(),
'files' => $calculatedSize->getNumFiles(),
'folders' => $calculatedSize->getNumFolders(),
'create_time' => $folder->getCreatedAt()->format('U') * 1000,
'create_user' => $folder->getCreateUserId(),
'modify_time' => $folder->getModifiedAt()->format('U') * 1000,
'modify_user' => $folder->getModifyUserId(),
];
} catch (\Exception $e) {
$data = [];
}
return new JsonResponse($data);
} | php | public function propertiesAction(Request $request)
{
$folderId = $request->get('folder_id');
$volumeManager = $this->get('phlexible_media_manager.volume_manager');
$volume = $volumeManager->getByFolderId($folderId);
try {
$folder = $volume->findFolder($folderId);
$calculator = new SizeCalculator();
$calculatedSize = $calculator->calculate($volume, $folder);
$data = [
'title' => $folder->getName(),
'type' => 'folder',
'path' => '/'.$folder->getPath(),
'size' => $calculatedSize->getSize(),
'files' => $calculatedSize->getNumFiles(),
'folders' => $calculatedSize->getNumFolders(),
'create_time' => $folder->getCreatedAt()->format('U') * 1000,
'create_user' => $folder->getCreateUserId(),
'modify_time' => $folder->getModifiedAt()->format('U') * 1000,
'modify_user' => $folder->getModifyUserId(),
];
} catch (\Exception $e) {
$data = [];
}
return new JsonResponse($data);
} | [
"public",
"function",
"propertiesAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"folderId",
"=",
"$",
"request",
"->",
"get",
"(",
"'folder_id'",
")",
";",
"$",
"volumeManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_media_manager.volume_manager'",
")",
";",
"$",
"volume",
"=",
"$",
"volumeManager",
"->",
"getByFolderId",
"(",
"$",
"folderId",
")",
";",
"try",
"{",
"$",
"folder",
"=",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"folderId",
")",
";",
"$",
"calculator",
"=",
"new",
"SizeCalculator",
"(",
")",
";",
"$",
"calculatedSize",
"=",
"$",
"calculator",
"->",
"calculate",
"(",
"$",
"volume",
",",
"$",
"folder",
")",
";",
"$",
"data",
"=",
"[",
"'title'",
"=>",
"$",
"folder",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"'folder'",
",",
"'path'",
"=>",
"'/'",
".",
"$",
"folder",
"->",
"getPath",
"(",
")",
",",
"'size'",
"=>",
"$",
"calculatedSize",
"->",
"getSize",
"(",
")",
",",
"'files'",
"=>",
"$",
"calculatedSize",
"->",
"getNumFiles",
"(",
")",
",",
"'folders'",
"=>",
"$",
"calculatedSize",
"->",
"getNumFolders",
"(",
")",
",",
"'create_time'",
"=>",
"$",
"folder",
"->",
"getCreatedAt",
"(",
")",
"->",
"format",
"(",
"'U'",
")",
"*",
"1000",
",",
"'create_user'",
"=>",
"$",
"folder",
"->",
"getCreateUserId",
"(",
")",
",",
"'modify_time'",
"=>",
"$",
"folder",
"->",
"getModifiedAt",
"(",
")",
"->",
"format",
"(",
"'U'",
")",
"*",
"1000",
",",
"'modify_user'",
"=>",
"$",
"folder",
"->",
"getModifyUserId",
"(",
")",
",",
"]",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"data",
")",
";",
"}"
] | Folder properties.
@param Request $request
@return JsonResponse
@Route("/properties", name="mediamanager_folder_properties") | [
"Folder",
"properties",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MediaManagerBundle/Controller/FolderController.php#L360-L389 |
9,092 | chippyash/Validation | src/Chippyash/Validation/Util/IpUtil.php | IpUtil.isValidIP | public static function isValidIP($ipAddr, $allowipv6 = false)
{
$validator = new ZendIp(array('allowipv6' => $allowipv6));
return $validator->isValid($ipAddr);
} | php | public static function isValidIP($ipAddr, $allowipv6 = false)
{
$validator = new ZendIp(array('allowipv6' => $allowipv6));
return $validator->isValid($ipAddr);
} | [
"public",
"static",
"function",
"isValidIP",
"(",
"$",
"ipAddr",
",",
"$",
"allowipv6",
"=",
"false",
")",
"{",
"$",
"validator",
"=",
"new",
"ZendIp",
"(",
"array",
"(",
"'allowipv6'",
"=>",
"$",
"allowipv6",
")",
")",
";",
"return",
"$",
"validator",
"->",
"isValid",
"(",
"$",
"ipAddr",
")",
";",
"}"
] | Check if string is a valid ip address
@param string $ipAddr
@param boolean $allowipv6
@return boolean | [
"Check",
"if",
"string",
"is",
"a",
"valid",
"ip",
"address"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Util/IpUtil.php#L77-L81 |
9,093 | chippyash/Validation | src/Chippyash/Validation/Util/IpUtil.php | IpUtil.cidrMatch32bit | protected static function cidrMatch32bit($ipAddr, $cidr)
{
list ($subNet, $bits) = explode('/', $cidr);
$ipLong = \ip2long($ipAddr);
$subnetLong = \ip2long($subNet);
$mask = -1 << (32 - $bits);
$subnetLong &= $mask; // nb: in case the supplied subnet wasn't correctly aligned
return ($ipLong & $mask) == $subnetLong;
} | php | protected static function cidrMatch32bit($ipAddr, $cidr)
{
list ($subNet, $bits) = explode('/', $cidr);
$ipLong = \ip2long($ipAddr);
$subnetLong = \ip2long($subNet);
$mask = -1 << (32 - $bits);
$subnetLong &= $mask; // nb: in case the supplied subnet wasn't correctly aligned
return ($ipLong & $mask) == $subnetLong;
} | [
"protected",
"static",
"function",
"cidrMatch32bit",
"(",
"$",
"ipAddr",
",",
"$",
"cidr",
")",
"{",
"list",
"(",
"$",
"subNet",
",",
"$",
"bits",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"cidr",
")",
";",
"$",
"ipLong",
"=",
"\\",
"ip2long",
"(",
"$",
"ipAddr",
")",
";",
"$",
"subnetLong",
"=",
"\\",
"ip2long",
"(",
"$",
"subNet",
")",
";",
"$",
"mask",
"=",
"-",
"1",
"<<",
"(",
"32",
"-",
"$",
"bits",
")",
";",
"$",
"subnetLong",
"&=",
"$",
"mask",
";",
"// nb: in case the supplied subnet wasn't correctly aligned",
"return",
"(",
"$",
"ipLong",
"&",
"$",
"mask",
")",
"==",
"$",
"subnetLong",
";",
"}"
] | 32 bit processor CIDR match
@codeCoverageIgnore
@link http://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php5
@param string $ipAddr
@param string $cidr
@return boolean | [
"32",
"bit",
"processor",
"CIDR",
"match"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Util/IpUtil.php#L116-L124 |
9,094 | chippyash/Validation | src/Chippyash/Validation/Util/IpUtil.php | IpUtil.cidrMatch64bit | protected static function cidrMatch64bit($ipAddr, $cidr)
{
list ($sn, $bits) = explode('/', $cidr);
$ipLong = self::ip2long64($ipAddr, $bits);
$subnet = self::ip2long64($sn, $bits);
$mask = -1 << (32 - $bits);
return ($ipLong & $mask) == $subnet;
} | php | protected static function cidrMatch64bit($ipAddr, $cidr)
{
list ($sn, $bits) = explode('/', $cidr);
$ipLong = self::ip2long64($ipAddr, $bits);
$subnet = self::ip2long64($sn, $bits);
$mask = -1 << (32 - $bits);
return ($ipLong & $mask) == $subnet;
} | [
"protected",
"static",
"function",
"cidrMatch64bit",
"(",
"$",
"ipAddr",
",",
"$",
"cidr",
")",
"{",
"list",
"(",
"$",
"sn",
",",
"$",
"bits",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"cidr",
")",
";",
"$",
"ipLong",
"=",
"self",
"::",
"ip2long64",
"(",
"$",
"ipAddr",
",",
"$",
"bits",
")",
";",
"$",
"subnet",
"=",
"self",
"::",
"ip2long64",
"(",
"$",
"sn",
",",
"$",
"bits",
")",
";",
"$",
"mask",
"=",
"-",
"1",
"<<",
"(",
"32",
"-",
"$",
"bits",
")",
";",
"return",
"(",
"$",
"ipLong",
"&",
"$",
"mask",
")",
"==",
"$",
"subnet",
";",
"}"
] | 64 bit processor CIDR match
@link http://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php5
@param string $ipAddr
@param string $cidr
@return boolean | [
"64",
"bit",
"processor",
"CIDR",
"match"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Util/IpUtil.php#L135-L143 |
9,095 | phplegends/thumb | src/Thumb/Urlizer.php | Urlizer.buildThumbFilename | public function buildThumbFilename($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (! $extension) {
$filename .= '.' . pathinfo($this->relative, PATHINFO_EXTENSION);
}
return $this->getThumbFolder() . '/' . $filename;
} | php | public function buildThumbFilename($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (! $extension) {
$filename .= '.' . pathinfo($this->relative, PATHINFO_EXTENSION);
}
return $this->getThumbFolder() . '/' . $filename;
} | [
"public",
"function",
"buildThumbFilename",
"(",
"$",
"filename",
")",
"{",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"!",
"$",
"extension",
")",
"{",
"$",
"filename",
".=",
"'.'",
".",
"pathinfo",
"(",
"$",
"this",
"->",
"relative",
",",
"PATHINFO_EXTENSION",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getThumbFolder",
"(",
")",
".",
"'/'",
".",
"$",
"filename",
";",
"}"
] | Builds the filename for thumb image
@return string | [
"Builds",
"the",
"filename",
"for",
"thumb",
"image"
] | 962679265f7bf34893c23a82c34d73508cb84d29 | https://github.com/phplegends/thumb/blob/962679265f7bf34893c23a82c34d73508cb84d29/src/Thumb/Urlizer.php#L105-L115 |
9,096 | webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Snippet/Mapper.php | Mapper.getSavePath | public function getSavePath()
{
if ( empty( $this->savePath ) )
{
$this->savePath = sprintf(
static::SAVE_PATH,
$this->getSiteInfo()
->getSchema()
);
$dir = rtrim( $this->savePath, '/' );
if ( ! is_dir( $dir ) )
{
@ mkdir( $dir, 0777, true );
}
}
return $this->savePath;
} | php | public function getSavePath()
{
if ( empty( $this->savePath ) )
{
$this->savePath = sprintf(
static::SAVE_PATH,
$this->getSiteInfo()
->getSchema()
);
$dir = rtrim( $this->savePath, '/' );
if ( ! is_dir( $dir ) )
{
@ mkdir( $dir, 0777, true );
}
}
return $this->savePath;
} | [
"public",
"function",
"getSavePath",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"savePath",
")",
")",
"{",
"$",
"this",
"->",
"savePath",
"=",
"sprintf",
"(",
"static",
"::",
"SAVE_PATH",
",",
"$",
"this",
"->",
"getSiteInfo",
"(",
")",
"->",
"getSchema",
"(",
")",
")",
";",
"$",
"dir",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"savePath",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"@",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"savePath",
";",
"}"
] | Get save path
@return string | [
"Get",
"save",
"path"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Snippet/Mapper.php#L104-L123 |
9,097 | webriq/core | module/Paragraph/src/Grid/Paragraph/Model/Snippet/Mapper.php | Mapper.findAll | public function findAll()
{
return new CallbackMapIterator(
new FilesystemIterator(
$this->getSavePath(),
FilesystemIterator::SKIP_DOTS |
FilesystemIterator::KEY_AS_FILENAME |
FilesystemIterator::CURRENT_AS_FILEINFO
),
function ( SplFileInfo $info ) {
return $info->getFilename();
}
);
} | php | public function findAll()
{
return new CallbackMapIterator(
new FilesystemIterator(
$this->getSavePath(),
FilesystemIterator::SKIP_DOTS |
FilesystemIterator::KEY_AS_FILENAME |
FilesystemIterator::CURRENT_AS_FILEINFO
),
function ( SplFileInfo $info ) {
return $info->getFilename();
}
);
} | [
"public",
"function",
"findAll",
"(",
")",
"{",
"return",
"new",
"CallbackMapIterator",
"(",
"new",
"FilesystemIterator",
"(",
"$",
"this",
"->",
"getSavePath",
"(",
")",
",",
"FilesystemIterator",
"::",
"SKIP_DOTS",
"|",
"FilesystemIterator",
"::",
"KEY_AS_FILENAME",
"|",
"FilesystemIterator",
"::",
"CURRENT_AS_FILEINFO",
")",
",",
"function",
"(",
"SplFileInfo",
"$",
"info",
")",
"{",
"return",
"$",
"info",
"->",
"getFilename",
"(",
")",
";",
"}",
")",
";",
"}"
] | Find all snippets
@return \Iterator | [
"Find",
"all",
"snippets"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Snippet/Mapper.php#L331-L344 |
9,098 | railsphp/framework | src/Rails/ActiveModel/Attributes/AccessibleProperties.php | AccessibleProperties.getAccessibleProperties | protected function getAccessibleProperties($className)
{
$refl = $className::getReflection();
$props = [];
foreach ($refl->getProperties() as $prop) {
if (
$prop->getDeclaringClass()->getName() == 'Rails\ActiveModel\Base' ||
$prop->getDeclaringClass()->getName() == 'Rails\ActiveRecord\Base' ||
$prop->getDeclaringClass()->getName() == 'Rails\ActiveRecord\Mongo\Base'
) {
break;
}
if ($prop->isPublic()) {
$props[$prop->getName()] = [
'propName' => $prop->getName()
];
} else {
$params = [];
$getterMethodName = $prop->getName();
if (
$refl->hasMethod($getterMethodName) &&
($method = $refl->getMethod($getterMethodName)) &&
$method->isPublic()
) {
$params[] = $getterMethodName;
} else {
$params[] = false;
}
$setterMethodName = 'set' . ucfirst($prop->getName());
if (
$refl->hasMethod($setterMethodName) &&
($method = $refl->getMethod($setterMethodName)) &&
$method->isPublic()
) {
$params[] = $setterMethodName;
} else {
$params[] = false;
}
$props[$prop->getName()] = $params;
}
}
return $props;
} | php | protected function getAccessibleProperties($className)
{
$refl = $className::getReflection();
$props = [];
foreach ($refl->getProperties() as $prop) {
if (
$prop->getDeclaringClass()->getName() == 'Rails\ActiveModel\Base' ||
$prop->getDeclaringClass()->getName() == 'Rails\ActiveRecord\Base' ||
$prop->getDeclaringClass()->getName() == 'Rails\ActiveRecord\Mongo\Base'
) {
break;
}
if ($prop->isPublic()) {
$props[$prop->getName()] = [
'propName' => $prop->getName()
];
} else {
$params = [];
$getterMethodName = $prop->getName();
if (
$refl->hasMethod($getterMethodName) &&
($method = $refl->getMethod($getterMethodName)) &&
$method->isPublic()
) {
$params[] = $getterMethodName;
} else {
$params[] = false;
}
$setterMethodName = 'set' . ucfirst($prop->getName());
if (
$refl->hasMethod($setterMethodName) &&
($method = $refl->getMethod($setterMethodName)) &&
$method->isPublic()
) {
$params[] = $setterMethodName;
} else {
$params[] = false;
}
$props[$prop->getName()] = $params;
}
}
return $props;
} | [
"protected",
"function",
"getAccessibleProperties",
"(",
"$",
"className",
")",
"{",
"$",
"refl",
"=",
"$",
"className",
"::",
"getReflection",
"(",
")",
";",
"$",
"props",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"refl",
"->",
"getProperties",
"(",
")",
"as",
"$",
"prop",
")",
"{",
"if",
"(",
"$",
"prop",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"'Rails\\ActiveModel\\Base'",
"||",
"$",
"prop",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"'Rails\\ActiveRecord\\Base'",
"||",
"$",
"prop",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"'Rails\\ActiveRecord\\Mongo\\Base'",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"prop",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"props",
"[",
"$",
"prop",
"->",
"getName",
"(",
")",
"]",
"=",
"[",
"'propName'",
"=>",
"$",
"prop",
"->",
"getName",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"getterMethodName",
"=",
"$",
"prop",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"refl",
"->",
"hasMethod",
"(",
"$",
"getterMethodName",
")",
"&&",
"(",
"$",
"method",
"=",
"$",
"refl",
"->",
"getMethod",
"(",
"$",
"getterMethodName",
")",
")",
"&&",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"getterMethodName",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"]",
"=",
"false",
";",
"}",
"$",
"setterMethodName",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"prop",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"refl",
"->",
"hasMethod",
"(",
"$",
"setterMethodName",
")",
"&&",
"(",
"$",
"method",
"=",
"$",
"refl",
"->",
"getMethod",
"(",
"$",
"setterMethodName",
")",
")",
"&&",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"setterMethodName",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"]",
"=",
"false",
";",
"}",
"$",
"props",
"[",
"$",
"prop",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"params",
";",
"}",
"}",
"return",
"$",
"props",
";",
"}"
] | Get accessible properties.
An accessible property is either a public property, or a
property that has a setter method named like `setPropName`.
Returns an array whose keys are the property name, and the value
is the setter name if the property has a setter, or an array with
the actual property name under the `propName` key if its a public
property.
@param string $className
@return array | [
"Get",
"accessible",
"properties",
".",
"An",
"accessible",
"property",
"is",
"either",
"a",
"public",
"property",
"or",
"a",
"property",
"that",
"has",
"a",
"setter",
"method",
"named",
"like",
"setPropName",
".",
"Returns",
"an",
"array",
"whose",
"keys",
"are",
"the",
"property",
"name",
"and",
"the",
"value",
"is",
"the",
"setter",
"name",
"if",
"the",
"property",
"has",
"a",
"setter",
"or",
"an",
"array",
"with",
"the",
"actual",
"property",
"name",
"under",
"the",
"propName",
"key",
"if",
"its",
"a",
"public",
"property",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveModel/Attributes/AccessibleProperties.php#L78-L126 |
9,099 | RhubarbPHP/Module.Patterns | src/Mvp/BoilerPlates/Login/LoginPresenter.php | LoginPresenter.getLoginProvider | private function getLoginProvider()
{
if (!$this->loginProviderClassName) {
return Container::instance(LoginProvider::class);
}
$provider = $this->loginProviderClassName;
return new $provider();
} | php | private function getLoginProvider()
{
if (!$this->loginProviderClassName) {
return Container::instance(LoginProvider::class);
}
$provider = $this->loginProviderClassName;
return new $provider();
} | [
"private",
"function",
"getLoginProvider",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loginProviderClassName",
")",
"{",
"return",
"Container",
"::",
"instance",
"(",
"LoginProvider",
"::",
"class",
")",
";",
"}",
"$",
"provider",
"=",
"$",
"this",
"->",
"loginProviderClassName",
";",
"return",
"new",
"$",
"provider",
"(",
")",
";",
"}"
] | Returns the login provider for this presenter.
@return \Rhubarb\Stem\LoginProviders\ModelLoginProvider | [
"Returns",
"the",
"login",
"provider",
"for",
"this",
"presenter",
"."
] | 118b13b44bce7d35cb8aaa09135c47836098831f | https://github.com/RhubarbPHP/Module.Patterns/blob/118b13b44bce7d35cb8aaa09135c47836098831f/src/Mvp/BoilerPlates/Login/LoginPresenter.php#L73-L81 |
Subsets and Splits