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
|
|
|
|