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

BindVolume::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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
    protected $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 static function getType(): string
31
    {
32
        return VolumeTypeEnum::BIND_VOLUME;
33
    }
34
35
36
    /**
37
     * Specify data which should be serialized to JSON
38
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
39
     * @return array data which can be serialized by <b>json_encode</b>,
40
     * which is a value of any type other than a resource.
41
     * @since 5.4.0
42
     */
43
    public function jsonSerialize(): array
44
    {
45
        return array(
46
            'type' => self::getType(),
47
            'source' => $this->source,
48
            'target' => $this->target,
49
            'readOnly' => $this->readOnly,
50
        );
51
    }
52
}
53