Volume::build()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 4
nc 4
nop 1
1
<?php
2
3
/*
4
 * This file is part of the DigitalOceanV2 library.
5
 *
6
 * (c) Antoine Corcy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DigitalOceanV2\Entity;
13
14
/**
15
 * @author Yassir Hannoun <[email protected]>
16
 */
17
final class Volume extends AbstractEntity
18
{
19
    /**
20
     * @var string
21
     */
22
    public $id;
23
24
    /**
25
     * @var Region
26
     */
27
    public $region;
28
29
    /**
30
     * @var int[]
31
     */
32
    public $dropletIds = [];
33
34
    /**
35
     * @var string
36
     */
37
    public $name;
38
39
    /**
40
     * @var string
41
     */
42
    public $description;
43
44
    /**
45
     * @var int
46
     */
47
    public $sizeGigabytes;
48
49
    /**
50
     * @var string
51
     */
52
    public $createdAt;
53
54
    /**
55
     * @param array $parameters
56
     */
57
    public function build(array $parameters)
58
    {
59
        parent::build($parameters);
60
61
        foreach ($parameters as $property => $value) {
62
            switch ($property) {
63
                case 'region':
64
                    if (is_object($value)) {
65
                        $this->region = new Region($value);
66
                    }
67
                    unset($parameters[$property]);
68
                    break;
69
            }
70
        }
71
    }
72
73
    /**
74
     * @param string $createdAt
75
     */
76
    public function setCreatedAt($createdAt)
77
    {
78
        $this->createdAt = static::convertDateTime($createdAt);
79
    }
80
}
81