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