SetNote::setNotes()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 12
cts 12
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 6
nop 1
crap 4
1
<?php
2
3
namespace AmoCRM\Models\Traits;
4
5
use AmoCRM\Models\Note;
6
7
trait SetNote
8
{
9
    /**
10
     * Сеттер для списка примечаний, которые появятся
11
     * после принятия неразобранного
12
     *
13
     * @param array|Note $value Примечание или массив примечаний
14
     * @return $this
15
     */
16 2
    public function setNotes($value)
17
    {
18 2
        $this->values['notes'] = [];
0 ignored issues
show
Bug introduced by
The property values does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
20 2
        if ($value instanceof Note) {
21 2
            $value = [$value];
22 2
        }
23
24 2
        foreach ($value as $note) {
25 2
            if ($note instanceof Note) {
26 2
                $note = $note->getValues();
27 2
            }
28
29 2
            $this->values['notes'][] = $note;
30 2
        }
31
32 2
        return $this;
33
    }
34
}
35