Completed
Push — master ( caad37...82c5ce )
by Dmitriy
06:13
created

Children   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 76.47%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 8
c 2
b 1
f 1
lcom 1
cbo 2
dl 0
loc 47
ccs 13
cts 17
cp 0.7647
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A add() 0 10 4
A getAll() 0 4 1
1
<?php
2
3
namespace Yandex\Market\Content\Models;
4
5
use Yandex\Common\ObjectModel;
6
7
class Children extends ObjectModel
8
{
9
    /**
10
     * Constructor
11
     *
12
     * @param array $data
13
     */
14 1
    public function __construct($data = array())
15
    {
16
        // fix children inheritance
17 1
        if (isset($data['models'])
18 1
            && count($data['models']) > 0
19 1
        ) {
20 1
            $data = $data['models'];
21 1
        }
22
23 1
        parent::__construct($data);
24 1
    }
25
26
    /**
27
     * Add childModel to collection
28
     *
29
     * @param ModelChild|array $childModel
30
     *
31
     * @return Children
32
     */
33 1
    public function add($childModel)
34
    {
35 1
        if (is_array($childModel)) {
36 1
            $this->collection[] = new ModelChild($childModel);
37 1
        } elseif (is_object($childModel) && $childModel instanceof ModelChild) {
38
            $this->collection[] = $childModel;
39
        }
40
41 1
        return $this;
42
    }
43
44
    /**
45
     * Retrieve the collection property
46
     *
47
     * @return Children
48
     */
49
    public function getAll()
50
    {
51
        return $this->collection;
52
    }
53
}
54