BindVolume   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

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