Completed
Push — master ( 08753a...42665f )
by Sascha-Oliver
05:38
created

Index   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 36
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 10 2
A getTranslations() 0 4 1
A addTranslation() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp\Model\Translation;
11
12
use FAPI\PhraseApp\Model\CreatableFromArray;
13
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
class Index implements CreatableFromArray
18
{
19
    /**
20
     * @var Translation[]
21
     */
22
    private $translations = [];
23
24
    /**
25
     * @param array $data
26
     *
27
     * @return Index
28
     */
29
    public static function createFromArray(array $data)
30
    {
31
        $self = new self();
32
33
        foreach ($data as $translation) {
34
            $self->addTranslation(Translation::createFromArray($translation));
35
        }
36
37
        return $self;
38
    }
39
40
    /**
41
     * @return Translation[]
42
     */
43
    public function getTranslations(): array
44
    {
45
        return $this->translations;
46
    }
47
48
    private function addTranslation(Translation $translation)
49
    {
50
        $this->translations[] = $translation;
51
    }
52
}
53