Completed
Push — master ( e5b10a...ef7318 )
by dotzero
02:34 queued 01:01
created

SetNote   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 28
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setNotes() 0 18 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