|
1 | 1 | <?php |
| 2 | +// phpcs:ignoreFile |
2 | 3 |
|
3 | 4 | declare(strict_types=1); |
4 | 5 |
|
5 | 6 | namespace Yokai\EnumBundle\Tests\Unit; |
6 | 7 |
|
| 8 | +use Symfony\Component\HttpKernel\Kernel; |
7 | 9 | use Symfony\Contracts\Translation\TranslatorInterface; |
8 | 10 |
|
9 | | -/** |
10 | | - * @author Yann Eugoné <[email protected]> |
11 | | - */ |
12 | | -class Translator implements TranslatorInterface |
13 | | -{ |
| 11 | +if (Kernel::MAJOR_VERSION >= 6) { |
14 | 12 | /** |
15 | | - * @var array |
| 13 | + * @author Yann Eugoné <[email protected]> |
16 | 14 | */ |
17 | | - private $map; |
| 15 | + class Translator implements TranslatorInterface |
| 16 | + { |
| 17 | + /** |
| 18 | + * @var array |
| 19 | + */ |
| 20 | + private $map; |
| 21 | + |
| 22 | + /** |
| 23 | + * @var string |
| 24 | + */ |
| 25 | + private $domain; |
18 | 26 |
|
| 27 | + public function __construct(array $map, string $domain = 'messages') |
| 28 | + { |
| 29 | + $this->map = $map; |
| 30 | + $this->domain = $domain; |
| 31 | + } |
| 32 | + |
| 33 | + public function getLocale(): string |
| 34 | + { |
| 35 | + return 'fr'; |
| 36 | + } |
| 37 | + |
| 38 | + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string |
| 39 | + { |
| 40 | + if ($domain !== $this->domain) { |
| 41 | + return $id; |
| 42 | + } |
| 43 | + |
| 44 | + return $this->map[$id] ?? $id; |
| 45 | + } |
| 46 | + } |
| 47 | +} else { |
19 | 48 | /** |
20 | | - * @var string |
| 49 | + * @author Yann Eugoné <[email protected]> |
21 | 50 | */ |
22 | | - private $domain; |
23 | | - |
24 | | - public function __construct(array $map, string $domain = 'messages') |
| 51 | + class Translator implements TranslatorInterface |
25 | 52 | { |
26 | | - $this->map = $map; |
27 | | - $this->domain = $domain; |
28 | | - } |
| 53 | + /** |
| 54 | + * @var array |
| 55 | + */ |
| 56 | + private $map; |
29 | 57 |
|
30 | | - public function getLocale(): string |
31 | | - { |
32 | | - return 'fr'; |
33 | | - } |
| 58 | + /** |
| 59 | + * @var string |
| 60 | + */ |
| 61 | + private $domain; |
34 | 62 |
|
35 | | - public function trans($id, array $parameters = [], $domain = null, $locale = null) |
36 | | - { |
37 | | - if ($domain !== $this->domain) { |
38 | | - return $id; |
| 63 | + public function __construct(array $map, string $domain = 'messages') |
| 64 | + { |
| 65 | + $this->map = $map; |
| 66 | + $this->domain = $domain; |
39 | 67 | } |
40 | 68 |
|
41 | | - return $this->map[$id] ?? $id; |
| 69 | + public function getLocale(): string |
| 70 | + { |
| 71 | + return 'fr'; |
| 72 | + } |
| 73 | + |
| 74 | + public function trans($id, array $parameters = [], $domain = null, $locale = null) |
| 75 | + { |
| 76 | + if ($domain !== $this->domain) { |
| 77 | + return $id; |
| 78 | + } |
| 79 | + |
| 80 | + return $this->map[$id] ?? $id; |
| 81 | + } |
42 | 82 | } |
43 | 83 | } |
0 commit comments