Completed
Push — master ( 8babd6...f4be45 )
by David
15s queued 11s
created

NamedVolume   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 58
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isReadOnly() 0 3 1
A __construct() 0 5 1
A getType() 0 3 1
A jsonSerialize() 0 7 1
A getTarget() 0 3 1
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
14
    /**
15
     * BindVolume constructor.
16
     * @param string $source
17
     * @param bool $readOnly
18
     * @param string $target
19
     */
20
    public function __construct(string $source, string $target, bool $readOnly = false)
21
    {
22
        parent::__construct($source);
23
        $this->target = $target;
24
        $this->readOnly = $readOnly;
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getType(): string
31
    {
32
        return VolumeTypeEnum::NAMED_VOLUME;
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getTarget(): string
39
    {
40
        return $this->target;
41
    }
42
43
    /**
44
     * @return bool
45
     */
46
    public function isReadOnly(): bool
47
    {
48
        return $this->readOnly;
49
    }
50
51
    /**
52
     * Specify data which should be serialized to JSON
53
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
54
     * @return array data which can be serialized by <b>json_encode</b>,
55
     * which is a value of any type other than a resource.
56
     * @since 5.4.0
57
     */
58
    public function jsonSerialize(): array
59
    {
60
        return array(
61
            'type' => $this->getType(),
62
            'source' => $this->source,
63
            'target' => $this->target,
64
            'readOnly' => $this->readOnly,
65
        );
66
    }
67
}
68