Passed
Push — master ( 1208d6...08925d )
by Steffen
08:15
created

DataTransferConverter::getBaseUnit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * This file is part of the unicorn project
4
 *
5
 * (c) Philipp Braeutigam <[email protected]>, Steffen Brand <[email protected]> and contributors
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Xynnn\Unicorn\Converter;
12
13
use Xynnn\Unicorn\Model\Unit;
14
15
class DataTransferConverter extends AbstractMathematicalConverter
16
{
17
18
    /**
19
     * @var Unit $bit_per_second Static instance for conversions
20
     */
21
    public static $bit_per_second;
22
23
    /**
24
     * @var Unit $kilobit_per_second Static instance for conversions
25
     */
26
    public static $kilobit_per_second;
27
28
    /**
29
     * @var Unit $megabit_per_second Static instance for conversions
30
     */
31
    public static $megabit_per_second;
32
33
    /**
34
     * @var Unit $gigabit_per_second Static instance for conversions
35
     */
36
    public static $gigabit_per_second;
37
38
    /**
39
     * @var Unit $terabit_per_second Static instance for conversions
40
     */
41
    public static $terabit_per_second;
42
43
    /**
44
     * @var Unit $petabit_per_second Static instance for conversions
45
     */
46
    public static $petabit_per_second;
47
48
    /**
49
     * @var Unit $exabit_per_second Static instance for conversions
50
     */
51
    public static $exabit_per_second;
52
53
    /**
54
     * @var Unit $zettabit_per_second Static instance for conversions
55
     */
56
    public static $zettabit_per_second;
57
58
    /**
59
     * @var Unit $yottabit_per_second Static instance for conversions
60
     */
61
    public static $yottabit_per_second;
62
63
    /**
64
     * @var Unit $kibibit_per_second Static instance for conversions
65
     */
66
    public static $kibibit_per_second;
67
68
    /**
69
     * @var Unit $mebibit_per_second Static instance for conversions
70
     */
71
    public static $mebibit_per_second;
72
73
    /**
74
     * @var Unit $gibibit_per_second Static instance for conversions
75
     */
76
    public static $gibibit_per_second;
77
78
    /**
79
     * @var Unit $tebibit_per_second Static instance for conversions
80
     */
81
    public static $tebibit_per_second;
82
83
    /**
84
     * @var Unit $pebibit_per_second Static instance for conversions
85
     */
86
    public static $pebibit_per_second;
87
88
    /**
89
     * @var Unit $exibit_per_second Static instance for conversions
90
     */
91
    public static $exibit_per_second;
92
93
    /**
94
     * @var Unit $zebibit_per_second Static instance for conversions
95
     */
96
    public static $zebibit_per_second;
97
98
    /**
99
     * @var Unit $yobibit_per_second Static instance for conversions
100
     */
101
    public static $yobibit_per_second;
102
103
    /**
104
     * @var Unit $byte_per_second Static instance for conversions
105
     */
106
    public static $byte_per_second;
107
108
    /**
109
     * @var Unit $kilobyte_per_second Static instance for conversions
110
     */
111
    public static $kilobyte_per_second;
112
113
    /**
114
     * @var Unit $megabyte_per_second Static instance for conversions
115
     */
116
    public static $megabyte_per_second;
117
118
    /**
119
     * @var Unit $gigabyte_per_second Static instance for conversions
120
     */
121
    public static $gigabyte_per_second;
122
123
    /**
124
     * @var Unit $terabyte_per_second Static instance for conversions
125
     */
126
    public static $terabyte_per_second;
127
128
    /**
129
     * @var Unit $petabyte_per_second Static instance for conversions
130
     */
131
    public static $petabyte_per_second;
132
133
    /**
134
     * @var Unit $exabyte_per_second Static instance for conversions
135
     */
136
    public static $exabyte_per_second;
137
138
    /**
139
     * @var Unit $zettabyte_per_second Static instance for conversions
140
     */
141
    public static $zettabyte_per_second;
142
143
    /**
144
     * @var Unit $yottabyte_per_second Static instance for conversions
145
     */
146
    public static $yottabyte_per_second;
147
148
    /**
149
     * @var Unit $kibibyte_per_second Static instance for conversions
150
     */
151
    public static $kibibyte_per_second;
152
153
    /**
154
     * @var Unit $mebibyte_per_second Static instance for conversions
155
     */
156
    public static $mebibyte_per_second;
157
158
    /**
159
     * @var Unit $gibibyte_per_second Static instance for conversions
160
     */
161
    public static $gibibyte_per_second;
162
163
    /**
164
     * @var Unit $tebibyte_per_second Static instance for conversions
165
     */
166
    public static $tebibyte_per_second;
167
168
    /**
169
     * @var Unit $pebibyte_per_second Static instance for conversions
170
     */
171
    public static $pebibyte_per_second;
172
173
    /**
174
     * @var Unit $exibyte_per_second Static instance for conversions
175
     */
176
    public static $exibyte_per_second;
177
178
    /**
179
     * @var Unit $zebibyte_per_second Static instance for conversions
180
     */
181
    public static $zebibyte_per_second;
182
183
    /**
184
     * @var Unit $yobibyte_per_second Static instance for conversions
185
     */
186
    public static $yobibyte_per_second;
187
188
    /**
189
     * LengthConverter constructor.
190
     */
191 5
    public function __construct()
192
    {
193 5
        $this->units[] = self::$bit_per_second = new Unit('Bit', 'Bit per second', '1000000');
194 5
        $this->units[] = self::$kilobit_per_second = new Unit('Kilobit per second', 'Kbit/s', '1000');
195 5
        $this->units[] = self::$megabit_per_second = new Unit('Megabit per second', 'Mbit/s', '1');
196 5
        $this->units[] = self::$gigabit_per_second = new Unit('Gigabit per second', 'Gbit/s', '0.001');
197 5
        $this->units[] = self::$terabit_per_second = new Unit('Terabit per second', 'Tbit/s', '0.000001');
198 5
        $this->units[] = self::$petabit_per_second = new Unit('Petabit per second', 'Pbit/s', '0.000000001');
199 5
        $this->units[] = self::$exabit_per_second = new Unit('Exabit per second', 'Ebit/s', '0.000000000001');
200 5
        $this->units[] = self::$zettabit_per_second = new Unit('Zettabit per second', 'Zbit/s', '0.000000000000001');
201 5
        $this->units[] = self::$yottabit_per_second = new Unit('Yottabit per second', 'Ybit/s', '0.000000000000000001');
202
203 5
        $this->units[] = self::$kibibit_per_second = new Unit('Kibibit per second', 'Kibit/s', '976.5625');
204 5
        $this->units[] = self::$mebibit_per_second = new Unit('Mebibit per second', 'Mibit/s', bcdiv(self::$kibibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
205 5
        $this->units[] = self::$gibibit_per_second = new Unit('Gibibit per second', 'Gibit/s', bcdiv(self::$mebibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
206 5
        $this->units[] = self::$tebibit_per_second = new Unit('Tebibit per second', 'Tibit/s', bcdiv(self::$gibibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
207 5
        $this->units[] = self::$pebibit_per_second = new Unit('Pebibit per second', 'Pibit/s', bcdiv(self::$tebibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
208 5
        $this->units[] = self::$exibit_per_second = new Unit('Exibit per second', 'Eibit/s', bcdiv(self::$pebibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
209 5
        $this->units[] = self::$zebibit_per_second = new Unit('Zebibit per second', 'Zibit/s', bcdiv(self::$exibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
210 5
        $this->units[] = self::$yobibit_per_second = new Unit('Yobibit per second', 'Yibit/s', bcdiv(self::$zebibit_per_second->getFactor(), '1024', self::MAX_DECIMALS));
211
212 5
        $this->units[] = self::$byte_per_second = new Unit('Byte per second', 'B/s', '125000');
213 5
        $this->units[] = self::$kilobyte_per_second = new Unit('Kilobyte per second', 'KB/s', '125');
214 5
        $this->units[] = self::$megabyte_per_second = new Unit('Megabyte per second', 'MB/s', '0.125');
215 5
        $this->units[] = self::$gigabyte_per_second = new Unit('Gigabyte per second', 'GB/s', '0.000125');
216 5
        $this->units[] = self::$terabyte_per_second = new Unit('Terabyte per second', 'TB/s', '0.000000125');
217 5
        $this->units[] = self::$petabyte_per_second = new Unit('Petabyte per second', 'PB/s', '0.000000000125');
218 5
        $this->units[] = self::$exabyte_per_second = new Unit('Exabyte per second', 'EB/s', '0.000000000000125');
219 5
        $this->units[] = self::$zettabyte_per_second = new Unit('Zettabyte per second', 'ZB/s', '0.000000000000000125');
220 5
        $this->units[] = self::$yottabyte_per_second = new Unit('Yottabyte per second', 'YB/s', '0.000000000000000000125');
221
222 5
        $this->units[] = self::$kibibyte_per_second = new Unit('Kibibyte per second', 'KiB/s', '122.07031296');
223 5
        $this->units[] = self::$mebibyte_per_second = new Unit('Mebibyte per second', 'MiB/s', bcdiv(self::$kibibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
224 5
        $this->units[] = self::$gibibyte_per_second = new Unit('Gibibyte per second', 'GiB/s', bcdiv(self::$mebibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
225 5
        $this->units[] = self::$tebibyte_per_second = new Unit('Tebibyte per second', 'TiB/s', bcdiv(self::$gibibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
226 5
        $this->units[] = self::$pebibyte_per_second = new Unit('Pebibyte per second', 'PiB/s', bcdiv(self::$tebibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
227 5
        $this->units[] = self::$exibyte_per_second = new Unit('Exibyte per second', 'EiB/s', bcdiv(self::$pebibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
228 5
        $this->units[] = self::$zebibyte_per_second = new Unit('Zebibyte per second', 'ZiB/s', bcdiv(self::$exibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
229 5
        $this->units[] = self::$yobibyte_per_second = new Unit('Yobibyte per second', 'YiB/s', bcdiv(self::$zebibyte_per_second->getFactor(), '1024', self::MAX_DECIMALS));
230 5
    }
231
232
    /**
233
     * @return string Name of the converter
234
     */
235 4
    public function getName(): string
236
    {
237 4
        return 'unicorn.converter.datatransfer';
238
    }
239
240 10
    public function getBaseUnit(): Unit
241
    {
242 10
        return self::$megabit_per_second;
243
    }
244
245
    /**
246
     * @param array $units
247
     */
248
    public function setUnits(array $units)
249
    {
250
        $this->units = $units;
251
    }
252
253
    /**
254
     * @param Unit $unit
255
     */
256
    public function addUnit(Unit $unit)
257
    {
258
        $this->units[] = $unit;
259
    }
260
261
}
262