Code Duplication    Length = 36-36 lines in 2 locations

src/Model/Key/KeySearchResults.php 1 location

@@ 17-52 (lines=36) @@
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
final class KeySearchResults implements CreatableFromArray, \IteratorAggregate
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[]|\Iterator
42
     */
43
    public function getIterator(): \Iterator
44
    {
45
        return new \ArrayIterator($this->searchResults);
46
    }
47
48
    private function addSearchResult(KeySearchResult $searchResult)
49
    {
50
        $this->searchResults[] = $searchResult;
51
    }
52
}
53

src/Model/Translation/Index.php 1 location

@@ 17-52 (lines=36) @@
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17
final class Index implements CreatableFromArray, \IteratorAggregate
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[]|\Iterator
42
     */
43
    public function getIterator(): \Iterator
44
    {
45
        return new \ArrayIterator($this->translations);
46
    }
47
48
    private function addTranslation(Translation $translation)
49
    {
50
        $this->translations[] = $translation;
51
    }
52
}
53