Completed
Push — master ( b57986...ac2fba )
by Oscar
02:06
created

DictionaryTrait::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Gettext\Utils;
4
5
use Gettext\Translations;
6
7
/**
8
 * Trait used by all generators that exports the translations to plain dictionary (original => singular-translation).
9
 */
10
trait DictionaryTrait
11
{
12
    /**
13
     * Returns a plain dictionary with the format [original => translation].
14
     * 
15
     * @param Translations $translations
16
     *
17
     * @return array
18
     */
19
    private static function toArray(Translations $translations)
20
    {
21
        $messages = [];
22
23
        foreach ($translations as $translation) {
24
            $messages[$translation->getOriginal()] = $translation->getTranslation();
25
        }
26
27
        return $messages;
28
    }
29
}
30