Conditions | 5 |
Paths | 4 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public static function fromString($string, Translations $translations, array $options = []) |
||
27 | { |
||
28 | $options += static::$options; |
||
29 | $handle = fopen('php://memory', 'w'); |
||
30 | |||
31 | fputs($handle, $string); |
||
32 | rewind($handle); |
||
33 | |||
34 | while ($row = static::fgetcsv($handle, $options)) { |
||
35 | $context = array_shift($row); |
||
36 | $original = array_shift($row); |
||
37 | |||
38 | if ($context === '' && $original === '') { |
||
39 | static::extractHeaders(array_shift($row), $translations); |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $translation = $translations->insert($context, $original); |
||
44 | |||
45 | if (!empty($row)) { |
||
46 | $translation->setTranslation(array_shift($row)); |
||
47 | $translation->setPluralTranslations($row); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | fclose($handle); |
||
52 | } |
||
53 | } |
||
54 |