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

JsonapiFactory::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 0
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
use VGirol\JsonApiFaker\Members;
8
9
class JsonapiFactory extends BaseFactory
10
{
11
    use HasMeta;
12
    use HasVersion;
0 ignored issues
show
introduced by
The trait VGirol\JsonApiFaker\Factory\HasVersion requires some properties which are not provided by VGirol\JsonApiFaker\Factory\JsonapiFactory: $randomDigitNotNull, $randomDigit
Loading history...
13
14
    /**
15
     * Undocumented function
16
     *
17
     * @return array|null
18
     */
19 4
    public function toArray(): ?array
20
    {
21 4
        $json = [];
22
23 4
        if (isset($this->version)) {
24 2
            $json[Members::VERSION] = $this->version;
25
        }
26 4
        if (isset($this->meta)) {
27 2
            $json[Members::META] = $this->meta;
28
        }
29
30 4
        return $json;
31
    }
32
33
    /**
34
     * Undocumented function
35
     *
36
     * @return static
37
     */
38 1
    public function fake()
39
    {
40 1
        return $this->fakeMeta()
41 1
            ->fakeVersion();
42
    }
43
}
44