Passed
Push — master ( 2b9668...6875d9 )
by Sebastian
02:20
created

ConvertHelper_StorageSizeEnum_Size::getBase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * File containing the {@see ConvertHelper_StorageSizeEnum_Size} class.
4
 *
5
 * @package AppUtils
6
 * @subpackage ConvertHelper
7
 * @see ConvertHelper_StorageSizeEnum_Size
8
 */
9
10
declare(strict_types=1);
11
12
namespace AppUtils;
13
14
/**
15
 * Stores information about individual storage sizes (like Megabytes, 
16
 * Kibibytes...), and offers utility methods to access the information.
17
 * 
18
 * NOTE: Use the enum's methods to retrieve instances of this class.
19
 *
20
 * @package AppUtils
21
 * @subpackage ConvertHelper
22
 * @author Sebastian Mordziol <[email protected]>
23
 * 
24
 * @see ConvertHelper_StorageSizeEnum
25
 */
26
class ConvertHelper_StorageSizeEnum_Size
27
{
28
   /**
29
    * @var string
30
    */
31
    protected $name;
32
    
33
   /**
34
    * @var int
35
    */
36
    protected $base;
37
    
38
   /**
39
    * @var int
40
    */
41
    protected $exponent;
42
    
43
   /**
44
    * @var string
45
    */
46
    protected $singular;
47
    
48
   /**
49
    * @var string
50
    */
51
    protected $plural;
52
    
53
   /**
54
    * @var string
55
    */
56
    protected $suffix;
57
    
58
    public function __construct(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural)
59
    {
60
        $this->name = $name;
61
        $this->base = $base;
62
        $this->exponent = $exponent;
63
        $this->suffix = $suffix;
64
        $this->singular = $singular;
65
        $this->plural = $plural;
66
    }
67
    
68
    public function getBytes() : int
69
    {
70
        return $this->base ** $this->exponent;
71
    }
72
    
73
    public function getName() : string
74
    {
75
        return $this->name;
76
    }
77
    
78
    public function getBase() : int
79
    {
80
        return $this->base;
81
    }
82
    
83
    public function getExponent() : int
84
    {
85
        return $this->exponent;
86
    }
87
    
88
    public function getSuffix() : string
89
    {
90
        return $this->suffix;
91
    }
92
93
    public function getLabelSingular() : string
94
    {
95
        return $this->singular;
96
    }
97
    
98
    public function getLabelPlural() : string
99
    {
100
        return $this->plural;
101
    }
102
}
103