Passed
Pull Request — master (#59)
by
unknown
03:19
created

Relationship::addRelated()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace tuyakhov\jsonapi;
4
5
use yii\base\Model;
6
7
class Relationship extends Model
8
{
9
    public $multiple = false;
10
    public $relations = [];
11
12
    public function addRelated($related)
13
    {
14
        if (!$related) {
15
            return $this;
16
        }
17
18
        if (!is_array($related)) {
19
            return $this->addRelated([$related]);
20
        }
21
22
        $this->relations = array_merge($this->relations, $related);
23
        return $this;
24
    }
25
}