Completed
Pull Request — master (#139)
by
unknown
10:24
created

SearchResults   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B add() 0 15 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
    public function add($searchResult)
18
    {
19
        if (is_array($searchResult)) {
20
            if (isset($searchResult['model']))
21
                $this->collection[] = MarketModel::getInstance($searchResult['model']);
22
23
            if (isset($searchResult['offer']))
24
                $this->collection[] = new Offer($searchResult['offer']);
25
26
        } elseif (is_object($searchResult) && ($searchResult instanceof MarketModel || $searchResult instanceof Offer)) {
27
            $this->collection[] = $searchResult;
28
        }
29
30
        return $this;
31
    }
32
33
    /**
34
     * Retrieve the collection property
35
     *
36
     * @return SearchResults|null
37
     */
38
    public function getAll()
39
    {
40
        return $this->collection;
41
    }
42
}
43