Passed
Push — master ( 0676a7...01ab94 )
by Artem
11:54
created

Backup::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\LinodeInstances;
13
14
use Linode\Entity;
15
16
/**
17
 * An object representing a Backup or snapshot for a Linode with Backup service
18
 * enabled.
19
 *
20
 * @property int          $id       The unique ID of this Backup.
21
 * @property string       $status   The current state of a specific Backup.
22
 * @property string       $type     This indicates whether the Backup is an automatic Backup or manual snapshot taken
23
 *                                  by the User at a specific point in time.
24
 * @property string       $created  The date the Backup was taken.
25
 * @property string       $updated  The date the Backup was most recently updated.
26
 * @property string       $finished The date the Backup completed.
27
 * @property null|string  $label    A label for Backups that are of type `snapshot`.
28
 * @property string[]     $configs  A list of the labels of the Configuration profiles that are part of the Backup.
29
 * @property BackupDisk[] $disks    A list of the disks that are part of the Backup.
30
 */
31
class Backup extends Entity
32
{
33
    // Available fields.
34
    public const FIELD_ID       = 'id';
35
    public const FIELD_STATUS   = 'status';
36
    public const FIELD_TYPE     = 'type';
37
    public const FIELD_CREATED  = 'created';
38
    public const FIELD_UPDATED  = 'updated';
39
    public const FIELD_FINISHED = 'finished';
40
    public const FIELD_LABEL    = 'label';
41
    public const FIELD_CONFIGS  = 'configs';
42
    public const FIELD_DISKS    = 'disks';
43
44
    // `FIELD_STATUS` values.
45
    public const STATUS_PAUSED              = 'paused';
46
    public const STATUS_PENDING             = 'pending';
47
    public const STATUS_RUNNING             = 'running';
48
    public const STATUS_NEEDSPOSTPROCESSING = 'needsPostProcessing';
49
    public const STATUS_SUCCESSFUL          = 'successful';
50
    public const STATUS_FAILED              = 'failed';
51
    public const STATUS_USERABORTED         = 'userAborted';
52
53
    // `FIELD_TYPE` values.
54
    public const TYPE_AUTO     = 'auto';
55
    public const TYPE_SNAPSHOT = 'snapshot';
56
57
    /**
58
     * @codeCoverageIgnore This method was autogenerated.
59
     */
60
    public function __get(string $name): mixed
61
    {
62
        return match ($name) {
63
            self::FIELD_DISKS => array_map(fn ($data) => new BackupDisk($this->client, $data), $this->data[$name]),
64
            default           => parent::__get($name),
65
        };
66
    }
67
}
68