IdentifiableList::addIdToQuery()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.2559
1
<?php
2
3
namespace linkprofit\AmoCRM\traits;
4
5
/**
6
 * Trait IdentifiableList
7
 * @package linkprofit\AmoCRM\traits
8
 */
9
trait IdentifiableList
10
{
11
    /**
12
     * @var int
13
     */
14
    protected $listId;
15
16
    /**
17
     * @param $id
18
     *
19
     * @return $this
20
     */
21
    public function setId($id)
22
    {
23
        $this->listId = $id;
24
25
        return $this;
26
    }
27
28
    /**
29
     * @param array $query
30
     *
31
     * @return array
32
     */
33 2
    public function addIdToQuery($query = [])
34
    {
35 2
        if ($this->listId !== null) {
36
            $query['id'] = $this->listId;
37
        }
38
39 2
        return $query;
40
    }
41
}