RamResourceDecorator::displayUnit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\models\decorators\server;
12
13
use Yii;
14
15 View Code Duplication
class RamResourceDecorator extends AbstractServerResourceDecorator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    public function displayTitle()
18
    {
19
        return Yii::t('hipanel:server:order', 'RAM');
20
    }
21
22
    public function getPrepaidQuantity()
23
    {
24
        $part = $this->resource->part;
25
        preg_match('/((\d{1,5}) MB)$/i', $part->partno, $matches);
26
27
        return $matches[2] / 1024;
28
    }
29
30
    public function getOverusePrice()
31
    {
32
        return 4; // TODO: move to config
33
    }
34
35
    public function displayUnit()
36
    {
37
        return Yii::t('hipanel', 'GB');
38
    }
39
40
    public function toUnit(): string
41
    {
42
        return 'gb';
43
    }
44
45
    public function displayPrepaidAmount()
46
    {
47
        return Yii::t('yii', '{nFormatted} GB', ['nFormatted' => $this->getPrepaidQuantity()]);
48
    }
49
}
50