| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* League.Uri (https://uri.thephpleague.com) |
| 5 |
* |
| 6 |
* (c) Ignace Nyamagana Butera <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
declare(strict_types=1); |
| 13 |
|
| 14 |
namespace WP_DEFENDER_VENDOR\League\Uri\Contracts; |
| 15 |
|
| 16 |
use WP_DEFENDER_VENDOR\League\Uri\Exceptions\SyntaxError; |
| 17 |
|
| 18 |
/** |
| 19 |
* @extends \IteratorAggregate<string> |
| 20 |
*/ |
| 21 |
interface SegmentedPathInterface extends \Countable, \IteratorAggregate, PathInterface |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Returns the total number of segments in the path. |
| 25 |
*/ |
| 26 |
public function count(): int; |
| 27 |
|
| 28 |
/** |
| 29 |
* Iterate over the path segment. |
| 30 |
* |
| 31 |
* @return \Iterator<string> |
| 32 |
*/ |
| 33 |
public function getIterator(): \Iterator; |
| 34 |
|
| 35 |
/** |
| 36 |
* Returns parent directory's path. |
| 37 |
*/ |
| 38 |
public function getDirname(): string; |
| 39 |
|
| 40 |
/** |
| 41 |
* Returns the path basename. |
| 42 |
*/ |
| 43 |
public function getBasename(): string; |
| 44 |
|
| 45 |
/** |
| 46 |
* Returns the basename extension. |
| 47 |
*/ |
| 48 |
public function getExtension(): string; |
| 49 |
|
| 50 |
/** |
| 51 |
* Retrieves a single path segment. |
| 52 |
* |
| 53 |
* If the segment offset has not been set, returns null. |
| 54 |
*/ |
| 55 |
public function get(int $offset): ?string; |
| 56 |
|
| 57 |
/** |
| 58 |
* Returns the associated key for a specific segment. |
| 59 |
* |
| 60 |
* If a value is specified only the keys associated with |
| 61 |
* the given value will be returned |
| 62 |
* |
| 63 |
* @param ?string $segment |
| 64 |
* |
| 65 |
* @return int[] |
| 66 |
*/ |
| 67 |
public function keys(?string $segment = null): array; |
| 68 |
|
| 69 |
/** |
| 70 |
* Appends a segment to the path. |
| 71 |
*/ |
| 72 |
public function append(string $segment): self; |
| 73 |
|
| 74 |
/** |
| 75 |
* Prepends a segment to the path. |
| 76 |
*/ |
| 77 |
public function prepend(string $segment): self; |
| 78 |
|
| 79 |
/** |
| 80 |
* Returns an instance with the modified segment. |
| 81 |
* |
| 82 |
* This method MUST retain the state of the current instance, and return |
| 83 |
* an instance that contains the new segment |
| 84 |
* |
| 85 |
* If $key is non-negative, the added segment will be the segment at $key position from the start. |
| 86 |
* If $key is negative, the added segment will be the segment at $key position from the end. |
| 87 |
* |
| 88 |
* @param ?string $segment |
| 89 |
* |
| 90 |
* @throws SyntaxError If the key is invalid |
| 91 |
*/ |
| 92 |
public function withSegment(int $key, ?string $segment): self; |
| 93 |
|
| 94 |
/** |
| 95 |
* Returns an instance without the specified segment. |
| 96 |
* |
| 97 |
* This method MUST retain the state of the current instance, and return |
| 98 |
* an instance that contains the modified component |
| 99 |
* |
| 100 |
* If $key is non-negative, the removed segment will be the segment at $key position from the start. |
| 101 |
* If $key is negative, the removed segment will be the segment at $key position from the end. |
| 102 |
* |
| 103 |
* @param int ...$keys remaining keys to remove |
| 104 |
* |
| 105 |
* @throws SyntaxError If the key is invalid |
| 106 |
*/ |
| 107 |
public function withoutSegment(int ...$keys): self; |
| 108 |
|
| 109 |
/** |
| 110 |
* Returns an instance without duplicate delimiters. |
| 111 |
* |
| 112 |
* This method MUST retain the state of the current instance, and return |
| 113 |
* an instance that contains the path component normalized by removing |
| 114 |
* multiple consecutive empty segment |
| 115 |
*/ |
| 116 |
public function withoutEmptySegments(): self; |
| 117 |
|
| 118 |
/** |
| 119 |
* Returns an instance with the specified parent directory's path. |
| 120 |
* |
| 121 |
* This method MUST retain the state of the current instance, and return |
| 122 |
* an instance that contains the extension basename modified. |
| 123 |
* |
| 124 |
* @param ?string $path |
| 125 |
*/ |
| 126 |
public function withDirname(?string $path): self; |
| 127 |
|
| 128 |
/** |
| 129 |
* Returns an instance with the specified basename. |
| 130 |
* |
| 131 |
* This method MUST retain the state of the current instance, and return |
| 132 |
* an instance that contains the extension basename modified. |
| 133 |
* |
| 134 |
* @param ?string $basename |
| 135 |
*/ |
| 136 |
public function withBasename(?string $basename): self; |
| 137 |
|
| 138 |
/** |
| 139 |
* Returns an instance with the specified basename extension. |
| 140 |
* |
| 141 |
* This method MUST retain the state of the current instance, and return |
| 142 |
* an instance that contains the extension basename modified. |
| 143 |
* |
| 144 |
* @param ?string $extension |
| 145 |
*/ |
| 146 |
public function withExtension(?string $extension): self; |
| 147 |
} |
| 148 |
|