Conditions | 3 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public static function toString(Translations $translations) |
||
15 | { |
||
16 | $array = PhpArray::toArray($translations); |
||
17 | |||
18 | //for a simple json translation dictionary, one domain is supported |
||
19 | $values = current($array); |
||
20 | |||
21 | // remove meta / header data |
||
22 | if (array_key_exists('', $values)) { |
||
23 | unset($values['']); |
||
24 | } |
||
25 | |||
26 | //map to a simple yml dictionary (no plurals) |
||
27 | $yml = new Dumper(); |
||
28 | $output = $yml->dump( |
||
29 | array_map( |
||
30 | function ($val) { |
||
31 | return isset( $val[1] ) ? $val[1] : null; |
||
32 | }, |
||
33 | $values |
||
34 | ), |
||
35 | 1 |
||
36 | ); |
||
37 | |||
38 | return $output; |
||
39 | } |
||
40 | } |
||
41 |