ServerEntity::getCpu()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
class ServerEntity
6
{
7
    /** @var Cpu */
8
    public $cpu;
9
    /** @var Ram */
10
    public $ram;
11
    /** @var Hdd */
12
    public $hdd;
13
14
    /**
15
     * VMachine constructor.
16
     *
17
     * @param int $cpu
18
     * @param int $ram
19
     * @param int $hdd
20
     */
21
    public function __construct(int $cpu, int $ram, int $hdd)
22
    {
23
        $this->cpu = new Cpu($cpu);
24
        $this->ram = new Ram($ram);
25
        $this->hdd = new Hdd($hdd);
26
    }
27
28
    /**
29
     * @return Cpu
30
     */
31
    public function getCpu(): Cpu
32
    {
33
        return $this->cpu;
34
    }
35
36
    /**
37
     * @return Ram
38
     */
39
    public function getRam(): Ram
40
    {
41
        return $this->ram;
42
    }
43
44
    /**
45
     * @return Hdd
46
     */
47
    public function getHdd(): Hdd
48
    {
49
        return $this->hdd;
50
    }
51
52
    /**
53
     * VMachine create.
54
     *
55
     * @param int $cpu
56
     * @param int $ram
57
     * @param int $hdd
58
     *
59
     * @return static
60
     */
61
    public static function create(int $cpu, int $ram, int $hdd)
62
    {
63
        return new static($cpu, $ram, $hdd);
64
    }
65
66
    /**
67
     * VMachine create.
68
     *
69
     * @param ServerEntity $vmachine
70
     *
71
     * @return static
72
     *
73
     * @internal param int $cpu
74
     * @internal param int $ram
75
     * @internal param int $hdd
76
     */
77
    public static function createAsVm($vmachine)
78
    {
79
        return new static(
80
            $vmachine->getCpu()->getAmount(),
81
            $vmachine->getRam()->getAmount(),
82
            $vmachine->getHdd()->getAmount()
83
        );
84
    }
85
}
86