Conditions | 5 |
Paths | 8 |
Total Lines | 29 |
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 | static::fputcsv($handle, ['', '', static::generateHeaders($translations)], $options); |
||
34 | } |
||
35 | |||
36 | foreach ($translations as $translation) { |
||
37 | if ($translation->isDisabled()) { |
||
38 | continue; |
||
39 | } |
||
40 | |||
41 | $line = [$translation->getContext(), $translation->getOriginal(), $translation->getTranslation()]; |
||
42 | |||
43 | if ($translation->hasPluralTranslations(true)) { |
||
44 | $line = array_merge($line, $translation->getPluralTranslations()); |
||
45 | } |
||
46 | |||
47 | static::fputcsv($handle, $line, $options); |
||
48 | } |
||
49 | |||
50 | rewind($handle); |
||
51 | $csv = stream_get_contents($handle); |
||
52 | fclose($handle); |
||
53 | |||
54 | return $csv; |
||
55 | } |
||
56 | } |
||
57 |