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 | 95 | public function __construct(array $locales) |
|
40 | |||
41 | 11 | public function setCustomRoot(Root $customRoot) |
|
47 | |||
48 | 11 | public function customRoot(): ?Root |
|
52 | |||
53 | /** |
||
54 | * Get the locale by segment identifier |
||
55 | * |
||
56 | * @param $segment |
||
57 | * @return null|Locale |
||
58 | */ |
||
59 | 43 | public function findLocale($segment): ?Locale |
|
63 | |||
64 | 45 | public function locales(): array |
|
68 | |||
69 | 15 | public function defaultLocale(): Locale |
|
73 | |||
74 | 19 | public function activeLocale(): string |
|
78 | |||
79 | /** |
||
80 | * Get the url segment which corresponds with the passed locale |
||
81 | * |
||
82 | * @param null $locale |
||
83 | * @return null|string |
||
84 | */ |
||
85 | 45 | public function segment($locale = null): ?string |
|
91 | |||
92 | 19 | public function activeSegment(): ?string |
|
96 | |||
97 | 34 | public function validateLocale(string $locale = null): bool |
|
103 | |||
104 | 31 | public function validateSegment(string $segment = null): bool |
|
110 | } |
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: