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

Models   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 31
rs 10

2 Methods

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