-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Symfony 6.0 & Updated tests according to changes (#51)
- Loading branch information
1 parent
01744ff
commit e98614b
Showing
5 changed files
with
104 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,83 @@ | ||
<?php | ||
// phpcs:ignoreFile | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yokai\EnumBundle\Tests\Unit; | ||
|
||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @author Yann Eugoné <eugone.yann@gmail.com> | ||
*/ | ||
class Translator implements TranslatorInterface | ||
{ | ||
if (Kernel::MAJOR_VERSION >= 6) { | ||
/** | ||
* @var array | ||
* @author Yann Eugoné <eugone.yann@gmail.com> | ||
*/ | ||
private $map; | ||
class Translator implements TranslatorInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $map; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $domain; | ||
|
||
public function __construct(array $map, string $domain = 'messages') | ||
{ | ||
$this->map = $map; | ||
$this->domain = $domain; | ||
} | ||
|
||
public function getLocale(): string | ||
{ | ||
return 'fr'; | ||
} | ||
|
||
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string | ||
{ | ||
if ($domain !== $this->domain) { | ||
return $id; | ||
} | ||
|
||
return $this->map[$id] ?? $id; | ||
} | ||
} | ||
} else { | ||
/** | ||
* @var string | ||
* @author Yann Eugoné <eugone.yann@gmail.com> | ||
*/ | ||
private $domain; | ||
|
||
public function __construct(array $map, string $domain = 'messages') | ||
class Translator implements TranslatorInterface | ||
{ | ||
$this->map = $map; | ||
$this->domain = $domain; | ||
} | ||
/** | ||
* @var array | ||
*/ | ||
private $map; | ||
|
||
public function getLocale(): string | ||
{ | ||
return 'fr'; | ||
} | ||
/** | ||
* @var string | ||
*/ | ||
private $domain; | ||
|
||
public function trans($id, array $parameters = [], $domain = null, $locale = null) | ||
{ | ||
if ($domain !== $this->domain) { | ||
return $id; | ||
public function __construct(array $map, string $domain = 'messages') | ||
{ | ||
$this->map = $map; | ||
$this->domain = $domain; | ||
} | ||
|
||
return $this->map[$id] ?? $id; | ||
public function getLocale(): string | ||
{ | ||
return 'fr'; | ||
} | ||
|
||
public function trans($id, array $parameters = [], $domain = null, $locale = null) | ||
{ | ||
if ($domain !== $this->domain) { | ||
return $id; | ||
} | ||
|
||
return $this->map[$id] ?? $id; | ||
} | ||
} | ||
} |