| Total Complexity | 10 |
| Total Lines | 99 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 2 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 17 | class Localization implements LocalizationInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Language of the localization |
||
| 21 | */ |
||
| 22 | protected string $language; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Localized images |
||
| 26 | * |
||
| 27 | * @var ImageInterface[] |
||
| 28 | */ |
||
| 29 | protected array $images = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Localized texts (token=>value) |
||
| 33 | * |
||
| 34 | * @var string[] |
||
| 35 | */ |
||
| 36 | protected array $strings = []; |
||
| 37 | |||
| 38 | 1 | public function __construct($language) |
|
| 39 | { |
||
| 40 | 1 | $this->setLanguage($language); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | 1 | public function setLanguage($language): void |
|
| 47 | { |
||
| 48 | 1 | $this->language = $language; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritdoc} |
||
| 53 | */ |
||
| 54 | 1 | public function getLanguage() |
|
| 55 | { |
||
| 56 | 1 | return $this->language; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritdoc} |
||
| 61 | */ |
||
| 62 | public function addString($token, $value) |
||
| 63 | { |
||
| 64 | $this->strings[$token] = $value; |
||
| 65 | |||
| 66 | return $this; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * {@inheritdoc} |
||
| 71 | */ |
||
| 72 | 1 | public function addStrings(array $strings) |
|
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * {@inheritdoc} |
||
| 81 | */ |
||
| 82 | public function getStrings() |
||
| 83 | { |
||
| 84 | return $this->strings; |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * {@inheritdoc} |
||
| 89 | */ |
||
| 90 | 1 | public function getStringsFileOutput() |
|
| 91 | { |
||
| 92 | 1 | $output = ''; |
|
| 93 | 1 | foreach ($this->strings as $token => $value) { |
|
| 94 | 1 | $output .= '"' . addslashes($token) . '" = "' . addslashes($value) . '";' . PHP_EOL; |
|
| 95 | } |
||
| 96 | |||
| 97 | 1 | return $output; |
|
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * {@inheritdoc} |
||
| 102 | */ |
||
| 103 | public function addImage(Image $image) |
||
| 104 | { |
||
| 105 | $this->images[] = $image; |
||
| 106 | |||
| 107 | return $this; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * {@inheritdoc} |
||
| 112 | */ |
||
| 113 | 1 | public function getImages() |
|
| 116 | } |
||
| 117 | } |
||
| 118 |