Completed
Push — v4.0-dev ( 627b53...5ca120 )
by Oscar
02:44
created

CsvDictionary::toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 15
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace Gettext\Generators;
4
5
use Gettext\Translations;
6
7
class CsvDictionary extends Generator implements GeneratorInterface
8
{
9
    /**
10
     * {@parentDoc}.
11
     */
12
    public static function toString(Translations $translations)
13
    {
14
        $handle = fopen('php://memory', 'w');
15
16
        foreach ($translations as $translation) {
17
            fputcsv($handle, [$translation->getOriginal(), $translation->getTranslation()]);
18
        }
19
20
        rewind($handle);
21
        $csv = stream_get_contents($handle);
22
23
        fclose($handle);
24
25
        return $csv;
26
    }
27
}
28