HasJsonapi   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
dl 0
loc 46
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setJsonapi() 0 5 1
A fakeJsonapi() 0 6 1
A getJsonapi() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
use VGirol\JsonApiFaker\Contract\JsonapiContract;
8
9
/**
10
 * Add "jsonapi" member to a factory.
11
 */
12
trait HasJsonapi
13
{
14
    /**
15
     * The jsonapi object
16
     *
17
     * @var JsonapiContract
18
     */
19
    protected $jsonapi;
20
21
    /**
22
     * Sets the jsonapi object.
23
     *
24
     * @param JsonapiContract $jsonapi
25
     *
26
     * @return static
27
     */
28 21
    public function setJsonapi($jsonapi)
29
    {
30 21
        $this->jsonapi = $jsonapi;
31
32 21
        return $this;
33
    }
34
35
    /**
36
     * Gets the jsonapi object.
37
     *
38
     * @return JsonapiContract
39
     */
40 15
    public function getJsonapi()
41
    {
42 15
        return $this->jsonapi;
43
    }
44
45
    /**
46
     * Fill the "jsonapi" object with fake members and values.
47
     *
48
     * @param integer $countMeta The number of meta members to generate.
49
     *
50
     * @return static
51
     */
52 9
    public function fakeJsonapi(int $countMeta = 5)
53
    {
54 9
        return $this->setJsonapi(
55 9
            $this->generator
56 9
                ->jsonapiObject()
57 9
                ->fake($countMeta)
58
        );
59
    }
60
}
61