HasMeta   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 62
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setMeta() 0 5 1
A getMeta() 0 3 1
A fakeMeta() 0 7 1
A addToMeta() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
use VGirol\JsonApiConstant\Members;
8
9
/**
10
 * Add "meta" member to a factory.
11
 */
12
trait HasMeta
13
{
14
    /**
15
     * The "meta" member
16
     *
17
     * @var array
18
     */
19
    protected $meta;
20
21
    /**
22
     * Set the "meta" member.
23
     *
24
     * @param array $meta
25
     *
26
     * @return static
27
     */
28 84
    public function setMeta(array $meta)
29
    {
30 84
        $this->meta = $meta;
31
32 84
        return $this;
33
    }
34
35
    /**
36
     * Get the "meta" member.
37
     *
38
     * @return array|null
39
     */
40 33
    public function getMeta(): ?array
41
    {
42 33
        return $this->meta;
43
    }
44
45
    /**
46
     * Add a single value to the "meta" member
47
     *
48
     * @param string $name
49
     * @param mixed $value
50
     *
51
     * @return static
52
     */
53 15
    public function addToMeta(string $name, $value)
54
    {
55 15
        $this->addToObject(Members::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

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

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