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

HasAttributes::addAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
trait HasAttributes
8
{
9
    /**
10
     * Undocumented variable
11
     *
12
     * @var array
13
     */
14
    public $attributes;
15
16
    /**
17
     * Undocumented function
18
     *
19
     * @param array $attributes
20
     *
21
     * @return static
22
     */
23 9
    public function setAttributes(array $attributes)
24
    {
25 9
        $this->attributes = $attributes;
26
27 9
        return $this;
28
    }
29
30
    /**
31
     * Undocumented function
32
     *
33
     * @param array $attributes
34
     *
35
     * @return static
36
     */
37 1
    public function addAttributes(array $attributes)
38
    {
39 1
        foreach ($attributes as $name => $value) {
40 1
            $this->addAttribute($name, $value);
41
        }
42
43 1
        return $this;
44
    }
45
46
    /**
47
     * Undocumented function
48
     *
49
     * @param string $name
50
     * @param mixed $value
51
     *
52
     * @return static
53
     */
54 2
    public function addAttribute(string $name, $value)
55
    {
56 2
        $this->addToObject('attributes', $name, $value);
0 ignored issues
show
Bug introduced by
It seems like addToObject() 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

56
        $this->/** @scrutinizer ignore-call */ 
57
               addToObject('attributes', $name, $value);
Loading history...
57
58 2
        return $this;
59
    }
60
61
    /**
62
     * Undocumented function
63
     *
64
     * @param integer $count
65
     *
66
     * @return static
67
     */
68 5
    public function fakeAttributes(int $count = 5)
69
    {
70 5
        $this->setAttributes(
71 5
            $this->fakeMembers($count)
0 ignored issues
show
Bug introduced by
It seems like fakeMembers() 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

71
            $this->/** @scrutinizer ignore-call */ 
72
                   fakeMembers($count)
Loading history...
72
        );
73
74 5
        return $this;
75
    }
76
}
77