Completed
Push — master ( 9f1d6e...bc3715 )
by
unknown
03:37
created

SearchResults   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 37
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B add() 0 17 7
A getAll() 0 4 1
1
<?php
2
3
namespace Yandex\Market\Content\Models;
4
5
use Yandex\Common\ObjectModel;
6
use Yandex\Market\Content\Models\Base\MarketModel;
7
8
class SearchResults extends ObjectModel
9
{
10
    /**
11
     * Add category to collection
12
     *
13
     * @param ModelParent|ModelChild|ModelVisual|ModelSingle|ModelInfo|Offer|array $searchResult
14
     *
15
     * @return SearchResults
16
     */
17 2
    public function add($searchResult)
18
    {
19 2
        if (is_array($searchResult)) {
20 2
            if (isset($searchResult['model'])) {
21 2
                $this->collection[] = MarketModel::getInstance($searchResult['model']);
22
            }
23
24 2
            if (isset($searchResult['offer'])) {
25 2
                $this->collection[] = new Offer($searchResult['offer']);
26
            }
27
        } elseif (is_object($searchResult) && ($searchResult instanceof MarketModel || $searchResult instanceof Offer)
28
        ) {
29
            $this->collection[] = $searchResult;
30
        }
31
32 2
        return $this;
33
    }
34
35
    /**
36
     * Retrieve the collection property
37
     *
38
     * @return SearchResults|null
39
     */
40
    public function getAll()
41
    {
42
        return $this->collection;
43
    }
44
}
45