Conditions | 5 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
18 | public static function fromString($string, Translations $translations, array $options = []) |
||
19 | { |
||
20 | $handle = fopen('php://memory', 'w'); |
||
21 | |||
22 | fputs($handle, $string); |
||
23 | rewind($handle); |
||
24 | |||
25 | while ($row = fgetcsv($handle)) { |
||
26 | $context = array_shift($row); |
||
27 | $original = array_shift($row); |
||
28 | |||
29 | if ($context === '' && $original === '') { |
||
30 | self::extractHeaders(array_shift($row), $translations); |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | $translation = $translations->insert($context, $original); |
||
35 | |||
36 | if (!empty($row)) { |
||
37 | $translation->setTranslation(array_shift($row)); |
||
38 | $translation->setPluralTranslations($row); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | fclose($handle); |
||
43 | |||
44 | return $translations; |
||
45 | } |
||
46 | } |
||
47 |