Completed
Push — master ( a787fa...dc9af5 )
by Vincent
05:35
created

JsonapiFactory::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 3
nc 4
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiAssert\Factory;
6
7
use VGirol\JsonApiAssert\Members;
8
9
class JsonapiFactory extends BaseFactory
10
{
11
    use HasMeta;
12
13
    /**
14
     * Undocumented variable
15
     *
16
     * @var string
17
     */
18
    public $version;
19
20
    /**
21
     * Undocumented function
22
     *
23
     * @param string $version
24
     * @return static
25
     */
26
    public function setVersion(string $version)
27
    {
28
        $this->version = $version;
29
30
        return $this;
31
    }
32
33
    public function toArray(): ?array
34
    {
35
        $json = [];
36
37
        if (isset($this->version)) {
38
            $json[Members::VERSION] = $this->version;
39
        }
40
        if (isset($this->meta)) {
41
            $json[Members::META] = $this->meta;
42
        }
43
44
        return $json;
45
    }
46
}
47