Completed
Push — master ( c5c0e9...29e67b )
by David
14s
created

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