1 | <?php |
||
12 | class InternationalisationMiddleware implements MiddlewareInterface |
||
13 | { |
||
14 | /** @var UrlHelper */ |
||
15 | private $helper; |
||
16 | |||
17 | /** @var string|null */ |
||
18 | private $defaultLocale; |
||
19 | |||
20 | /** @var string $fallbackLocale */ |
||
21 | private $fallbackLocale = 'en_US'; |
||
22 | |||
23 | const REGEX_LOCALE = '#^/(?P<locale>[a-z]{2,3}|[a-z]{2}[-_][a-zA-Z]{2})(?:/|$)#'; |
||
24 | |||
25 | /** |
||
26 | * InternationalisationMiddleware constructor. |
||
27 | * @param $helper |
||
28 | * @param string|null $defaultLocale |
||
29 | */ |
||
30 | public function __construct( $helper, string $defaultLocale = null) |
||
37 | |||
38 | /** |
||
39 | * @param ServerRequestInterface $request |
||
40 | * @param RequestHandlerInterface $handler |
||
41 | * @return ResponseInterface |
||
42 | */ |
||
43 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface |
||
64 | } |
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: