Completed
Push — master ( da0ab4...8ffee5 )
by Vincent
03:47
created

HasMeta::getMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
/**
8
 * Add "meta" member to a factory.
9
 */
10
trait HasMeta
11
{
12
    /**
13
     * The "meta" member
14
     *
15
     * @var array
16
     */
17
    protected $meta;
18
19
    /**
20
     * Set the "meta" member.
21
     *
22
     * @param array $meta
23
     *
24
     * @return static
25
     */
26 84
    public function setMeta(array $meta)
27
    {
28 84
        $this->meta = $meta;
29
30 84
        return $this;
31
    }
32
33
    /**
34
     * Get the "meta" member.
35
     *
36
     * @return array|null
37
     */
38 33
    public function getMeta(): ?array
39
    {
40 33
        return $this->meta;
41
    }
42
43
    /**
44
     * Add a single value to the "meta" member
45
     *
46
     * @param string $name
47
     * @param mixed $value
48
     *
49
     * @return static
50
     */
51 15
    public function addToMeta(string $name, $value)
52
    {
53 15
        $this->addToObject('meta', $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

53
        $this->/** @scrutinizer ignore-call */ 
54
               addToObject('meta', $name, $value);
Loading history...
54
55 15
        return $this;
56
    }
57
58
    /**
59
     * Fill the "meta" member with fake values.
60
     *
61
     * @param integer $count The number of values to generate.
62
     *
63
     * @return static
64
     */
65 60
    public function fakeMeta(int $count = 5)
66
    {
67 60
        $this->setMeta(
68 60
            $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

68
            $this->/** @scrutinizer ignore-call */ 
69
                   fakeMembers($count)
Loading history...
69
        );
70
71 60
        return $this;
72
    }
73
}
74