Backup   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 23
c 0
b 0
f 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 0 5 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
 * @property bool         $available Whether this Backup is available for restoration.
31
 *                                   Backups undergoing maintenance are not available for restoration.
32
 */
33
class Backup extends Entity
34
{
35
    // Available fields.
36
    public const FIELD_ID        = 'id';
37
    public const FIELD_STATUS    = 'status';
38
    public const FIELD_TYPE      = 'type';
39
    public const FIELD_CREATED   = 'created';
40
    public const FIELD_UPDATED   = 'updated';
41
    public const FIELD_FINISHED  = 'finished';
42
    public const FIELD_LABEL     = 'label';
43
    public const FIELD_CONFIGS   = 'configs';
44
    public const FIELD_DISKS     = 'disks';
45
    public const FIELD_AVAILABLE = 'available';
46
47
    // `FIELD_STATUS` values.
48
    public const STATUS_PAUSED              = 'paused';
49
    public const STATUS_PENDING             = 'pending';
50
    public const STATUS_RUNNING             = 'running';
51
    public const STATUS_NEEDSPOSTPROCESSING = 'needsPostProcessing';
52
    public const STATUS_SUCCESSFUL          = 'successful';
53
    public const STATUS_FAILED              = 'failed';
54
    public const STATUS_USERABORTED         = 'userAborted';
55
56
    // `FIELD_TYPE` values.
57
    public const TYPE_AUTO     = 'auto';
58
    public const TYPE_SNAPSHOT = 'snapshot';
59
60
    /**
61
     * @codeCoverageIgnore This method was autogenerated.
62
     */
63
    public function __get(string $name): mixed
64
    {
65
        return match ($name) {
66
            self::FIELD_DISKS => array_map(fn ($data) => new BackupDisk($this->client, $data), $this->data[$name]),
67
            default           => parent::__get($name),
68
        };
69
    }
70
}
71