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

KeySearchResults::createFromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
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\Key;
11
12
use FAPI\PhraseApp\Model\CreatableFromArray;
13
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
class KeySearchResults implements CreatableFromArray
18
{
19
    /**
20
     * @var KeySearchResult[]
21
     */
22
    private $searchResults = [];
23
24
    /**
25
     * @param array $data
26
     *
27
     * @return KeySearchResults
28
     */
29
    public static function createFromArray(array $data)
30
    {
31
        $self = new self();
32
33
        foreach ($data as $searchResult) {
34
            $self->addSearchResult(KeySearchResult::createFromArray($searchResult));
35
        }
36
37
        return $self;
38
    }
39
40
    /**
41
     * @return KeySearchResult[]
42
     */
43
    public function getSearchResults(): array
44
    {
45
        return $this->searchResults;
46
    }
47
48
    private function addSearchResult(KeySearchResult $searchResult)
49
    {
50
        $this->searchResults[] = $searchResult;
51
    }
52
}
53