Conditions | 4 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
22 | public static function toString(Translations $translations, array $options = []) |
||
23 | { |
||
24 | $options += static::$options; |
||
25 | $handle = fopen('php://memory', 'w'); |
||
26 | |||
27 | if ($options['includeHeaders']) { |
||
28 | fputcsv($handle, ['', '', self::generateHeaders($translations)]); |
||
29 | } |
||
30 | |||
31 | foreach ($translations as $translation) { |
||
32 | $line = [$translation->getContext(), $translation->getOriginal(), $translation->getTranslation()]; |
||
33 | |||
34 | if ($translation->hasPluralTranslations()) { |
||
35 | $line = array_merge($line, $translation->getPluralTranslations()); |
||
36 | } |
||
37 | |||
38 | fputcsv($handle, $line); |
||
39 | } |
||
40 | |||
41 | rewind($handle); |
||
42 | $csv = stream_get_contents($handle); |
||
43 | fclose($handle); |
||
44 | |||
45 | return $csv; |
||
46 | } |
||
47 | } |
||
48 |