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

Relationship   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A addRelated() 0 12 3
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
}