| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| 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 | list($original, $translation) = $row + ['', '']; |
||
| 36 | |||
| 37 | if ($original === '') { |
||
| 38 | static::extractHeaders($translation, $translations); |
||
| 39 | continue; |
||
| 40 | } |
||
| 41 | |||
| 42 | $translations->insert(null, $original)->setTranslation($translation); |
||
| 43 | } |
||
| 44 | |||
| 45 | fclose($handle); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |