repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
thephpleague/uri-components
src/Component/Query.php
Query.withoutNumericIndices
public function withoutNumericIndices(): self { $pairs = array_map([$this, 'encodeNumericIndices'], $this->pairs); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
php
public function withoutNumericIndices(): self { $pairs = array_map([$this, 'encodeNumericIndices'], $this->pairs); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
[ "public", "function", "withoutNumericIndices", "(", ")", ":", "self", "{", "$", "pairs", "=", "array_map", "(", "[", "$", "this", ",", "'encodeNumericIndices'", "]", ",", "$", "this", "->", "pairs", ")", ";", "if", "(", "$", "pairs", "===", "$", "this"...
Returns an instance where numeric indices associated to PHP's array like key are removed. This method MUST retain the state of the current instance, and return an instance that contains the query component normalized so that numeric indexes are removed from the pair key value. ie.: toto[3]=bar[3]&foo=bar becomes toto[]=bar[3]&foo=bar
[ "Returns", "an", "instance", "where", "numeric", "indices", "associated", "to", "PHP", "s", "array", "like", "key", "are", "removed", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L451-L462
thephpleague/uri-components
src/Component/Query.php
Query.withPair
public function withPair(string $key, $value): self { $pairs = $this->addPair($this->pairs, [$key, $this->filterPair($value)]); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
php
public function withPair(string $key, $value): self { $pairs = $this->addPair($this->pairs, [$key, $this->filterPair($value)]); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
[ "public", "function", "withPair", "(", "string", "$", "key", ",", "$", "value", ")", ":", "self", "{", "$", "pairs", "=", "$", "this", "->", "addPair", "(", "$", "this", "->", "pairs", ",", "[", "$", "key", ",", "$", "this", "->", "filterPair", "...
Returns an instance with the a new key/value pair added to it. This method MUST retain the state of the current instance, and return an instance that contains the modified query If the pair already exists the value will replace the existing value. @see https://url.spec.whatwg.org/#dom-urlsearchparams-set
[ "Returns", "an", "instance", "with", "the", "a", "new", "key", "/", "value", "pair", "added", "to", "it", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L486-L497
thephpleague/uri-components
src/Component/Query.php
Query.addPair
private function addPair(array $list, array $pair): array { $found = false; $reducer = static function (array $pairs, array $srcPair) use ($pair, &$found): array { if ($pair[0] !== $srcPair[0]) { $pairs[] = $srcPair; return $pairs; } if (!$found) { $pairs[] = $pair; $found = true; return $pairs; } return $pairs; }; $pairs = array_reduce($list, $reducer, []); if (!$found) { $pairs[] = $pair; } return $pairs; }
php
private function addPair(array $list, array $pair): array { $found = false; $reducer = static function (array $pairs, array $srcPair) use ($pair, &$found): array { if ($pair[0] !== $srcPair[0]) { $pairs[] = $srcPair; return $pairs; } if (!$found) { $pairs[] = $pair; $found = true; return $pairs; } return $pairs; }; $pairs = array_reduce($list, $reducer, []); if (!$found) { $pairs[] = $pair; } return $pairs; }
[ "private", "function", "addPair", "(", "array", "$", "list", ",", "array", "$", "pair", ")", ":", "array", "{", "$", "found", "=", "false", ";", "$", "reducer", "=", "static", "function", "(", "array", "$", "pairs", ",", "array", "$", "srcPair", ")",...
Add a new pair to the query key/value list. If there are any key/value pair whose kay is kay, in the list, set the value of the first such key/value pair to value and remove the others. Otherwise, append a new key/value pair whose key is key and value is value, to the list.
[ "Add", "a", "new", "pair", "to", "the", "query", "key", "/", "value", "list", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L506-L532
thephpleague/uri-components
src/Component/Query.php
Query.merge
public function merge($query): self { $pairs = $this->pairs; foreach (QueryString::parse($this->filterComponent($query), $this->separator, PHP_QUERY_RFC3986) as $pair) { $pairs = $this->addPair($pairs, $pair); } if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
php
public function merge($query): self { $pairs = $this->pairs; foreach (QueryString::parse($this->filterComponent($query), $this->separator, PHP_QUERY_RFC3986) as $pair) { $pairs = $this->addPair($pairs, $pair); } if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
[ "public", "function", "merge", "(", "$", "query", ")", ":", "self", "{", "$", "pairs", "=", "$", "this", "->", "pairs", ";", "foreach", "(", "QueryString", "::", "parse", "(", "$", "this", "->", "filterComponent", "(", "$", "query", ")", ",", "$", ...
Returns an instance with the new pairs set to it. This method MUST retain the state of the current instance, and return an instance that contains the modified query @see ::withPair
[ "Returns", "an", "instance", "with", "the", "new", "pairs", "set", "to", "it", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L542-L557
thephpleague/uri-components
src/Component/Query.php
Query.filterPair
private function filterPair($value) { if (null === $value || is_scalar($value)) { return $value; } if ($value instanceof UriComponentInterface) { return $value->getContent(); } if (method_exists($value, '__toString')) { return (string) $value; } throw new TypeError('The submitted value is invalid.'); }
php
private function filterPair($value) { if (null === $value || is_scalar($value)) { return $value; } if ($value instanceof UriComponentInterface) { return $value->getContent(); } if (method_exists($value, '__toString')) { return (string) $value; } throw new TypeError('The submitted value is invalid.'); }
[ "private", "function", "filterPair", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", "||", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "value", "instanceof", "UriComponentInterfa...
Validate the given pair. To be valid the pair must be the null value, a scalar or a collection of scalar and null values. @throws TypeError if the value type is invalid
[ "Validate", "the", "given", "pair", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L566-L581
thephpleague/uri-components
src/Component/Query.php
Query.withoutPair
public function withoutPair(string $key, string ...$keys): self { $keys[] = $key; $keys_to_remove = array_intersect($keys, array_column($this->pairs, 0)); if ([] === $keys_to_remove) { return $this; } $filter = static function (array $pair) use ($keys_to_remove): bool { return !in_array($pair[0], $keys_to_remove, true); }; $clone = clone $this; $clone->pairs = array_filter($this->pairs, $filter); return $clone; }
php
public function withoutPair(string $key, string ...$keys): self { $keys[] = $key; $keys_to_remove = array_intersect($keys, array_column($this->pairs, 0)); if ([] === $keys_to_remove) { return $this; } $filter = static function (array $pair) use ($keys_to_remove): bool { return !in_array($pair[0], $keys_to_remove, true); }; $clone = clone $this; $clone->pairs = array_filter($this->pairs, $filter); return $clone; }
[ "public", "function", "withoutPair", "(", "string", "$", "key", ",", "string", "...", "$", "keys", ")", ":", "self", "{", "$", "keys", "[", "]", "=", "$", "key", ";", "$", "keys_to_remove", "=", "array_intersect", "(", "$", "keys", ",", "array_column",...
Returns an instance without the specified keys. This method MUST retain the state of the current instance, and return an instance that contains the modified component @param string $key the first key to remove @param string ...$keys the list of remaining keys to remove
[ "Returns", "an", "instance", "without", "the", "specified", "keys", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L592-L608
thephpleague/uri-components
src/Component/Query.php
Query.appendTo
public function appendTo(string $key, $value): self { $clone = clone $this; $clone->pairs[] = [$key, $this->filterPair($value)]; return $clone; }
php
public function appendTo(string $key, $value): self { $clone = clone $this; $clone->pairs[] = [$key, $this->filterPair($value)]; return $clone; }
[ "public", "function", "appendTo", "(", "string", "$", "key", ",", "$", "value", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "pairs", "[", "]", "=", "[", "$", "key", ",", "$", "this", "->", "filterPair"...
Returns a new instance with a specified key/value pair appended as a new pair. This method MUST retain the state of the current instance, and return an instance that contains the modified query @param mixed $value must be a scalar or the null value
[ "Returns", "a", "new", "instance", "with", "a", "specified", "key", "/", "value", "pair", "appended", "as", "a", "new", "pair", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L618-L624
thephpleague/uri-components
src/Component/Query.php
Query.append
public function append($query): self { if ($query instanceof UriComponentInterface) { $query = $query->getContent(); } $pairs = array_merge($this->pairs, QueryString::parse($query, $this->separator, PHP_QUERY_RFC3986)); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = array_filter($pairs, [$this, 'filterEmptyValue']); return $clone; }
php
public function append($query): self { if ($query instanceof UriComponentInterface) { $query = $query->getContent(); } $pairs = array_merge($this->pairs, QueryString::parse($query, $this->separator, PHP_QUERY_RFC3986)); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = array_filter($pairs, [$this, 'filterEmptyValue']); return $clone; }
[ "public", "function", "append", "(", "$", "query", ")", ":", "self", "{", "if", "(", "$", "query", "instanceof", "UriComponentInterface", ")", "{", "$", "query", "=", "$", "query", "->", "getContent", "(", ")", ";", "}", "$", "pairs", "=", "array_merge...
Returns an instance with the new pairs appended to it. This method MUST retain the state of the current instance, and return an instance that contains the modified query If the pair already exists the value will be added to it.
[ "Returns", "an", "instance", "with", "the", "new", "pairs", "appended", "to", "it", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L634-L649
thephpleague/uri-components
src/Component/Query.php
Query.withoutParam
public function withoutParam(string $offset, string ...$offsets): self { $offsets[] = $offset; $mapper = static function (string $offset): string { return preg_quote($offset, ',').'(\[.*\].*)?'; }; $regexp = ',^('.implode('|', array_map($mapper, $offsets)).')?$,'; $filter = static function (array $pair) use ($regexp): bool { return 1 !== preg_match($regexp, $pair[0]); }; $pairs = array_filter($this->pairs, $filter); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
php
public function withoutParam(string $offset, string ...$offsets): self { $offsets[] = $offset; $mapper = static function (string $offset): string { return preg_quote($offset, ',').'(\[.*\].*)?'; }; $regexp = ',^('.implode('|', array_map($mapper, $offsets)).')?$,'; $filter = static function (array $pair) use ($regexp): bool { return 1 !== preg_match($regexp, $pair[0]); }; $pairs = array_filter($this->pairs, $filter); if ($pairs === $this->pairs) { return $this; } $clone = clone $this; $clone->pairs = $pairs; return $clone; }
[ "public", "function", "withoutParam", "(", "string", "$", "offset", ",", "string", "...", "$", "offsets", ")", ":", "self", "{", "$", "offsets", "[", "]", "=", "$", "offset", ";", "$", "mapper", "=", "static", "function", "(", "string", "$", "offset", ...
Returns an instance without the specified params. This method MUST retain the state of the current instance, and return an instance that contains the modified component without PHP's value. PHP's mangled is not taken into account. @param string ...$offsets
[ "Returns", "an", "instance", "without", "the", "specified", "params", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Query.php#L668-L689
thephpleague/uri-components
src/Component/Domain.php
Domain.createFromLabels
public static function createFromLabels(iterable $labels): self { $hostLabels = []; foreach ($labels as $label) { $label = self::filterComponent($label); if (null === $label) { throw new TypeError('a label can not be null'); } $hostLabels[] = $label; } return new self(implode(self::SEPARATOR, array_reverse($hostLabels))); }
php
public static function createFromLabels(iterable $labels): self { $hostLabels = []; foreach ($labels as $label) { $label = self::filterComponent($label); if (null === $label) { throw new TypeError('a label can not be null'); } $hostLabels[] = $label; } return new self(implode(self::SEPARATOR, array_reverse($hostLabels))); }
[ "public", "static", "function", "createFromLabels", "(", "iterable", "$", "labels", ")", ":", "self", "{", "$", "hostLabels", "=", "[", "]", ";", "foreach", "(", "$", "labels", "as", "$", "label", ")", "{", "$", "label", "=", "self", "::", "filterCompo...
Returns a new instance from an iterable structure. @throws TypeError If a label is the null value
[ "Returns", "a", "new", "instance", "from", "an", "iterable", "structure", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L57-L69
thephpleague/uri-components
src/Component/Domain.php
Domain.get
public function get(int $offset): ?string { if ($offset < 0) { $offset += count($this->labels); } return $this->labels[$offset] ?? null; }
php
public function get(int $offset): ?string { if ($offset < 0) { $offset += count($this->labels); } return $this->labels[$offset] ?? null; }
[ "public", "function", "get", "(", "int", "$", "offset", ")", ":", "?", "string", "{", "if", "(", "$", "offset", "<", "0", ")", "{", "$", "offset", "+=", "count", "(", "$", "this", "->", "labels", ")", ";", "}", "return", "$", "this", "->", "lab...
Retrieves a single host label. If the label offset has not been set, returns the null value.
[ "Retrieves", "a", "single", "host", "label", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L185-L192
thephpleague/uri-components
src/Component/Domain.php
Domain.prepend
public function prepend($label): self { $label = $this->filterComponent($label); if (null === $label) { return $this; } return new self($label.self::SEPARATOR.$this->getContent()); }
php
public function prepend($label): self { $label = $this->filterComponent($label); if (null === $label) { return $this; } return new self($label.self::SEPARATOR.$this->getContent()); }
[ "public", "function", "prepend", "(", "$", "label", ")", ":", "self", "{", "$", "label", "=", "$", "this", "->", "filterComponent", "(", "$", "label", ")", ";", "if", "(", "null", "===", "$", "label", ")", "{", "return", "$", "this", ";", "}", "r...
Prepends a label to the host.
[ "Prepends", "a", "label", "to", "the", "host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L213-L221
thephpleague/uri-components
src/Component/Domain.php
Domain.append
public function append($label): self { $label = $this->filterComponent($label); if (null === $label) { return $this; } return new self($this->getContent().self::SEPARATOR.$label); }
php
public function append($label): self { $label = $this->filterComponent($label); if (null === $label) { return $this; } return new self($this->getContent().self::SEPARATOR.$label); }
[ "public", "function", "append", "(", "$", "label", ")", ":", "self", "{", "$", "label", "=", "$", "this", "->", "filterComponent", "(", "$", "label", ")", ";", "if", "(", "null", "===", "$", "label", ")", "{", "return", "$", "this", ";", "}", "re...
Appends a label to the host.
[ "Appends", "a", "label", "to", "the", "host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L226-L234
thephpleague/uri-components
src/Component/Domain.php
Domain.withoutRootLabel
public function withoutRootLabel(): self { if ('' !== reset($this->labels)) { return $this; } $labels = $this->labels; array_shift($labels); return self::createFromLabels($labels); }
php
public function withoutRootLabel(): self { if ('' !== reset($this->labels)) { return $this; } $labels = $this->labels; array_shift($labels); return self::createFromLabels($labels); }
[ "public", "function", "withoutRootLabel", "(", ")", ":", "self", "{", "if", "(", "''", "!==", "reset", "(", "$", "this", "->", "labels", ")", ")", "{", "return", "$", "this", ";", "}", "$", "labels", "=", "$", "this", "->", "labels", ";", "array_sh...
Returns an instance without its Root label. @see https://tools.ietf.org/html/rfc3986#section-3.2.2
[ "Returns", "an", "instance", "without", "its", "Root", "label", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L268-L278
thephpleague/uri-components
src/Component/Domain.php
Domain.withLabel
public function withLabel(int $key, $label): self { $nb_labels = count($this->labels); if ($key < - $nb_labels - 1 || $key > $nb_labels) { throw new OffsetOutOfBounds(sprintf('no label can be added with the submitted key : `%s`', $key)); } if (0 > $key) { $key += $nb_labels; } if ($nb_labels === $key) { return $this->append($label); } if (-1 === $key) { return $this->prepend($label); } if (!$label instanceof HostInterface) { $label = new Host($label); } $label = $label->getContent(); if ($label === $this->labels[$key]) { return $this; } $labels = $this->labels; $labels[$key] = $label; return new self(implode(self::SEPARATOR, array_reverse($labels))); }
php
public function withLabel(int $key, $label): self { $nb_labels = count($this->labels); if ($key < - $nb_labels - 1 || $key > $nb_labels) { throw new OffsetOutOfBounds(sprintf('no label can be added with the submitted key : `%s`', $key)); } if (0 > $key) { $key += $nb_labels; } if ($nb_labels === $key) { return $this->append($label); } if (-1 === $key) { return $this->prepend($label); } if (!$label instanceof HostInterface) { $label = new Host($label); } $label = $label->getContent(); if ($label === $this->labels[$key]) { return $this; } $labels = $this->labels; $labels[$key] = $label; return new self(implode(self::SEPARATOR, array_reverse($labels))); }
[ "public", "function", "withLabel", "(", "int", "$", "key", ",", "$", "label", ")", ":", "self", "{", "$", "nb_labels", "=", "count", "(", "$", "this", "->", "labels", ")", ";", "if", "(", "$", "key", "<", "-", "$", "nb_labels", "-", "1", "||", ...
Returns an instance with the modified label. This method MUST retain the state of the current instance, and return an instance that contains the new label If $key is non-negative, the added label will be the label at $key position from the start. If $key is negative, the added label will be the label at $key position from the end. @throws OffsetOutOfBounds If the key is invalid
[ "Returns", "an", "instance", "with", "the", "modified", "label", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L291-L323
thephpleague/uri-components
src/Component/Domain.php
Domain.withoutLabel
public function withoutLabel(int $key, int ...$keys): self { array_unshift($keys, $key); $nb_labels = count($this->labels); foreach ($keys as &$key) { if (- $nb_labels > $key || $nb_labels - 1 < $key) { throw new OffsetOutOfBounds(sprintf('no label can be removed with the submitted key : `%s`', $key)); } if (0 > $key) { $key += $nb_labels; } } unset($key); $deleted_keys = array_keys(array_count_values($keys)); $filter = static function ($key) use ($deleted_keys): bool { return !in_array($key, $deleted_keys, true); }; return self::createFromLabels(array_filter($this->labels, $filter, ARRAY_FILTER_USE_KEY)); }
php
public function withoutLabel(int $key, int ...$keys): self { array_unshift($keys, $key); $nb_labels = count($this->labels); foreach ($keys as &$key) { if (- $nb_labels > $key || $nb_labels - 1 < $key) { throw new OffsetOutOfBounds(sprintf('no label can be removed with the submitted key : `%s`', $key)); } if (0 > $key) { $key += $nb_labels; } } unset($key); $deleted_keys = array_keys(array_count_values($keys)); $filter = static function ($key) use ($deleted_keys): bool { return !in_array($key, $deleted_keys, true); }; return self::createFromLabels(array_filter($this->labels, $filter, ARRAY_FILTER_USE_KEY)); }
[ "public", "function", "withoutLabel", "(", "int", "$", "key", ",", "int", "...", "$", "keys", ")", ":", "self", "{", "array_unshift", "(", "$", "keys", ",", "$", "key", ")", ";", "$", "nb_labels", "=", "count", "(", "$", "this", "->", "labels", ")"...
Returns an instance without the specified label. This method MUST retain the state of the current instance, and return an instance that contains the modified component If $key is non-negative, the removed label will be the label at $key position from the start. If $key is negative, the removed label will be the label at $key position from the end. @param int ...$keys @throws OffsetOutOfBounds If the key is invalid
[ "Returns", "an", "instance", "without", "the", "specified", "label", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Domain.php#L338-L359
thephpleague/uri-components
src/Component/Component.php
Component.validateComponent
protected function validateComponent($component): ?string { $component = $this->filterComponent($component); if (null === $component) { return $component; } return $this->decodeComponent($component); }
php
protected function validateComponent($component): ?string { $component = $this->filterComponent($component); if (null === $component) { return $component; } return $this->decodeComponent($component); }
[ "protected", "function", "validateComponent", "(", "$", "component", ")", ":", "?", "string", "{", "$", "component", "=", "$", "this", "->", "filterComponent", "(", "$", "component", ")", ";", "if", "(", "null", "===", "$", "component", ")", "{", "return...
Validate the component content.
[ "Validate", "the", "component", "content", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Component.php#L61-L69
thephpleague/uri-components
src/Component/Component.php
Component.filterComponent
protected static function filterComponent($component): ?string { if ($component instanceof UriComponentInterface) { return $component->getContent(); } if (null === $component) { return $component; } if (!is_scalar($component) && !method_exists($component, '__toString')) { throw new TypeError(sprintf('Expected component to be stringable; received %s', gettype($component))); } $component = (string) $component; if (1 !== preg_match(self::REGEXP_INVALID_URI_CHARS, $component)) { return $component; } throw new SyntaxError(sprintf('Invalid component string: %s', $component)); }
php
protected static function filterComponent($component): ?string { if ($component instanceof UriComponentInterface) { return $component->getContent(); } if (null === $component) { return $component; } if (!is_scalar($component) && !method_exists($component, '__toString')) { throw new TypeError(sprintf('Expected component to be stringable; received %s', gettype($component))); } $component = (string) $component; if (1 !== preg_match(self::REGEXP_INVALID_URI_CHARS, $component)) { return $component; } throw new SyntaxError(sprintf('Invalid component string: %s', $component)); }
[ "protected", "static", "function", "filterComponent", "(", "$", "component", ")", ":", "?", "string", "{", "if", "(", "$", "component", "instanceof", "UriComponentInterface", ")", "{", "return", "$", "component", "->", "getContent", "(", ")", ";", "}", "if",...
Filter the input component. @throws SyntaxError If the component can not be converted to a string or null
[ "Filter", "the", "input", "component", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Component.php#L76-L96
thephpleague/uri-components
src/Component/Component.php
Component.decodeMatches
protected function decodeMatches(array $matches): string { if (1 === preg_match(static::REGEXP_PREVENTS_DECODING, $matches[0])) { return strtoupper($matches[0]); } return rawurldecode($matches[0]); }
php
protected function decodeMatches(array $matches): string { if (1 === preg_match(static::REGEXP_PREVENTS_DECODING, $matches[0])) { return strtoupper($matches[0]); } return rawurldecode($matches[0]); }
[ "protected", "function", "decodeMatches", "(", "array", "$", "matches", ")", ":", "string", "{", "if", "(", "1", "===", "preg_match", "(", "static", "::", "REGEXP_PREVENTS_DECODING", ",", "$", "matches", "[", "0", "]", ")", ")", "{", "return", "strtoupper"...
Decodes Matches sequence.
[ "Decodes", "Matches", "sequence", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Component.php#L110-L117
thephpleague/uri-components
src/Component/Component.php
Component.encodeComponent
protected function encodeComponent($str, int $enc_type, string $regexp): ?string { if (self::NO_ENCODING === $enc_type || null === $str || 1 !== preg_match(self::REGEXP_NO_ENCODING, $str)) { return $str; } return preg_replace_callback($regexp, [$this, 'encodeMatches'], $str) ?? rawurlencode($str); }
php
protected function encodeComponent($str, int $enc_type, string $regexp): ?string { if (self::NO_ENCODING === $enc_type || null === $str || 1 !== preg_match(self::REGEXP_NO_ENCODING, $str)) { return $str; } return preg_replace_callback($regexp, [$this, 'encodeMatches'], $str) ?? rawurlencode($str); }
[ "protected", "function", "encodeComponent", "(", "$", "str", ",", "int", "$", "enc_type", ",", "string", "$", "regexp", ")", ":", "?", "string", "{", "if", "(", "self", "::", "NO_ENCODING", "===", "$", "enc_type", "||", "null", "===", "$", "str", "||",...
Returns the component as converted for RFC3986 or RFC1738. @param null|string $str
[ "Returns", "the", "component", "as", "converted", "for", "RFC3986", "or", "RFC1738", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Component.php#L124-L131
thephpleague/uri-components
src/Component/Fragment.php
Fragment.getContent
public function getContent(): ?string { return $this->encodeComponent($this->fragment, self::RFC3986_ENCODING, self::REGEXP_FRAGMENT_ENCODING); }
php
public function getContent(): ?string { return $this->encodeComponent($this->fragment, self::RFC3986_ENCODING, self::REGEXP_FRAGMENT_ENCODING); }
[ "public", "function", "getContent", "(", ")", ":", "?", "string", "{", "return", "$", "this", "->", "encodeComponent", "(", "$", "this", "->", "fragment", ",", "self", "::", "RFC3986_ENCODING", ",", "self", "::", "REGEXP_FRAGMENT_ENCODING", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Fragment.php#L56-L59
thephpleague/uri-components
src/Component/Fragment.php
Fragment.decoded
public function decoded(): ?string { return $this->encodeComponent($this->fragment, self::NO_ENCODING, self::REGEXP_FRAGMENT_ENCODING); }
php
public function decoded(): ?string { return $this->encodeComponent($this->fragment, self::NO_ENCODING, self::REGEXP_FRAGMENT_ENCODING); }
[ "public", "function", "decoded", "(", ")", ":", "?", "string", "{", "return", "$", "this", "->", "encodeComponent", "(", "$", "this", "->", "fragment", ",", "self", "::", "NO_ENCODING", ",", "self", "::", "REGEXP_FRAGMENT_ENCODING", ")", ";", "}" ]
Returns the decoded query.
[ "Returns", "the", "decoded", "query", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Fragment.php#L72-L75
thephpleague/uri-components
src/Component/Authority.php
Authority.parse
private function parse(?string $authority): array { $components = ['user' => null, 'pass' => null, 'host' => null, 'port' => null]; if (null === $authority) { return $components; } if ('' === $authority) { $components['host'] = ''; return $components; } $parts = explode('@', $authority, 2); if (isset($parts[1])) { [$components['user'], $components['pass']] = explode(':', $parts[0], 2) + [1 => null]; } preg_match(self::REGEXP_HOST_PORT, $parts[1] ?? $parts[0], $matches); $matches += ['port' => '']; $components['host'] = $matches['host']; $components['port'] = '' === $matches['port'] ? null : $matches['port']; return $components; }
php
private function parse(?string $authority): array { $components = ['user' => null, 'pass' => null, 'host' => null, 'port' => null]; if (null === $authority) { return $components; } if ('' === $authority) { $components['host'] = ''; return $components; } $parts = explode('@', $authority, 2); if (isset($parts[1])) { [$components['user'], $components['pass']] = explode(':', $parts[0], 2) + [1 => null]; } preg_match(self::REGEXP_HOST_PORT, $parts[1] ?? $parts[0], $matches); $matches += ['port' => '']; $components['host'] = $matches['host']; $components['port'] = '' === $matches['port'] ? null : $matches['port']; return $components; }
[ "private", "function", "parse", "(", "?", "string", "$", "authority", ")", ":", "array", "{", "$", "components", "=", "[", "'user'", "=>", "null", ",", "'pass'", "=>", "null", ",", "'host'", "=>", "null", ",", "'port'", "=>", "null", "]", ";", "if", ...
Extracts the authority parts from a given string. @param ?string $authority
[ "Extracts", "the", "authority", "parts", "from", "a", "given", "string", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Authority.php#L93-L116
thephpleague/uri-components
src/Component/Authority.php
Authority.getContent
public function getContent(): ?string { $auth = $this->host->getContent(); $port = $this->port->getContent(); if (null !== $port) { $auth .= ':'.$port; } $userInfo = $this->userInfo->getContent(); if (null === $userInfo) { return $auth; } return $userInfo.'@'.$auth; }
php
public function getContent(): ?string { $auth = $this->host->getContent(); $port = $this->port->getContent(); if (null !== $port) { $auth .= ':'.$port; } $userInfo = $this->userInfo->getContent(); if (null === $userInfo) { return $auth; } return $userInfo.'@'.$auth; }
[ "public", "function", "getContent", "(", ")", ":", "?", "string", "{", "$", "auth", "=", "$", "this", "->", "host", "->", "getContent", "(", ")", ";", "$", "port", "=", "$", "this", "->", "port", "->", "getContent", "(", ")", ";", "if", "(", "nul...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Authority.php#L121-L135
thephpleague/uri-components
src/Component/Authority.php
Authority.withHost
public function withHost($host): self { if (!$host instanceof HostInterface) { $host = new Host($host); } if ($host->getContent() === $this->host->getContent()) { return $this; } $clone = clone $this; $clone->host = $host; $clone->validate(); return $clone; }
php
public function withHost($host): self { if (!$host instanceof HostInterface) { $host = new Host($host); } if ($host->getContent() === $this->host->getContent()) { return $this; } $clone = clone $this; $clone->host = $host; $clone->validate(); return $clone; }
[ "public", "function", "withHost", "(", "$", "host", ")", ":", "self", "{", "if", "(", "!", "$", "host", "instanceof", "HostInterface", ")", "{", "$", "host", "=", "new", "Host", "(", "$", "host", ")", ";", "}", "if", "(", "$", "host", "->", "getC...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Authority.php#L185-L200
thephpleague/uri-components
src/Component/Authority.php
Authority.withPort
public function withPort($port): self { if (!$port instanceof Port) { $port = new Port($port); } if ($port->getContent() === $this->port->getContent()) { return $this; } $clone = clone $this; $clone->port = $port; $clone->validate(); return $clone; }
php
public function withPort($port): self { if (!$port instanceof Port) { $port = new Port($port); } if ($port->getContent() === $this->port->getContent()) { return $this; } $clone = clone $this; $clone->port = $port; $clone->validate(); return $clone; }
[ "public", "function", "withPort", "(", "$", "port", ")", ":", "self", "{", "if", "(", "!", "$", "port", "instanceof", "Port", ")", "{", "$", "port", "=", "new", "Port", "(", "$", "port", ")", ";", "}", "if", "(", "$", "port", "->", "getContent", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Authority.php#L205-L220
thephpleague/uri-components
src/Component/Authority.php
Authority.withUserInfo
public function withUserInfo($user, $pass = null): self { $userInfo = new UserInfo($user, $pass); if ($userInfo->getContent() === $this->userInfo->getContent()) { return $this; } $clone = clone $this; $clone->userInfo = $userInfo; $clone->validate(); return $clone; }
php
public function withUserInfo($user, $pass = null): self { $userInfo = new UserInfo($user, $pass); if ($userInfo->getContent() === $this->userInfo->getContent()) { return $this; } $clone = clone $this; $clone->userInfo = $userInfo; $clone->validate(); return $clone; }
[ "public", "function", "withUserInfo", "(", "$", "user", ",", "$", "pass", "=", "null", ")", ":", "self", "{", "$", "userInfo", "=", "new", "UserInfo", "(", "$", "user", ",", "$", "pass", ")", ";", "if", "(", "$", "userInfo", "->", "getContent", "("...
{@inheritDoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Authority.php#L225-L237
thephpleague/uri-components
src/Component/Port.php
Port.validate
private function validate($port): ?int { $port = $this->filterComponent($port); if (null === $port) { return null; } $fport = filter_var($port, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]); if (false !== $fport) { return $fport; } throw new SyntaxError(sprintf('Expected port to be a positive integer or 0; received %s', $port)); }
php
private function validate($port): ?int { $port = $this->filterComponent($port); if (null === $port) { return null; } $fport = filter_var($port, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]); if (false !== $fport) { return $fport; } throw new SyntaxError(sprintf('Expected port to be a positive integer or 0; received %s', $port)); }
[ "private", "function", "validate", "(", "$", "port", ")", ":", "?", "int", "{", "$", "port", "=", "$", "this", "->", "filterComponent", "(", "$", "port", ")", ";", "if", "(", "null", "===", "$", "port", ")", "{", "return", "null", ";", "}", "$", ...
Validate a port. @throws SyntaxError if the port is invalid
[ "Validate", "a", "port", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Port.php#L57-L70
thephpleague/uri-components
src/Component/Port.php
Port.getContent
public function getContent(): ?string { if (null === $this->port) { return $this->port; } return (string) $this->port; }
php
public function getContent(): ?string { if (null === $this->port) { return $this->port; } return (string) $this->port; }
[ "public", "function", "getContent", "(", ")", ":", "?", "string", "{", "if", "(", "null", "===", "$", "this", "->", "port", ")", "{", "return", "$", "this", "->", "port", ";", "}", "return", "(", "string", ")", "$", "this", "->", "port", ";", "}"...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Port.php#L75-L82
thephpleague/uri-components
src/Component/Port.php
Port.withContent
public function withContent($content): self { $content = $this->validate($this->filterComponent($content)); if ($content === $this->port) { return $this; } return new self($content); }
php
public function withContent($content): self { $content = $this->validate($this->filterComponent($content)); if ($content === $this->port) { return $this; } return new self($content); }
[ "public", "function", "withContent", "(", "$", "content", ")", ":", "self", "{", "$", "content", "=", "$", "this", "->", "validate", "(", "$", "this", "->", "filterComponent", "(", "$", "content", ")", ")", ";", "if", "(", "$", "content", "===", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Port.php#L103-L111
thephpleague/uri-components
src/Component/DataPath.php
DataPath.createFromPath
public static function createFromPath(string $path, $context = null): self { $file_args = [$path, false]; $mime_args = [$path, FILEINFO_MIME]; if (null !== $context) { $file_args[] = $context; $mime_args[] = $context; } $content = @file_get_contents(...$file_args); if (false === $content) { throw new SyntaxError(sprintf('`%s` failed to open stream: No such file or directory', $path)); } return new self( str_replace(' ', '', (new finfo(FILEINFO_MIME))->file(...$mime_args)) .';base64,'.base64_encode($content) ); }
php
public static function createFromPath(string $path, $context = null): self { $file_args = [$path, false]; $mime_args = [$path, FILEINFO_MIME]; if (null !== $context) { $file_args[] = $context; $mime_args[] = $context; } $content = @file_get_contents(...$file_args); if (false === $content) { throw new SyntaxError(sprintf('`%s` failed to open stream: No such file or directory', $path)); } return new self( str_replace(' ', '', (new finfo(FILEINFO_MIME))->file(...$mime_args)) .';base64,'.base64_encode($content) ); }
[ "public", "static", "function", "createFromPath", "(", "string", "$", "path", ",", "$", "context", "=", "null", ")", ":", "self", "{", "$", "file_args", "=", "[", "$", "path", ",", "false", "]", ";", "$", "mime_args", "=", "[", "$", "path", ",", "F...
Create a new instance from a file path. @param null|resource $context @throws SyntaxError If the File is not readable
[ "Create", "a", "new", "instance", "from", "a", "file", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L98-L116
thephpleague/uri-components
src/Component/DataPath.php
DataPath.filterPath
private function filterPath(?string $path): string { if (null === $path) { throw new SyntaxError('The path can not be null'); } if ('' === $path || ',' === $path) { return 'text/plain;charset=us-ascii,'; } if (1 === preg_match(self::REGEXP_DATAPATH, $path)) { $path = substr($path, 0, -1).'charset=us-ascii,'; } if (1 === preg_match(self::REGEXP_NON_ASCII_PATTERN, $path) && false === strpos($path, ',')) { throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path)); } return $path; }
php
private function filterPath(?string $path): string { if (null === $path) { throw new SyntaxError('The path can not be null'); } if ('' === $path || ',' === $path) { return 'text/plain;charset=us-ascii,'; } if (1 === preg_match(self::REGEXP_DATAPATH, $path)) { $path = substr($path, 0, -1).'charset=us-ascii,'; } if (1 === preg_match(self::REGEXP_NON_ASCII_PATTERN, $path) && false === strpos($path, ',')) { throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path)); } return $path; }
[ "private", "function", "filterPath", "(", "?", "string", "$", "path", ")", ":", "string", "{", "if", "(", "null", "===", "$", "path", ")", "{", "throw", "new", "SyntaxError", "(", "'The path can not be null'", ")", ";", "}", "if", "(", "''", "===", "$"...
Filter the data path. @param ?string $path @throws SyntaxError If the path is null @throws SyntaxError If the path is not valid according to RFC2937
[ "Filter", "the", "data", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L150-L169
thephpleague/uri-components
src/Component/DataPath.php
DataPath.filterMimeType
private function filterMimeType(string $mimetype): string { if ('' == $mimetype) { return static::DEFAULT_MIMETYPE; } if (1 === preg_match(static::REGEXP_MIMETYPE, $mimetype)) { return $mimetype; } throw new SyntaxError(sprintf('invalid mimeType, `%s`', $mimetype)); }
php
private function filterMimeType(string $mimetype): string { if ('' == $mimetype) { return static::DEFAULT_MIMETYPE; } if (1 === preg_match(static::REGEXP_MIMETYPE, $mimetype)) { return $mimetype; } throw new SyntaxError(sprintf('invalid mimeType, `%s`', $mimetype)); }
[ "private", "function", "filterMimeType", "(", "string", "$", "mimetype", ")", ":", "string", "{", "if", "(", "''", "==", "$", "mimetype", ")", "{", "return", "static", "::", "DEFAULT_MIMETYPE", ";", "}", "if", "(", "1", "===", "preg_match", "(", "static"...
Filter the mimeType property. @throws SyntaxError If the mimetype is invalid
[ "Filter", "the", "mimeType", "property", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L176-L187
thephpleague/uri-components
src/Component/DataPath.php
DataPath.filterParameters
private function filterParameters(string $parameters, bool &$is_binary_data): array { if ('' === $parameters) { return [static::DEFAULT_PARAMETER]; } if (1 === preg_match(',(;|^)'.static::BINARY_PARAMETER.'$,', $parameters, $matches)) { $parameters = substr($parameters, 0, - strlen($matches[0])); $is_binary_data = true; } $params = array_filter(explode(';', $parameters)); if ([] !== array_filter($params, [$this, 'validateParameter'])) { throw new SyntaxError(sprintf('invalid mediatype parameters, `%s`', $parameters)); } return $params; }
php
private function filterParameters(string $parameters, bool &$is_binary_data): array { if ('' === $parameters) { return [static::DEFAULT_PARAMETER]; } if (1 === preg_match(',(;|^)'.static::BINARY_PARAMETER.'$,', $parameters, $matches)) { $parameters = substr($parameters, 0, - strlen($matches[0])); $is_binary_data = true; } $params = array_filter(explode(';', $parameters)); if ([] !== array_filter($params, [$this, 'validateParameter'])) { throw new SyntaxError(sprintf('invalid mediatype parameters, `%s`', $parameters)); } return $params; }
[ "private", "function", "filterParameters", "(", "string", "$", "parameters", ",", "bool", "&", "$", "is_binary_data", ")", ":", "array", "{", "if", "(", "''", "===", "$", "parameters", ")", "{", "return", "[", "static", "::", "DEFAULT_PARAMETER", "]", ";",...
Extract and set the binary flag from the parameters if it exists. @param bool $is_binary_data the binary flag to set @throws SyntaxError If the mediatype parameters contain invalid data @return string[]
[ "Extract", "and", "set", "the", "binary", "flag", "from", "the", "parameters", "if", "it", "exists", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L198-L215
thephpleague/uri-components
src/Component/DataPath.php
DataPath.validateParameter
private function validateParameter(string $parameter): bool { $properties = explode('=', $parameter); return 2 != count($properties) || strtolower($properties[0]) === static::BINARY_PARAMETER; }
php
private function validateParameter(string $parameter): bool { $properties = explode('=', $parameter); return 2 != count($properties) || strtolower($properties[0]) === static::BINARY_PARAMETER; }
[ "private", "function", "validateParameter", "(", "string", "$", "parameter", ")", ":", "bool", "{", "$", "properties", "=", "explode", "(", "'='", ",", "$", "parameter", ")", ";", "return", "2", "!=", "count", "(", "$", "properties", ")", "||", "strtolow...
Validate mediatype parameter.
[ "Validate", "mediatype", "parameter", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L220-L225
thephpleague/uri-components
src/Component/DataPath.php
DataPath.validateDocument
private function validateDocument(): void { if (!$this->is_binary_data) { return; } $res = base64_decode($this->document, true); if (false === $res || $this->document !== base64_encode($res)) { throw new SyntaxError(sprintf('invalid document, `%s`', $this->document)); } }
php
private function validateDocument(): void { if (!$this->is_binary_data) { return; } $res = base64_decode($this->document, true); if (false === $res || $this->document !== base64_encode($res)) { throw new SyntaxError(sprintf('invalid document, `%s`', $this->document)); } }
[ "private", "function", "validateDocument", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "is_binary_data", ")", "{", "return", ";", "}", "$", "res", "=", "base64_decode", "(", "$", "this", "->", "document", ",", "true", ")", ";", "if...
Validate the path document string representation. @throws SyntaxError If the data is invalid
[ "Validate", "the", "path", "document", "string", "representation", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L232-L242
thephpleague/uri-components
src/Component/DataPath.php
DataPath.save
public function save(string $path, string $mode = 'w'): SplFileObject { $file = new SplFileObject($path, $mode); $data = $this->is_binary_data ? base64_decode($this->document) : rawurldecode($this->document); $file->fwrite((string) $data); return $file; }
php
public function save(string $path, string $mode = 'w'): SplFileObject { $file = new SplFileObject($path, $mode); $data = $this->is_binary_data ? base64_decode($this->document) : rawurldecode($this->document); $file->fwrite((string) $data); return $file; }
[ "public", "function", "save", "(", "string", "$", "path", ",", "string", "$", "mode", "=", "'w'", ")", ":", "SplFileObject", "{", "$", "file", "=", "new", "SplFileObject", "(", "$", "path", ",", "$", "mode", ")", ";", "$", "data", "=", "$", "this",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L303-L310
thephpleague/uri-components
src/Component/DataPath.php
DataPath.toBinary
public function toBinary(): self { if ($this->is_binary_data) { return $this; } return new self($this->formatComponent( $this->mimetype, $this->getParameters(), !$this->is_binary_data, base64_encode(rawurldecode($this->document)) )); }
php
public function toBinary(): self { if ($this->is_binary_data) { return $this; } return new self($this->formatComponent( $this->mimetype, $this->getParameters(), !$this->is_binary_data, base64_encode(rawurldecode($this->document)) )); }
[ "public", "function", "toBinary", "(", ")", ":", "self", "{", "if", "(", "$", "this", "->", "is_binary_data", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "this", "->", "formatComponent", "(", "$", "this", "->", "mime...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L315-L327
thephpleague/uri-components
src/Component/DataPath.php
DataPath.formatComponent
private function formatComponent( string $mimetype, string $parameters, bool $is_binary_data, string $data ): string { if ('' != $parameters) { $parameters = ';'.$parameters; } if ($is_binary_data) { $parameters .= ';base64'; } $path = $mimetype.$parameters.','.$data; return preg_replace_callback(self::REGEXP_DATAPATH_ENCODING, [$this, 'encodeMatches'], $path) ?? $path; }
php
private function formatComponent( string $mimetype, string $parameters, bool $is_binary_data, string $data ): string { if ('' != $parameters) { $parameters = ';'.$parameters; } if ($is_binary_data) { $parameters .= ';base64'; } $path = $mimetype.$parameters.','.$data; return preg_replace_callback(self::REGEXP_DATAPATH_ENCODING, [$this, 'encodeMatches'], $path) ?? $path; }
[ "private", "function", "formatComponent", "(", "string", "$", "mimetype", ",", "string", "$", "parameters", ",", "bool", "$", "is_binary_data", ",", "string", "$", "data", ")", ":", "string", "{", "if", "(", "''", "!=", "$", "parameters", ")", "{", "$", ...
Format the DataURI string.
[ "Format", "the", "DataURI", "string", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L332-L349
thephpleague/uri-components
src/Component/DataPath.php
DataPath.toAscii
public function toAscii(): self { if (false === $this->is_binary_data) { return $this; } return new self($this->formatComponent( $this->mimetype, $this->getParameters(), false, rawurlencode((string) base64_decode($this->document)) )); }
php
public function toAscii(): self { if (false === $this->is_binary_data) { return $this; } return new self($this->formatComponent( $this->mimetype, $this->getParameters(), false, rawurlencode((string) base64_decode($this->document)) )); }
[ "public", "function", "toAscii", "(", ")", ":", "self", "{", "if", "(", "false", "===", "$", "this", "->", "is_binary_data", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "this", "->", "formatComponent", "(", "$", "thi...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L354-L366
thephpleague/uri-components
src/Component/DataPath.php
DataPath.withContent
public function withContent($content): self { $content = $this->filterComponent($content); if ($content === $this->path->getContent()) { return $this; } return new self($content); }
php
public function withContent($content): self { $content = $this->filterComponent($content); if ($content === $this->path->getContent()) { return $this; } return new self($content); }
[ "public", "function", "withContent", "(", "$", "content", ")", ":", "self", "{", "$", "content", "=", "$", "this", "->", "filterComponent", "(", "$", "content", ")", ";", "if", "(", "$", "content", "===", "$", "this", "->", "path", "->", "getContent", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L395-L403
thephpleague/uri-components
src/Component/DataPath.php
DataPath.withParameters
public function withParameters(string $parameters): self { if ($parameters === $this->getParameters()) { return $this; } return new self($this->formatComponent($this->mimetype, $parameters, $this->is_binary_data, $this->document)); }
php
public function withParameters(string $parameters): self { if ($parameters === $this->getParameters()) { return $this; } return new self($this->formatComponent($this->mimetype, $parameters, $this->is_binary_data, $this->document)); }
[ "public", "function", "withParameters", "(", "string", "$", "parameters", ")", ":", "self", "{", "if", "(", "$", "parameters", "===", "$", "this", "->", "getParameters", "(", ")", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(",...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/DataPath.php#L408-L415
thephpleague/uri-components
src/UriModifier.php
UriModifier.appendQuery
public static function appendQuery($uri, $query) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->append($query)); }
php
public static function appendQuery($uri, $query) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->append($query)); }
[ "public", "static", "function", "appendQuery", "(", "$", "uri", ",", "$", "query", ")", "{", "return", "$", "uri", "->", "withQuery", "(", "(", "string", ")", "(", "new", "Query", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getQuery"...
Add the new query data to the existing URI query. @return Psr7UriInterface|UriInterface
[ "Add", "the", "new", "query", "data", "to", "the", "existing", "URI", "query", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L74-L77
thephpleague/uri-components
src/UriModifier.php
UriModifier.mergeQuery
public static function mergeQuery($uri, $query) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->merge($query)); }
php
public static function mergeQuery($uri, $query) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->merge($query)); }
[ "public", "static", "function", "mergeQuery", "(", "$", "uri", ",", "$", "query", ")", "{", "return", "$", "uri", "->", "withQuery", "(", "(", "string", ")", "(", "new", "Query", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getQuery",...
Merge a new query with the existing URI query. @return Psr7UriInterface|UriInterface
[ "Merge", "a", "new", "query", "with", "the", "existing", "URI", "query", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L84-L87
thephpleague/uri-components
src/UriModifier.php
UriModifier.removePairs
public static function removePairs($uri, string $key, string ... $keys) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->withoutPair($key, ...$keys)); }
php
public static function removePairs($uri, string $key, string ... $keys) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->withoutPair($key, ...$keys)); }
[ "public", "static", "function", "removePairs", "(", "$", "uri", ",", "string", "$", "key", ",", "string", "...", "$", "keys", ")", "{", "return", "$", "uri", "->", "withQuery", "(", "(", "string", ")", "(", "new", "Query", "(", "self", "::", "filterU...
Remove query data according to their key name. @param string... $keys @return Psr7UriInterface|UriInterface
[ "Remove", "query", "data", "according", "to", "their", "key", "name", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L96-L99
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeParams
public static function removeParams($uri, string $key, string ... $keys) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->withoutParam($key, ...$keys)); }
php
public static function removeParams($uri, string $key, string ... $keys) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->withoutParam($key, ...$keys)); }
[ "public", "static", "function", "removeParams", "(", "$", "uri", ",", "string", "$", "key", ",", "string", "...", "$", "keys", ")", "{", "return", "$", "uri", "->", "withQuery", "(", "(", "string", ")", "(", "new", "Query", "(", "self", "::", "filter...
Remove query data according to their key name. @param string... $keys @return Psr7UriInterface|UriInterface
[ "Remove", "query", "data", "according", "to", "their", "key", "name", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L108-L111
thephpleague/uri-components
src/UriModifier.php
UriModifier.sortQuery
public static function sortQuery($uri) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->sort()); }
php
public static function sortQuery($uri) { return $uri->withQuery((string) (new Query(self::filterUri($uri)->getQuery()))->sort()); }
[ "public", "static", "function", "sortQuery", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withQuery", "(", "(", "string", ")", "(", "new", "Query", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getQuery", "(", ")", ")", ")...
Sort the URI query by keys. @return Psr7UriInterface|UriInterface
[ "Sort", "the", "URI", "query", "by", "keys", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L118-L121
thephpleague/uri-components
src/UriModifier.php
UriModifier.addRootLabel
public static function addRootLabel($uri) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withRootLabel()); }
php
public static function addRootLabel($uri) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withRootLabel()); }
[ "public", "static", "function", "addRootLabel", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Domain", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", ...
Add the root label to the URI. @return Psr7UriInterface|UriInterface
[ "Add", "the", "root", "label", "to", "the", "URI", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L132-L135
thephpleague/uri-components
src/UriModifier.php
UriModifier.appendLabel
public static function appendLabel($uri, $label) { $host = new Host(self::filterUri($uri)->getHost()); if ($host->isDomain()) { return $uri->withHost((string) (new Domain($host))->append($label)); } if ($host->isIpv4()) { $label = ltrim((string) new Host($label), '.'); return $uri->withHost((string) $host->withContent($host->getContent().'.'.$label)); } throw new SyntaxError(sprintf('The URI host %s can not be appended', (string) $host)); }
php
public static function appendLabel($uri, $label) { $host = new Host(self::filterUri($uri)->getHost()); if ($host->isDomain()) { return $uri->withHost((string) (new Domain($host))->append($label)); } if ($host->isIpv4()) { $label = ltrim((string) new Host($label), '.'); return $uri->withHost((string) $host->withContent($host->getContent().'.'.$label)); } throw new SyntaxError(sprintf('The URI host %s can not be appended', (string) $host)); }
[ "public", "static", "function", "appendLabel", "(", "$", "uri", ",", "$", "label", ")", "{", "$", "host", "=", "new", "Host", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", ";", "if", "(", "$", "host", "->",...
Append a label or a host to the current URI host. @throws SyntaxError If the host can not be appended @return Psr7UriInterface|UriInterface
[ "Append", "a", "label", "or", "a", "host", "to", "the", "current", "URI", "host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L144-L158
thephpleague/uri-components
src/UriModifier.php
UriModifier.hostToAscii
public static function hostToAscii($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))); }
php
public static function hostToAscii($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))); }
[ "public", "static", "function", "hostToAscii", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Host", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", ")"...
Convert the URI host part to its ascii value. @return Psr7UriInterface|UriInterface
[ "Convert", "the", "URI", "host", "part", "to", "its", "ascii", "value", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L166-L169
thephpleague/uri-components
src/UriModifier.php
UriModifier.hostToUnicode
public static function hostToUnicode($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->toUnicode()); }
php
public static function hostToUnicode($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->toUnicode()); }
[ "public", "static", "function", "hostToUnicode", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Host", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", "...
Convert the URI host part to its unicode value. @return Psr7UriInterface|UriInterface
[ "Convert", "the", "URI", "host", "part", "to", "its", "unicode", "value", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L176-L179
thephpleague/uri-components
src/UriModifier.php
UriModifier.prependLabel
public static function prependLabel($uri, $label) { $host = new Host(self::filterUri($uri)->getHost()); if ($host->isDomain()) { return $uri->withHost((string) (new Domain($host))->prepend($label)); } if ($host->isIpv4()) { $label = rtrim((string) new Host($label), '.'); return $uri->withHost((string) $host->withContent($label.'.'.$host->getContent())); } throw new SyntaxError(sprintf('The URI host %s can not be prepended', (string) $host)); }
php
public static function prependLabel($uri, $label) { $host = new Host(self::filterUri($uri)->getHost()); if ($host->isDomain()) { return $uri->withHost((string) (new Domain($host))->prepend($label)); } if ($host->isIpv4()) { $label = rtrim((string) new Host($label), '.'); return $uri->withHost((string) $host->withContent($label.'.'.$host->getContent())); } throw new SyntaxError(sprintf('The URI host %s can not be prepended', (string) $host)); }
[ "public", "static", "function", "prependLabel", "(", "$", "uri", ",", "$", "label", ")", "{", "$", "host", "=", "new", "Host", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", ";", "if", "(", "$", "host", "->"...
Prepend a label or a host to the current URI host. @throws SyntaxError If the host can not be prepended @return Psr7UriInterface|UriInterface
[ "Prepend", "a", "label", "or", "a", "host", "to", "the", "current", "URI", "host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L188-L202
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeLabels
public static function removeLabels($uri, int $key, int ... $keys) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withoutLabel($key, ...$keys)); }
php
public static function removeLabels($uri, int $key, int ... $keys) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withoutLabel($key, ...$keys)); }
[ "public", "static", "function", "removeLabels", "(", "$", "uri", ",", "int", "$", "key", ",", "int", "...", "$", "keys", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Domain", "(", "self", "::", "filterUri", ...
Remove host labels according to their offset. @param int... $keys @return Psr7UriInterface|UriInterface
[ "Remove", "host", "labels", "according", "to", "their", "offset", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L211-L214
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeRootLabel
public static function removeRootLabel($uri) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withoutRootLabel()); }
php
public static function removeRootLabel($uri) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withoutRootLabel()); }
[ "public", "static", "function", "removeRootLabel", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Domain", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")",...
Remove the root label to the URI. @return Psr7UriInterface|UriInterface
[ "Remove", "the", "root", "label", "to", "the", "URI", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L221-L224
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeZoneId
public static function removeZoneId($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->withoutZoneIdentifier()); }
php
public static function removeZoneId($uri) { return $uri->withHost((string) (new Host(self::filterUri($uri)->getHost()))->withoutZoneIdentifier()); }
[ "public", "static", "function", "removeZoneId", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Host", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getHost", "(", ")", ")", ")...
Remove the host zone identifier. @return Psr7UriInterface|UriInterface
[ "Remove", "the", "host", "zone", "identifier", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L231-L234
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceLabel
public static function replaceLabel($uri, int $offset, $host) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withLabel($offset, $host)); }
php
public static function replaceLabel($uri, int $offset, $host) { return $uri->withHost((string) (new Domain(self::filterUri($uri)->getHost()))->withLabel($offset, $host)); }
[ "public", "static", "function", "replaceLabel", "(", "$", "uri", ",", "int", "$", "offset", ",", "$", "host", ")", "{", "return", "$", "uri", "->", "withHost", "(", "(", "string", ")", "(", "new", "Domain", "(", "self", "::", "filterUri", "(", "$", ...
Replace a label of the current URI host. @return Psr7UriInterface|UriInterface
[ "Replace", "a", "label", "of", "the", "current", "URI", "host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L241-L244
thephpleague/uri-components
src/UriModifier.php
UriModifier.addBasepath
public static function addBasepath($uri, $path) { self::filterUri($uri); $currentpath = $uri->getPath(); if ('' !== $currentpath && '/' !== $currentpath[0]) { $currentpath = '/'.$currentpath; } $path = (new HierarchicalPath($path))->withLeadingSlash(); if (0 === strpos($currentpath, (string) $path)) { return $uri->withPath($currentpath); } return $uri->withPath((string) $path->append($currentpath)); }
php
public static function addBasepath($uri, $path) { self::filterUri($uri); $currentpath = $uri->getPath(); if ('' !== $currentpath && '/' !== $currentpath[0]) { $currentpath = '/'.$currentpath; } $path = (new HierarchicalPath($path))->withLeadingSlash(); if (0 === strpos($currentpath, (string) $path)) { return $uri->withPath($currentpath); } return $uri->withPath((string) $path->append($currentpath)); }
[ "public", "static", "function", "addBasepath", "(", "$", "uri", ",", "$", "path", ")", "{", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "$", "currentpath", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "''", "!==", "$", "c...
Add a new basepath to the URI path. @return Psr7UriInterface|UriInterface
[ "Add", "a", "new", "basepath", "to", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L255-L269
thephpleague/uri-components
src/UriModifier.php
UriModifier.addLeadingSlash
public static function addLeadingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('/' !== ($path[0] ?? '')) { $path = '/'.$path; } return self::normalizePath($uri, $path); }
php
public static function addLeadingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('/' !== ($path[0] ?? '')) { $path = '/'.$path; } return self::normalizePath($uri, $path); }
[ "public", "static", "function", "addLeadingSlash", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "$", "path", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "'/'", "!==", "(", "$", ...
Add a leading slash to the URI path. @return Psr7UriInterface|UriInterface
[ "Add", "a", "leading", "slash", "to", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L276-L285
thephpleague/uri-components
src/UriModifier.php
UriModifier.normalizePath
private static function normalizePath($uri, $path = null) { if ($path instanceof PathInterface) { $path = $path->getContent(); } $path = $path ?? $uri->getPath(); $path = (string) $path; if (null !== $uri->getAuthority() && '' !== $uri->getAuthority() && '' !== $path && '/' != ($path[0] ?? '') ) { return $uri->withPath('/'.$path); } return $uri->withPath($path); }
php
private static function normalizePath($uri, $path = null) { if ($path instanceof PathInterface) { $path = $path->getContent(); } $path = $path ?? $uri->getPath(); $path = (string) $path; if (null !== $uri->getAuthority() && '' !== $uri->getAuthority() && '' !== $path && '/' != ($path[0] ?? '') ) { return $uri->withPath('/'.$path); } return $uri->withPath($path); }
[ "private", "static", "function", "normalizePath", "(", "$", "uri", ",", "$", "path", "=", "null", ")", "{", "if", "(", "$", "path", "instanceof", "PathInterface", ")", "{", "$", "path", "=", "$", "path", "->", "getContent", "(", ")", ";", "}", "$", ...
Normalize a URI path. Make sure the path always has a leading slash if an authority is present and the path is not the empty string. @param null|string|PathInterface $path @return Psr7UriInterface|UriInterface
[ "Normalize", "a", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L297-L314
thephpleague/uri-components
src/UriModifier.php
UriModifier.addTrailingSlash
public static function addTrailingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('/' !== substr($path, -1)) { $path .= '/'; } return self::normalizePath($uri, $path); }
php
public static function addTrailingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('/' !== substr($path, -1)) { $path .= '/'; } return self::normalizePath($uri, $path); }
[ "public", "static", "function", "addTrailingSlash", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "$", "path", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "'/'", "!==", "substr", ...
Add a trailing slash to the URI path. @return Psr7UriInterface|UriInterface
[ "Add", "a", "trailing", "slash", "to", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L321-L330
thephpleague/uri-components
src/UriModifier.php
UriModifier.appendSegment
public static function appendSegment($uri, string $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->append($segment)); }
php
public static function appendSegment($uri, string $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->append($segment)); }
[ "public", "static", "function", "appendSegment", "(", "$", "uri", ",", "string", "$", "segment", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new...
Append an new segment or a new path to the URI path. @return Psr7UriInterface|UriInterface
[ "Append", "an", "new", "segment", "or", "a", "new", "path", "to", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L337-L342
thephpleague/uri-components
src/UriModifier.php
UriModifier.datapathToAscii
public static function datapathToAscii($uri) { return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toAscii()); }
php
public static function datapathToAscii($uri) { return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toAscii()); }
[ "public", "static", "function", "datapathToAscii", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withPath", "(", "(", "string", ")", "(", "new", "DataPath", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getPath", "(", ")", ")...
Convert the Data URI path to its ascii form. @return Psr7UriInterface|UriInterface
[ "Convert", "the", "Data", "URI", "path", "to", "its", "ascii", "form", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L349-L352
thephpleague/uri-components
src/UriModifier.php
UriModifier.datapathToBinary
public static function datapathToBinary($uri) { return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toBinary()); }
php
public static function datapathToBinary($uri) { return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toBinary()); }
[ "public", "static", "function", "datapathToBinary", "(", "$", "uri", ")", "{", "return", "$", "uri", "->", "withPath", "(", "(", "string", ")", "(", "new", "DataPath", "(", "self", "::", "filterUri", "(", "$", "uri", ")", "->", "getPath", "(", ")", "...
Convert the Data URI path to its binary (base64encoded) form. @return Psr7UriInterface|UriInterface
[ "Convert", "the", "Data", "URI", "path", "to", "its", "binary", "(", "base64encoded", ")", "form", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L359-L362
thephpleague/uri-components
src/UriModifier.php
UriModifier.prependSegment
public static function prependSegment($uri, $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->prepend($segment)); }
php
public static function prependSegment($uri, $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->prepend($segment)); }
[ "public", "static", "function", "prependSegment", "(", "$", "uri", ",", "$", "segment", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "Hiera...
Prepend an new segment or a new path to the URI path. @return Psr7UriInterface|UriInterface
[ "Prepend", "an", "new", "segment", "or", "a", "new", "path", "to", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L369-L374
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeBasepath
public static function removeBasepath($uri, $path) { $uri = self::normalizePath(self::filterUri($uri)); $basepath = (new HierarchicalPath($path))->withLeadingSlash(); if ('/' === (string) $basepath) { return $uri; } $currentpath = $uri->getPath(); if (0 !== strpos($currentpath, (string) $basepath)) { return $uri; } return $uri->withPath( (string) (new HierarchicalPath($currentpath))->withoutSegment(...range(0, count($basepath) - 1)) ); }
php
public static function removeBasepath($uri, $path) { $uri = self::normalizePath(self::filterUri($uri)); $basepath = (new HierarchicalPath($path))->withLeadingSlash(); if ('/' === (string) $basepath) { return $uri; } $currentpath = $uri->getPath(); if (0 !== strpos($currentpath, (string) $basepath)) { return $uri; } return $uri->withPath( (string) (new HierarchicalPath($currentpath))->withoutSegment(...range(0, count($basepath) - 1)) ); }
[ "public", "static", "function", "removeBasepath", "(", "$", "uri", ",", "$", "path", ")", "{", "$", "uri", "=", "self", "::", "normalizePath", "(", "self", "::", "filterUri", "(", "$", "uri", ")", ")", ";", "$", "basepath", "=", "(", "new", "Hierarch...
Remove a basepath from the URI path. @return Psr7UriInterface|UriInterface
[ "Remove", "a", "basepath", "from", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L381-L397
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeDotSegments
public static function removeDotSegments($uri) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new Path($uri->getPath()))->withoutDotSegments()); }
php
public static function removeDotSegments($uri) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new Path($uri->getPath()))->withoutDotSegments()); }
[ "public", "static", "function", "removeDotSegments", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "Path", "(", "$", "uri",...
Remove dot segments from the URI path. @return Psr7UriInterface|UriInterface
[ "Remove", "dot", "segments", "from", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L404-L409
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeEmptySegments
public static function removeEmptySegments($uri) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withoutEmptySegments()); }
php
public static function removeEmptySegments($uri) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withoutEmptySegments()); }
[ "public", "static", "function", "removeEmptySegments", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "HierarchicalPath", "(", ...
Remove empty segments from the URI path. @return Psr7UriInterface|UriInterface
[ "Remove", "empty", "segments", "from", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L416-L421
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeLeadingSlash
public static function removeLeadingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('' !== $path && '/' === $path[0]) { $path = substr($path, 1); } return self::normalizePath($uri, $path); }
php
public static function removeLeadingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('' !== $path && '/' === $path[0]) { $path = substr($path, 1); } return self::normalizePath($uri, $path); }
[ "public", "static", "function", "removeLeadingSlash", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "$", "path", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "''", "!==", "$", "pa...
Remove the leading slash from the URI path. @return Psr7UriInterface|UriInterface
[ "Remove", "the", "leading", "slash", "from", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L428-L437
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeTrailingSlash
public static function removeTrailingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('' !== $path && '/' === substr($path, -1)) { $path = substr($path, 0, -1); } return self::normalizePath($uri, $path); }
php
public static function removeTrailingSlash($uri) { $uri = self::filterUri($uri); $path = $uri->getPath(); if ('' !== $path && '/' === substr($path, -1)) { $path = substr($path, 0, -1); } return self::normalizePath($uri, $path); }
[ "public", "static", "function", "removeTrailingSlash", "(", "$", "uri", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "$", "path", "=", "$", "uri", "->", "getPath", "(", ")", ";", "if", "(", "''", "!==", "$", "p...
Remove the trailing slash from the URI path. @return Psr7UriInterface|UriInterface
[ "Remove", "the", "trailing", "slash", "from", "the", "URI", "path", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L444-L453
thephpleague/uri-components
src/UriModifier.php
UriModifier.removeSegments
public static function removeSegments($uri, int $key, int ... $keys) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withoutSegment($key, ...$keys)); }
php
public static function removeSegments($uri, int $key, int ... $keys) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withoutSegment($key, ...$keys)); }
[ "public", "static", "function", "removeSegments", "(", "$", "uri", ",", "int", "$", "key", ",", "int", "...", "$", "keys", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", ...
Remove path segments from the URI path according to their offsets. @param int... $keys @return Psr7UriInterface|UriInterface
[ "Remove", "path", "segments", "from", "the", "URI", "path", "according", "to", "their", "offsets", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L462-L467
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceBasename
public static function replaceBasename($uri, $path) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withBasename($path)); }
php
public static function replaceBasename($uri, $path) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withBasename($path)); }
[ "public", "static", "function", "replaceBasename", "(", "$", "uri", ",", "$", "path", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "Hierarc...
Replace the URI path basename. @return Psr7UriInterface|UriInterface
[ "Replace", "the", "URI", "path", "basename", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L474-L479
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceDataUriParameters
public static function replaceDataUriParameters($uri, string $parameters) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new DataPath($uri->getPath()))->withParameters($parameters)); }
php
public static function replaceDataUriParameters($uri, string $parameters) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new DataPath($uri->getPath()))->withParameters($parameters)); }
[ "public", "static", "function", "replaceDataUriParameters", "(", "$", "uri", ",", "string", "$", "parameters", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",",...
Replace the data URI path parameters. @return Psr7UriInterface|UriInterface
[ "Replace", "the", "data", "URI", "path", "parameters", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L486-L491
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceDirname
public static function replaceDirname($uri, $path) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withDirname($path)); }
php
public static function replaceDirname($uri, $path) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withDirname($path)); }
[ "public", "static", "function", "replaceDirname", "(", "$", "uri", ",", "$", "path", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "Hierarch...
Replace the URI path dirname. @return Psr7UriInterface|UriInterface
[ "Replace", "the", "URI", "path", "dirname", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L498-L503
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceExtension
public static function replaceExtension($uri, $extension) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withExtension($extension)); }
php
public static function replaceExtension($uri, $extension) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withExtension($extension)); }
[ "public", "static", "function", "replaceExtension", "(", "$", "uri", ",", "$", "extension", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "uri", ",", "(", "new", "H...
Replace the URI path basename extension. @return Psr7UriInterface|UriInterface
[ "Replace", "the", "URI", "path", "basename", "extension", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L510-L515
thephpleague/uri-components
src/UriModifier.php
UriModifier.replaceSegment
public static function replaceSegment($uri, int $offset, $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withSegment($offset, $segment)); }
php
public static function replaceSegment($uri, int $offset, $segment) { $uri = self::filterUri($uri); return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withSegment($offset, $segment)); }
[ "public", "static", "function", "replaceSegment", "(", "$", "uri", ",", "int", "$", "offset", ",", "$", "segment", ")", "{", "$", "uri", "=", "self", "::", "filterUri", "(", "$", "uri", ")", ";", "return", "self", "::", "normalizePath", "(", "$", "ur...
Replace a segment from the URI path according its offset. @return Psr7UriInterface|UriInterface
[ "Replace", "a", "segment", "from", "the", "URI", "path", "according", "its", "offset", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/UriModifier.php#L522-L527
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.createFromSegments
public static function createFromSegments(iterable $segments, int $type = self::IS_RELATIVE): self { static $type_list = [self::IS_ABSOLUTE => 1, self::IS_RELATIVE => 1]; if (!isset($type_list[$type])) { throw new PathTypeNotFound(sprintf('"%s" is an invalid or unsupported %s type', $type, self::class)); } $pathSegments = []; foreach ($segments as $value) { if (!is_scalar($value) && !method_exists($value, '__toString')) { throw new TypeError('The submitted segments are invalid'); } $pathSegments[] = (string) $value; } $path = implode(self::SEPARATOR, $pathSegments); if (static::IS_ABSOLUTE !== $type) { return new self(ltrim($path, self::SEPARATOR)); } if (self::SEPARATOR !== ($path[0] ?? '')) { return new self(self::SEPARATOR.$path); } return new self($path); }
php
public static function createFromSegments(iterable $segments, int $type = self::IS_RELATIVE): self { static $type_list = [self::IS_ABSOLUTE => 1, self::IS_RELATIVE => 1]; if (!isset($type_list[$type])) { throw new PathTypeNotFound(sprintf('"%s" is an invalid or unsupported %s type', $type, self::class)); } $pathSegments = []; foreach ($segments as $value) { if (!is_scalar($value) && !method_exists($value, '__toString')) { throw new TypeError('The submitted segments are invalid'); } $pathSegments[] = (string) $value; } $path = implode(self::SEPARATOR, $pathSegments); if (static::IS_ABSOLUTE !== $type) { return new self(ltrim($path, self::SEPARATOR)); } if (self::SEPARATOR !== ($path[0] ?? '')) { return new self(self::SEPARATOR.$path); } return new self($path); }
[ "public", "static", "function", "createFromSegments", "(", "iterable", "$", "segments", ",", "int", "$", "type", "=", "self", "::", "IS_RELATIVE", ")", ":", "self", "{", "static", "$", "type_list", "=", "[", "self", "::", "IS_ABSOLUTE", "=>", "1", ",", "...
Returns a new instance from an iterable structure. @param int $type one of the constant IS_ABSOLUTE or IS_RELATIVE @throws PathTypeNotFound If the type is not recognized @throws TypeError If the segments are malformed
[ "Returns", "a", "new", "instance", "from", "an", "iterable", "structure", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L70-L96
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.getDirname
public function getDirname(): string { $path = (string) $this->decodeComponent($this->path->__toString()); return str_replace( ['\\', "\0"], [self::SEPARATOR, '\\'], dirname(str_replace('\\', "\0", $path)) ); }
php
public function getDirname(): string { $path = (string) $this->decodeComponent($this->path->__toString()); return str_replace( ['\\', "\0"], [self::SEPARATOR, '\\'], dirname(str_replace('\\', "\0", $path)) ); }
[ "public", "function", "getDirname", "(", ")", ":", "string", "{", "$", "path", "=", "(", "string", ")", "$", "this", "->", "decodeComponent", "(", "$", "this", "->", "path", "->", "__toString", "(", ")", ")", ";", "return", "str_replace", "(", "[", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L161-L170
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.get
public function get(int $offset): ?string { if ($offset < 0) { $offset += count($this->segments); } return $this->segments[$offset] ?? null; }
php
public function get(int $offset): ?string { if ($offset < 0) { $offset += count($this->segments); } return $this->segments[$offset] ?? null; }
[ "public", "function", "get", "(", "int", "$", "offset", ")", ":", "?", "string", "{", "if", "(", "$", "offset", "<", "0", ")", "{", "$", "offset", "+=", "count", "(", "$", "this", "->", "segments", ")", ";", "}", "return", "$", "this", "->", "s...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L195-L202
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withoutDotSegments
public function withoutDotSegments(): self { $path = $this->path->withoutDotSegments(); if ($path !== $this->path) { return new self($path); } return $this; }
php
public function withoutDotSegments(): self { $path = $this->path->withoutDotSegments(); if ($path !== $this->path) { return new self($path); } return $this; }
[ "public", "function", "withoutDotSegments", "(", ")", ":", "self", "{", "$", "path", "=", "$", "this", "->", "path", "->", "withoutDotSegments", "(", ")", ";", "if", "(", "$", "path", "!==", "$", "this", "->", "path", ")", "{", "return", "new", "self...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L215-L223
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withLeadingSlash
public function withLeadingSlash(): self { $path = $this->path->withLeadingSlash(); if ($path !== $this->path) { return new self($path); } return $this; }
php
public function withLeadingSlash(): self { $path = $this->path->withLeadingSlash(); if ($path !== $this->path) { return new self($path); } return $this; }
[ "public", "function", "withLeadingSlash", "(", ")", ":", "self", "{", "$", "path", "=", "$", "this", "->", "path", "->", "withLeadingSlash", "(", ")", ";", "if", "(", "$", "path", "!==", "$", "this", "->", "path", ")", "{", "return", "new", "self", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L228-L236
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withoutLeadingSlash
public function withoutLeadingSlash(): self { $path = $this->path->withoutLeadingSlash(); if ($path !== $this->path) { return new self($path); } return $this; }
php
public function withoutLeadingSlash(): self { $path = $this->path->withoutLeadingSlash(); if ($path !== $this->path) { return new self($path); } return $this; }
[ "public", "function", "withoutLeadingSlash", "(", ")", ":", "self", "{", "$", "path", "=", "$", "this", "->", "path", "->", "withoutLeadingSlash", "(", ")", ";", "if", "(", "$", "path", "!==", "$", "this", "->", "path", ")", "{", "return", "new", "se...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L241-L249
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.append
public function append($segment): self { $segment = $this->filterComponent($segment); if (null === $segment) { throw new TypeError('The appended path can not be null'); } return new self( rtrim($this->path->__toString(), self::SEPARATOR) .self::SEPARATOR .ltrim($segment, self::SEPARATOR) ); }
php
public function append($segment): self { $segment = $this->filterComponent($segment); if (null === $segment) { throw new TypeError('The appended path can not be null'); } return new self( rtrim($this->path->__toString(), self::SEPARATOR) .self::SEPARATOR .ltrim($segment, self::SEPARATOR) ); }
[ "public", "function", "append", "(", "$", "segment", ")", ":", "self", "{", "$", "segment", "=", "$", "this", "->", "filterComponent", "(", "$", "segment", ")", ";", "if", "(", "null", "===", "$", "segment", ")", "{", "throw", "new", "TypeError", "("...
{@inheritdoc} @see ::withSegment
[ "{", "@inheritdoc", "}" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L269-L281
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withSegment
public function withSegment(int $key, $segment): self { $nb_segments = count($this->segments); if ($key < - $nb_segments - 1 || $key > $nb_segments) { throw new OffsetOutOfBounds(sprintf('the given key `%s` is invalid', $key)); } if (0 > $key) { $key += $nb_segments; } if ($nb_segments === $key) { return $this->append($segment); } if (-1 === $key) { return $this->prepend($segment); } if (!$segment instanceof PathInterface) { $segment = new self($segment); } $segment = $this->decodeComponent((string) $segment); if ($segment === $this->segments[$key]) { return $this; } $segments = $this->segments; $segments[$key] = $segment; if ($this->isAbsolute()) { array_unshift($segments, ''); } return new self(implode(self::SEPARATOR, $segments)); }
php
public function withSegment(int $key, $segment): self { $nb_segments = count($this->segments); if ($key < - $nb_segments - 1 || $key > $nb_segments) { throw new OffsetOutOfBounds(sprintf('the given key `%s` is invalid', $key)); } if (0 > $key) { $key += $nb_segments; } if ($nb_segments === $key) { return $this->append($segment); } if (-1 === $key) { return $this->prepend($segment); } if (!$segment instanceof PathInterface) { $segment = new self($segment); } $segment = $this->decodeComponent((string) $segment); if ($segment === $this->segments[$key]) { return $this; } $segments = $this->segments; $segments[$key] = $segment; if ($this->isAbsolute()) { array_unshift($segments, ''); } return new self(implode(self::SEPARATOR, $segments)); }
[ "public", "function", "withSegment", "(", "int", "$", "key", ",", "$", "segment", ")", ":", "self", "{", "$", "nb_segments", "=", "count", "(", "$", "this", "->", "segments", ")", ";", "if", "(", "$", "key", "<", "-", "$", "nb_segments", "-", "1", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L305-L340
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withoutSegment
public function withoutSegment(int $key, int ...$keys): self { $keys[] = $key; $nb_segments = count($this->segments); $options = ['options' => ['min_range' => - $nb_segments, 'max_range' => $nb_segments - 1]]; $deleted_keys = []; foreach ($keys as $key) { if (false === ($offset = filter_var($key, FILTER_VALIDATE_INT, $options))) { throw new OffsetOutOfBounds(sprintf('the key `%s` is invalid', $key)); } if ($offset < 0) { $offset += $nb_segments; } $deleted_keys[] = $offset; } $deleted_keys = array_keys(array_count_values($deleted_keys)); $filter = static function ($key) use ($deleted_keys): bool { return !in_array($key, $deleted_keys, true); }; $path = implode(self::SEPARATOR, array_filter($this->segments, $filter, ARRAY_FILTER_USE_KEY)); if ($this->isAbsolute()) { return new self(self::SEPARATOR.$path); } return new self($path); }
php
public function withoutSegment(int $key, int ...$keys): self { $keys[] = $key; $nb_segments = count($this->segments); $options = ['options' => ['min_range' => - $nb_segments, 'max_range' => $nb_segments - 1]]; $deleted_keys = []; foreach ($keys as $key) { if (false === ($offset = filter_var($key, FILTER_VALIDATE_INT, $options))) { throw new OffsetOutOfBounds(sprintf('the key `%s` is invalid', $key)); } if ($offset < 0) { $offset += $nb_segments; } $deleted_keys[] = $offset; } $deleted_keys = array_keys(array_count_values($deleted_keys)); $filter = static function ($key) use ($deleted_keys): bool { return !in_array($key, $deleted_keys, true); }; $path = implode(self::SEPARATOR, array_filter($this->segments, $filter, ARRAY_FILTER_USE_KEY)); if ($this->isAbsolute()) { return new self(self::SEPARATOR.$path); } return new self($path); }
[ "public", "function", "withoutSegment", "(", "int", "$", "key", ",", "int", "...", "$", "keys", ")", ":", "self", "{", "$", "keys", "[", "]", "=", "$", "key", ";", "$", "nb_segments", "=", "count", "(", "$", "this", "->", "segments", ")", ";", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L353-L381
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withDirname
public function withDirname($path): self { if (!$path instanceof PathInterface) { $path = new Path($path); } if ($path->getContent() === $this->getDirname()) { return $this; } return new self( rtrim($path->__toString(), self::SEPARATOR) .self::SEPARATOR .array_pop($this->segments) ); }
php
public function withDirname($path): self { if (!$path instanceof PathInterface) { $path = new Path($path); } if ($path->getContent() === $this->getDirname()) { return $this; } return new self( rtrim($path->__toString(), self::SEPARATOR) .self::SEPARATOR .array_pop($this->segments) ); }
[ "public", "function", "withDirname", "(", "$", "path", ")", ":", "self", "{", "if", "(", "!", "$", "path", "instanceof", "PathInterface", ")", "{", "$", "path", "=", "new", "Path", "(", "$", "path", ")", ";", "}", "if", "(", "$", "path", "->", "g...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L386-L401
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withBasename
public function withBasename($basename): self { $basename = $this->validateComponent($basename); if (null === $basename) { throw new SyntaxError('a basename sequence can not be null'); } if (false !== strpos($basename, self::SEPARATOR)) { throw new SyntaxError('The basename can not contain the path separator'); } return $this->withSegment(count($this->segments) - 1, $basename); }
php
public function withBasename($basename): self { $basename = $this->validateComponent($basename); if (null === $basename) { throw new SyntaxError('a basename sequence can not be null'); } if (false !== strpos($basename, self::SEPARATOR)) { throw new SyntaxError('The basename can not contain the path separator'); } return $this->withSegment(count($this->segments) - 1, $basename); }
[ "public", "function", "withBasename", "(", "$", "basename", ")", ":", "self", "{", "$", "basename", "=", "$", "this", "->", "validateComponent", "(", "$", "basename", ")", ";", "if", "(", "null", "===", "$", "basename", ")", "{", "throw", "new", "Synta...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L406-L418
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.withExtension
public function withExtension($extension): self { $extension = $this->validateComponent($extension); if (null === $extension) { throw new SyntaxError('an extension sequence can not be null'); } if (false !== strpos($extension, self::SEPARATOR)) { throw new SyntaxError('an extension sequence can not contain a path delimiter'); } if (0 === strpos($extension, '.')) { throw new SyntaxError('an extension sequence can not contain a leading `.` character'); } $basename = end($this->segments); [$ext, $param] = explode(';', $basename, 2) + [1 => null]; if ('' === $ext) { return $this; } return $this->withBasename($this->buildBasename($extension, $ext, $param)); }
php
public function withExtension($extension): self { $extension = $this->validateComponent($extension); if (null === $extension) { throw new SyntaxError('an extension sequence can not be null'); } if (false !== strpos($extension, self::SEPARATOR)) { throw new SyntaxError('an extension sequence can not contain a path delimiter'); } if (0 === strpos($extension, '.')) { throw new SyntaxError('an extension sequence can not contain a leading `.` character'); } $basename = end($this->segments); [$ext, $param] = explode(';', $basename, 2) + [1 => null]; if ('' === $ext) { return $this; } return $this->withBasename($this->buildBasename($extension, $ext, $param)); }
[ "public", "function", "withExtension", "(", "$", "extension", ")", ":", "self", "{", "$", "extension", "=", "$", "this", "->", "validateComponent", "(", "$", "extension", ")", ";", "if", "(", "null", "===", "$", "extension", ")", "{", "throw", "new", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L423-L445
thephpleague/uri-components
src/Component/HierarchicalPath.php
HierarchicalPath.buildBasename
private function buildBasename(string $extension, string $ext, string $param = null): string { $length = strrpos($ext, '.'.pathinfo($ext, PATHINFO_EXTENSION)); if (false !== $length) { $ext = substr($ext, 0, $length); } if (null !== $param && '' !== $param) { $param = ';'.$param; } $extension = trim($extension); if ('' === $extension) { return $ext.$param; } return $ext.'.'.$extension.$param; }
php
private function buildBasename(string $extension, string $ext, string $param = null): string { $length = strrpos($ext, '.'.pathinfo($ext, PATHINFO_EXTENSION)); if (false !== $length) { $ext = substr($ext, 0, $length); } if (null !== $param && '' !== $param) { $param = ';'.$param; } $extension = trim($extension); if ('' === $extension) { return $ext.$param; } return $ext.'.'.$extension.$param; }
[ "private", "function", "buildBasename", "(", "string", "$", "extension", ",", "string", "$", "ext", ",", "string", "$", "param", "=", "null", ")", ":", "string", "{", "$", "length", "=", "strrpos", "(", "$", "ext", ",", "'.'", ".", "pathinfo", "(", "...
Creates a new basename with a new extension.
[ "Creates", "a", "new", "basename", "with", "a", "new", "extension", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/HierarchicalPath.php#L450-L467
thephpleague/uri-components
src/Component/Host.php
Host.createFromIp
public static function createFromIp(string $ip, string $version = '') { if ('' !== $version) { return new self('[v'.$version.'.'.$ip.']'); } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return new self($ip); } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return new self('['.$ip.']'); } if (false !== strpos($ip, '%')) { [$ipv6, $zoneId] = explode('%', rawurldecode($ip), 2) + [1 => '']; return new self('['.$ipv6.'%25'.rawurlencode($zoneId).']'); } throw new SyntaxError(sprintf('`%s` is an invalid IP Host', $ip)); }
php
public static function createFromIp(string $ip, string $version = '') { if ('' !== $version) { return new self('[v'.$version.'.'.$ip.']'); } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return new self($ip); } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return new self('['.$ip.']'); } if (false !== strpos($ip, '%')) { [$ipv6, $zoneId] = explode('%', rawurldecode($ip), 2) + [1 => '']; return new self('['.$ipv6.'%25'.rawurlencode($zoneId).']'); } throw new SyntaxError(sprintf('`%s` is an invalid IP Host', $ip)); }
[ "public", "static", "function", "createFromIp", "(", "string", "$", "ip", ",", "string", "$", "version", "=", "''", ")", "{", "if", "(", "''", "!==", "$", "version", ")", "{", "return", "new", "self", "(", "'[v'", ".", "$", "version", ".", "'.'", "...
Returns a host from an IP address. @throws SyntaxError If the $ip can not be converted into a Host @return static
[ "Returns", "a", "host", "from", "an", "IP", "address", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L158-L179
thephpleague/uri-components
src/Component/Host.php
Host.getIDNAErrors
private function getIDNAErrors(int $error_byte): string { /** * IDNA errors. */ static $idn_errors = [ IDNA_ERROR_EMPTY_LABEL => 'a non-final domain name label (or the whole domain name) is empty', IDNA_ERROR_LABEL_TOO_LONG => 'a domain name label is longer than 63 bytes', IDNA_ERROR_DOMAIN_NAME_TOO_LONG => 'a domain name is longer than 255 bytes in its storage form', IDNA_ERROR_LEADING_HYPHEN => 'a label starts with a hyphen-minus ("-")', IDNA_ERROR_TRAILING_HYPHEN => 'a label ends with a hyphen-minus ("-")', IDNA_ERROR_HYPHEN_3_4 => 'a label contains hyphen-minus ("-") in the third and fourth positions', IDNA_ERROR_LEADING_COMBINING_MARK => 'a label starts with a combining mark', IDNA_ERROR_DISALLOWED => 'a label or domain name contains disallowed characters', IDNA_ERROR_PUNYCODE => 'a label starts with "xn--" but does not contain valid Punycode', IDNA_ERROR_LABEL_HAS_DOT => 'a label contains a dot=full stop', IDNA_ERROR_INVALID_ACE_LABEL => 'An ACE label does not contain a valid label string', IDNA_ERROR_BIDI => 'a label does not meet the IDNA BiDi requirements (for right-to-left characters)', IDNA_ERROR_CONTEXTJ => 'a label does not meet the IDNA CONTEXTJ requirements', ]; $res = []; foreach ($idn_errors as $error => $reason) { if ($error_byte & $error) { $res[] = $reason; } } return [] === $res ? 'Unknown IDNA conversion error.' : implode(', ', $res).'.'; }
php
private function getIDNAErrors(int $error_byte): string { /** * IDNA errors. */ static $idn_errors = [ IDNA_ERROR_EMPTY_LABEL => 'a non-final domain name label (or the whole domain name) is empty', IDNA_ERROR_LABEL_TOO_LONG => 'a domain name label is longer than 63 bytes', IDNA_ERROR_DOMAIN_NAME_TOO_LONG => 'a domain name is longer than 255 bytes in its storage form', IDNA_ERROR_LEADING_HYPHEN => 'a label starts with a hyphen-minus ("-")', IDNA_ERROR_TRAILING_HYPHEN => 'a label ends with a hyphen-minus ("-")', IDNA_ERROR_HYPHEN_3_4 => 'a label contains hyphen-minus ("-") in the third and fourth positions', IDNA_ERROR_LEADING_COMBINING_MARK => 'a label starts with a combining mark', IDNA_ERROR_DISALLOWED => 'a label or domain name contains disallowed characters', IDNA_ERROR_PUNYCODE => 'a label starts with "xn--" but does not contain valid Punycode', IDNA_ERROR_LABEL_HAS_DOT => 'a label contains a dot=full stop', IDNA_ERROR_INVALID_ACE_LABEL => 'An ACE label does not contain a valid label string', IDNA_ERROR_BIDI => 'a label does not meet the IDNA BiDi requirements (for right-to-left characters)', IDNA_ERROR_CONTEXTJ => 'a label does not meet the IDNA CONTEXTJ requirements', ]; $res = []; foreach ($idn_errors as $error => $reason) { if ($error_byte & $error) { $res[] = $reason; } } return [] === $res ? 'Unknown IDNA conversion error.' : implode(', ', $res).'.'; }
[ "private", "function", "getIDNAErrors", "(", "int", "$", "error_byte", ")", ":", "string", "{", "/**\n * IDNA errors.\n */", "static", "$", "idn_errors", "=", "[", "IDNA_ERROR_EMPTY_LABEL", "=>", "'a non-final domain name label (or the whole domain name) is empt...
Retrieves and format IDNA conversion error message. @see http://icu-project.org/apiref/icu4j/com/ibm/icu/text/IDNA.Error.html
[ "Retrieves", "and", "format", "IDNA", "conversion", "error", "message", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L262-L291
thephpleague/uri-components
src/Component/Host.php
Host.isValidIpv6Hostname
private function isValidIpv6Hostname(string $host): bool { [$ipv6, $scope] = explode('%', $host, 2) + [1 => null]; if (null === $scope) { return (bool) filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); } $scope = rawurldecode('%'.$scope); return 1 !== preg_match(self::REGEXP_NON_ASCII_PATTERN, $scope) && 1 !== preg_match(self::REGEXP_GEN_DELIMS, $scope) && filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && 0 === strpos((string) inet_pton((string) $ipv6), self::ADDRESS_BLOCK); }
php
private function isValidIpv6Hostname(string $host): bool { [$ipv6, $scope] = explode('%', $host, 2) + [1 => null]; if (null === $scope) { return (bool) filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); } $scope = rawurldecode('%'.$scope); return 1 !== preg_match(self::REGEXP_NON_ASCII_PATTERN, $scope) && 1 !== preg_match(self::REGEXP_GEN_DELIMS, $scope) && filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && 0 === strpos((string) inet_pton((string) $ipv6), self::ADDRESS_BLOCK); }
[ "private", "function", "isValidIpv6Hostname", "(", "string", "$", "host", ")", ":", "bool", "{", "[", "$", "ipv6", ",", "$", "scope", "]", "=", "explode", "(", "'%'", ",", "$", "host", ",", "2", ")", "+", "[", "1", "=>", "null", "]", ";", "if", ...
Validates an Ipv6 as Host. @see http://tools.ietf.org/html/rfc6874#section-2 @see http://tools.ietf.org/html/rfc6874#section-4
[ "Validates", "an", "Ipv6", "as", "Host", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L299-L312
thephpleague/uri-components
src/Component/Host.php
Host.toUnicode
public function toUnicode(): ?string { if (null !== $this->ip_version || null === $this->host || false === strpos($this->host, 'xn--') ) { return $this->host; } $host = idn_to_utf8($this->host, 0, INTL_IDNA_VARIANT_UTS46, $arr); if (0 !== $arr['errors']) { $message = $this->getIDNAErrors($arr['errors']); throw new SyntaxError(sprintf('The host `%s` is invalid : %s', $this->host, $message)); } // @codeCoverageIgnoreStart if (false === $host) { throw new IdnSupportMissing(sprintf('The Intl extension is misconfigured for %s, please correct this issue before proceeding.', PHP_OS)); } // @codeCoverageIgnoreEnd return $host; }
php
public function toUnicode(): ?string { if (null !== $this->ip_version || null === $this->host || false === strpos($this->host, 'xn--') ) { return $this->host; } $host = idn_to_utf8($this->host, 0, INTL_IDNA_VARIANT_UTS46, $arr); if (0 !== $arr['errors']) { $message = $this->getIDNAErrors($arr['errors']); throw new SyntaxError(sprintf('The host `%s` is invalid : %s', $this->host, $message)); } // @codeCoverageIgnoreStart if (false === $host) { throw new IdnSupportMissing(sprintf('The Intl extension is misconfigured for %s, please correct this issue before proceeding.', PHP_OS)); } // @codeCoverageIgnoreEnd return $host; }
[ "public", "function", "toUnicode", "(", ")", ":", "?", "string", "{", "if", "(", "null", "!==", "$", "this", "->", "ip_version", "||", "null", "===", "$", "this", "->", "host", "||", "false", "===", "strpos", "(", "$", "this", "->", "host", ",", "'...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L333-L355
thephpleague/uri-components
src/Component/Host.php
Host.getIp
public function getIp(): ?string { if (null === $this->ip_version) { return null; } if ('4' === $this->ip_version) { return $this->host; } $ip = substr((string) $this->host, 1, -1); if ('6' !== $this->ip_version) { return substr($ip, strpos($ip, '.') + 1); } $pos = strpos($ip, '%'); if (false === $pos) { return $ip; } return substr($ip, 0, $pos).'%'.rawurldecode(substr($ip, $pos + 3)); }
php
public function getIp(): ?string { if (null === $this->ip_version) { return null; } if ('4' === $this->ip_version) { return $this->host; } $ip = substr((string) $this->host, 1, -1); if ('6' !== $this->ip_version) { return substr($ip, strpos($ip, '.') + 1); } $pos = strpos($ip, '%'); if (false === $pos) { return $ip; } return substr($ip, 0, $pos).'%'.rawurldecode(substr($ip, $pos + 3)); }
[ "public", "function", "getIp", "(", ")", ":", "?", "string", "{", "if", "(", "null", "===", "$", "this", "->", "ip_version", ")", "{", "return", "null", ";", "}", "if", "(", "'4'", "===", "$", "this", "->", "ip_version", ")", "{", "return", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L368-L389
thephpleague/uri-components
src/Component/Host.php
Host.withoutZoneIdentifier
public function withoutZoneIdentifier(): self { if (!$this->has_zone_identifier) { return $this; } [$ipv6, ] = explode('%', substr((string) $this->host, 1, -1)); return static::createFromIp($ipv6); }
php
public function withoutZoneIdentifier(): self { if (!$this->has_zone_identifier) { return $this; } [$ipv6, ] = explode('%', substr((string) $this->host, 1, -1)); return static::createFromIp($ipv6); }
[ "public", "function", "withoutZoneIdentifier", "(", ")", ":", "self", "{", "if", "(", "!", "$", "this", "->", "has_zone_identifier", ")", "{", "return", "$", "this", ";", "}", "[", "$", "ipv6", ",", "]", "=", "explode", "(", "'%'", ",", "substr", "("...
Returns an host without its zone identifier according to RFC6874. This method MUST retain the state of the current instance, and return an instance without the host zone identifier according to RFC6874 @see http://tools.ietf.org/html/rfc6874#section-4 @return static
[ "Returns", "an", "host", "without", "its", "zone", "identifier", "according", "to", "RFC6874", "." ]
train
https://github.com/thephpleague/uri-components/blob/215f10d66ad3463b1f31bdc1e1ab135e6911ad83/src/Component/Host.php#L451-L460
matteosister/GitElephant
src/GitElephant/Command/Remote/ShowSubCommand.php
ShowSubCommand.prepare
public function prepare($name = null, $queryRemotes = true) { $this->addCommandName(self::GIT_REMOTE_SHOW); /** * only add subject if relevant, * otherwise on repositories without a remote defined (ie, fresh * init'd or mock) will likely trigger warning/error condition * */ if ($name) { $this->addCommandSubject($name); } if (!$queryRemotes) { $this->addCommandArgument('-n'); } return $this; }
php
public function prepare($name = null, $queryRemotes = true) { $this->addCommandName(self::GIT_REMOTE_SHOW); /** * only add subject if relevant, * otherwise on repositories without a remote defined (ie, fresh * init'd or mock) will likely trigger warning/error condition * */ if ($name) { $this->addCommandSubject($name); } if (!$queryRemotes) { $this->addCommandArgument('-n'); } return $this; }
[ "public", "function", "prepare", "(", "$", "name", "=", "null", ",", "$", "queryRemotes", "=", "true", ")", "{", "$", "this", "->", "addCommandName", "(", "self", "::", "GIT_REMOTE_SHOW", ")", ";", "/**\n * only add subject if relevant,\n * otherwi...
build show sub command NOTE: for technical reasons $name is optional, however under normal implementation it SHOULD be passed! @param string $name @param bool $queryRemotes Fetch new information from remotes @return ShowSubCommand
[ "build", "show", "sub", "command" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/Remote/ShowSubCommand.php#L60-L78
matteosister/GitElephant
src/GitElephant/Command/Remote/AddSubCommand.php
AddSubCommand.addCmdValueOptions
public function addCmdValueOptions() { return array( self::GIT_REMOTE_ADD_OPTION_TRACK => self::GIT_REMOTE_ADD_OPTION_TRACK, self::GIT_REMOTE_ADD_OPTION_MIRROR => self::GIT_REMOTE_ADD_OPTION_MIRROR, self::GIT_REMOTE_ADD_OPTION_SETHEAD => self::GIT_REMOTE_ADD_OPTION_SETHEAD, ); }
php
public function addCmdValueOptions() { return array( self::GIT_REMOTE_ADD_OPTION_TRACK => self::GIT_REMOTE_ADD_OPTION_TRACK, self::GIT_REMOTE_ADD_OPTION_MIRROR => self::GIT_REMOTE_ADD_OPTION_MIRROR, self::GIT_REMOTE_ADD_OPTION_SETHEAD => self::GIT_REMOTE_ADD_OPTION_SETHEAD, ); }
[ "public", "function", "addCmdValueOptions", "(", ")", "{", "return", "array", "(", "self", "::", "GIT_REMOTE_ADD_OPTION_TRACK", "=>", "self", "::", "GIT_REMOTE_ADD_OPTION_TRACK", ",", "self", "::", "GIT_REMOTE_ADD_OPTION_MIRROR", "=>", "self", "::", "GIT_REMOTE_ADD_OPTI...
Valid options for remote command that require an associated value @return array Array of all value-required options
[ "Valid", "options", "for", "remote", "command", "that", "require", "an", "associated", "value" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/Remote/AddSubCommand.php#L60-L67
matteosister/GitElephant
src/GitElephant/Command/Remote/AddSubCommand.php
AddSubCommand.addCmdSwitchOptions
public function addCmdSwitchOptions() { return array( self::GIT_REMOTE_ADD_OPTION_TAGS => self::GIT_REMOTE_ADD_OPTION_TAGS, self::GIT_REMOTE_ADD_OPTION_NOTAGS => self::GIT_REMOTE_ADD_OPTION_NOTAGS, self::GIT_REMOTE_ADD_OPTION_FETCH => self::GIT_REMOTE_ADD_OPTION_FETCH, ); }
php
public function addCmdSwitchOptions() { return array( self::GIT_REMOTE_ADD_OPTION_TAGS => self::GIT_REMOTE_ADD_OPTION_TAGS, self::GIT_REMOTE_ADD_OPTION_NOTAGS => self::GIT_REMOTE_ADD_OPTION_NOTAGS, self::GIT_REMOTE_ADD_OPTION_FETCH => self::GIT_REMOTE_ADD_OPTION_FETCH, ); }
[ "public", "function", "addCmdSwitchOptions", "(", ")", "{", "return", "array", "(", "self", "::", "GIT_REMOTE_ADD_OPTION_TAGS", "=>", "self", "::", "GIT_REMOTE_ADD_OPTION_TAGS", ",", "self", "::", "GIT_REMOTE_ADD_OPTION_NOTAGS", "=>", "self", "::", "GIT_REMOTE_ADD_OPTIO...
switch only options for the add subcommand @return array
[ "switch", "only", "options", "for", "the", "add", "subcommand" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/Remote/AddSubCommand.php#L74-L81
matteosister/GitElephant
src/GitElephant/Command/Remote/AddSubCommand.php
AddSubCommand.prepare
public function prepare($name, $url, $options = array()) { $options = $this->normalizeOptions( $options, $this->addCmdSwitchOptions(), $this->addCmdValueOptions() ); $this->addCommandName(self::GIT_REMOTE_ADD); $this->addCommandSubject($name); $this->addCommandSubject($url); foreach ($options as $option) { $this->addCommandArgument($option); } return $this; }
php
public function prepare($name, $url, $options = array()) { $options = $this->normalizeOptions( $options, $this->addCmdSwitchOptions(), $this->addCmdValueOptions() ); $this->addCommandName(self::GIT_REMOTE_ADD); $this->addCommandSubject($name); $this->addCommandSubject($url); foreach ($options as $option) { $this->addCommandArgument($option); } return $this; }
[ "public", "function", "prepare", "(", "$", "name", ",", "$", "url", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "$", "this", "->", "normalizeOptions", "(", "$", "options", ",", "$", "this", "->", "addCmdSwitchOptions", ...
build add sub command @param string $name remote name @param string $url URL of remote @param array $options options for the add subcommand @return string
[ "build", "add", "sub", "command" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/Remote/AddSubCommand.php#L92-L108
matteosister/GitElephant
src/GitElephant/Command/DiffTreeCommand.php
DiffTreeCommand.rootDiff
public function rootDiff(Commit $commit) { if (!$commit->isRoot()) { throw new \InvalidArgumentException('rootDiff method accepts only root commits'); } $this->clearAll(); $this->addCommandName(static::DIFF_TREE_COMMAND); $this->addCommandArgument('--cc'); $this->addCommandArgument('--root'); $this->addCommandArgument('--dst-prefix=DST/'); $this->addCommandArgument('--src-prefix=SRC/'); $this->addCommandSubject($commit); return $this->getCommand(); }
php
public function rootDiff(Commit $commit) { if (!$commit->isRoot()) { throw new \InvalidArgumentException('rootDiff method accepts only root commits'); } $this->clearAll(); $this->addCommandName(static::DIFF_TREE_COMMAND); $this->addCommandArgument('--cc'); $this->addCommandArgument('--root'); $this->addCommandArgument('--dst-prefix=DST/'); $this->addCommandArgument('--src-prefix=SRC/'); $this->addCommandSubject($commit); return $this->getCommand(); }
[ "public", "function", "rootDiff", "(", "Commit", "$", "commit", ")", "{", "if", "(", "!", "$", "commit", "->", "isRoot", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'rootDiff method accepts only root commits'", ")", ";", "}", ...
get a diff of a root commit with the empty repository @param \GitElephant\Objects\Commit $commit the root commit object @throws \RuntimeException @throws \InvalidArgumentException @return string
[ "get", "a", "diff", "of", "a", "root", "commit", "with", "the", "empty", "repository" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/DiffTreeCommand.php#L56-L70
matteosister/GitElephant
src/GitElephant/Objects/Tag.php
Tag.create
public static function create( Repository $repository, string $name, $startPoint = null, string $message = null ) { $repository ->getCaller() ->execute(TagCommand::getInstance($repository)->create($name, $startPoint, $message)); return $repository->getTag($name); }
php
public static function create( Repository $repository, string $name, $startPoint = null, string $message = null ) { $repository ->getCaller() ->execute(TagCommand::getInstance($repository)->create($name, $startPoint, $message)); return $repository->getTag($name); }
[ "public", "static", "function", "create", "(", "Repository", "$", "repository", ",", "string", "$", "name", ",", "$", "startPoint", "=", "null", ",", "string", "$", "message", "=", "null", ")", "{", "$", "repository", "->", "getCaller", "(", ")", "->", ...
Creates a new tag on the repository and returns it @param \GitElephant\Repository $repository repository instance @param string $name branch name @param string $startPoint branch to start from @param string $message tag message @throws \RuntimeException @return \GitElephant\Objects\Tag
[ "Creates", "a", "new", "tag", "on", "the", "repository", "and", "returns", "it" ]
train
https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Tag.php#L65-L77