1 | <?php |
||
9 | class Scope |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | private $locales; |
||
15 | |||
16 | /** |
||
17 | * The default locale. In the request path |
||
18 | * it's the hidden segment, e.g. /. |
||
19 | * |
||
20 | * @var Locale |
||
21 | */ |
||
22 | private $default; |
||
23 | |||
24 | /** |
||
25 | * When the canonical scope has a root set to be |
||
26 | * other than the current, that specific root is defined here |
||
27 | * By default the current request root is of use (NULL). |
||
28 | * |
||
29 | * @var null|Root |
||
30 | */ |
||
31 | private $customRoot = null; |
||
32 | |||
33 | 75 | public function __construct(array $locales) |
|
41 | |||
42 | 11 | public function setCustomRoot(Root $customRoot) |
|
48 | |||
49 | 9 | public function customRoot(): ?Root |
|
53 | |||
54 | /** |
||
55 | * Get the locale by segment identifier. |
||
56 | * |
||
57 | * @param $segment |
||
58 | * |
||
59 | * @return null|Locale |
||
60 | */ |
||
61 | 64 | public function findLocale($segment): ?Locale |
|
65 | |||
66 | 30 | public function locales(): array |
|
70 | |||
71 | 59 | public function defaultLocale(): Locale |
|
75 | |||
76 | 16 | public function activeLocale(): string |
|
80 | |||
81 | /** |
||
82 | * Get the url segment which corresponds with the passed locale. |
||
83 | * |
||
84 | * @param null $locale |
||
85 | * |
||
86 | * @return null|string |
||
87 | */ |
||
88 | 33 | public function segment($locale = null): ?string |
|
96 | |||
97 | 16 | public function activeSegment(): ?string |
|
101 | |||
102 | 26 | public function validateLocale(string $locale = null): bool |
|
110 | |||
111 | 23 | public function validateSegment(string $segment = null): bool |
|
119 | } |
||
120 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: