1 | <?php |
||
14 | final class Psr4Namespace |
||
15 | { |
||
16 | private $namespace; |
||
17 | |||
18 | /** |
||
19 | * Constructor |
||
20 | * Take in the namespace value as a string |
||
21 | * |
||
22 | * @param string $namespace |
||
23 | */ |
||
24 | public function __construct(string $namespace) |
||
28 | |||
29 | /** |
||
30 | * Handle setting the namepsace string value |
||
31 | * |
||
32 | * @param string $value |
||
33 | */ |
||
34 | private function setValue(string $value) |
||
44 | |||
45 | /** |
||
46 | * Determine if the supplied namespace string is a valid according to the |
||
47 | * psr4 standard |
||
48 | * |
||
49 | * @param string $namespace |
||
50 | * @return boolean |
||
51 | */ |
||
52 | private function isValid(string $namespace): bool |
||
60 | |||
61 | /** |
||
62 | * Get the namespace value as a string |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getValue(): string |
||
70 | |||
71 | /** |
||
72 | * Handle the object when treated as a string |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function __toString(): string |
||
80 | |||
81 | /** |
||
82 | * Determine the supplied namespace is the same as the current namespace |
||
83 | * |
||
84 | * @param Psr4Namespace $value |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function equals(Psr4Namespace $value): bool |
||
91 | |||
92 | /** |
||
93 | * Determine if this namepsace starts with the supplied namespace |
||
94 | * |
||
95 | * @param Psr4Namespace $value |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function startsWith(Psr4Namespace $value): bool |
||
104 | |||
105 | /** |
||
106 | * Get the length of the namepsace as a string (characters) |
||
107 | * @return int |
||
108 | */ |
||
109 | public function length(): int |
||
113 | } |
||
114 |