1 | <?php |
||
19 | class Snapshot extends AbstractResource implements Listable, Creatable, Updateable, Deletable, Retrievable, HasMetadata |
||
20 | { |
||
21 | use HasWaiterTrait; |
||
22 | |||
23 | /** @var string */ |
||
24 | public $id; |
||
25 | |||
26 | /** @var string */ |
||
27 | public $name; |
||
28 | |||
29 | /** @var string */ |
||
30 | public $status; |
||
31 | |||
32 | /** @var string */ |
||
33 | public $description; |
||
34 | |||
35 | /** @var \DateTimeImmutable */ |
||
36 | public $createdAt; |
||
37 | |||
38 | /** @var array */ |
||
39 | public $metadata = []; |
||
40 | |||
41 | /** @var string */ |
||
42 | public $volumeId; |
||
43 | |||
44 | /** @var int */ |
||
45 | public $size; |
||
46 | |||
47 | protected $resourceKey = 'snapshot'; |
||
48 | protected $resourcesKey = 'snapshots'; |
||
49 | |||
50 | protected $aliases = [ |
||
51 | 'created_at' => 'createdAt', |
||
52 | 'volume_id' => 'volumeId', |
||
53 | ]; |
||
54 | |||
55 | 2 | public function populateFromResponse(ResponseInterface $response) |
|
61 | |||
62 | 1 | public function retrieve() |
|
63 | { |
||
64 | 1 | $response = $this->executeWithState($this->api->getSnapshot()); |
|
65 | 1 | return $this->populateFromResponse($response); |
|
|
|||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param array $userOptions {@see \OpenStack\BlockStorage\v2\Api::postSnapshots} |
||
70 | * |
||
71 | * @return self |
||
72 | */ |
||
73 | 1 | public function create(array $userOptions) |
|
78 | |||
79 | 1 | public function update() |
|
83 | |||
84 | 1 | public function delete() |
|
88 | |||
89 | 2 | public function getMetadata() |
|
95 | |||
96 | 1 | public function mergeMetadata(array $metadata) |
|
97 | { |
||
98 | 1 | $this->getMetadata(); |
|
99 | 1 | $this->metadata = array_merge($this->metadata, $metadata); |
|
100 | 1 | $this->executeWithState($this->api->putSnapshotMetadata()); |
|
101 | 1 | } |
|
102 | |||
103 | 1 | public function resetMetadata(array $metadata) |
|
104 | { |
||
105 | 1 | $this->metadata = $metadata; |
|
106 | 1 | $this->executeWithState($this->api->putSnapshotMetadata()); |
|
107 | 1 | } |
|
108 | |||
109 | 4 | public function parseMetadata(ResponseInterface $response) |
|
114 | } |
||
115 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.