TranslationGroup   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A all() 0 4 1
A allRaw() 0 4 1
A reArrangeTranslations() 0 12 3
1
<?php namespace Modules\Translation\ValueObjects;
2
3
use Illuminate\Support\Collection;
4
5
class TranslationGroup
6
{
7
    /**
8
     * @var array
9
     */
10
    private $translations;
11
12
    public function __construct(array $translations)
13
    {
14
        $this->translations = $translations;
15
    }
16
17
    /**
18
     * @param array $translationsRaw
19
     * @return Collection
20
     */
21
    private function reArrangeTranslations(array $translationsRaw)
22
    {
23
        $translations = [];
24
25
        foreach ($translationsRaw as $locale => $translationGroup) {
26
            foreach ($translationGroup as $key => $translation) {
27
                $translations[$key][$locale] = $translation;
28
            }
29
        }
30
31
        return new Collection($translations);
32
    }
33
34
    /**
35
     * Return the translations
36
     * @return Collection
37
     */
38
    public function all()
39
    {
40
        return $this->reArrangeTranslations($this->translations);
41
    }
42
43
    /**
44
     * Return the raw translations
45
     * @return array
46
     */
47
    public function allRaw()
48
    {
49
        return $this->translations;
50
    }
51
}
52