Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | public static function fromString($string, Translations $translations, array $options = []) |
||
17 | { |
||
18 | $entries = (array) YamlParser::parse($string); |
||
19 | |||
20 | foreach ($entries as $context => $contextTranslations) { |
||
21 | foreach ($contextTranslations as $original => $value) { |
||
22 | $translation = $translations->insert($context, $original); |
||
23 | |||
24 | if (is_array($value)) { |
||
25 | $translation->setTranslation(array_shift($value)); |
||
26 | $translation->setPluralTranslations($value); |
||
27 | } else { |
||
28 | $translation->setTranslation($value); |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 | |||
33 | return $translations; |
||
34 | } |
||
35 | } |
||
36 |