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

DictionaryTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 10 2
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