Completed
Push — master ( 883f28...097345 )
by Vincent
03:45 queued 11s
created

HasErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 43
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setErrors() 0 5 1
A addError() 0 5 1
A fakeErrors() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
trait HasErrors
8
{
9
    /**
10
     * Undocumented variable
11
     *
12
     * @var array
13
     */
14
    public $errors;
15
16
    /**
17
     * Undocumented function
18
     *
19
     * @param array $errors
20
     * @return static
21
     */
22 3
    public function setErrors(array $errors)
23
    {
24 3
        $this->errors = $errors;
25
26 3
        return $this;
27
    }
28
29
    /**
30
     * Undocumented function
31
     *
32
     * @param array $error
33
     * @return static
34
     */
35 1
    public function addError($error)
36
    {
37 1
        $this->addToArray('errors', $error);
0 ignored issues
show
Bug introduced by
It seems like addToArray() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $this->/** @scrutinizer ignore-call */ 
38
               addToArray('errors', $error);
Loading history...
38
39 1
        return $this;
40
    }
41
42
    /**
43
     * Undocumented function
44
     *
45
     * @return static
46
     */
47
    public function fakeErrors()
48
    {
49
        return $this;
50
    }
51
}
52