Completed
Push — master ( a7eaa4...6da405 )
by David
14s queued 11s
created

NamedVolume::getRequestStorage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Service\Volume;
4
5
use TheAentMachine\Service\Enum\VolumeTypeEnum;
6
7
class NamedVolume extends Volume
8
{
9
    /** @var string */
10
    private $target;
11
    /** @var bool */
12
    private $readOnly;
13
    /** @var null|string */
14
    private $requestStorage;
15
16
    public function __construct(string $source, string $target, bool $readOnly = false, ?string $comment = null, ?string $requestStorage = null)
17
    {
18
        parent::__construct($source, $comment);
19
        $this->target = $target;
20
        $this->readOnly = $readOnly;
21
        $this->requestStorage = $requestStorage;
22
    }
23
24
    public function getType(): string
25
    {
26
        return VolumeTypeEnum::NAMED_VOLUME;
27
    }
28
29
    public function getTarget(): string
30
    {
31
        return $this->target;
32
    }
33
34
    public function isReadOnly(): bool
35
    {
36
        return $this->readOnly;
37
    }
38
39
    public function getRequestStorage(): ?string
40
    {
41
        return $this->requestStorage;
42
    }
43
44
    /**
45
     * Specify data which should be serialized to JSON
46
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
47
     * @return array data which can be serialized by <b>json_encode</b>,
48
     * which is a value of any type other than a resource.
49
     * @since 5.4.0
50
     */
51
    public function jsonSerialize(): array
52
    {
53
        return array_filter([
54
            'type' => $this->getType(),
55
            'source' => $this->source,
56
            'target' => $this->target,
57
            'readOnly' => $this->readOnly,
58
            'comment' => $this->comment,
59
            'requestStorage' => $this->requestStorage,
60
        ], function ($v) {
61
            return null !== $v;
62
        });
63
    }
64
}
65