Completed
Push — master ( 9a535c...c9feec )
by Dmitry
14:33
created

RackUnitQuantity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 9 1
A getValue() 0 4 1
A getClientValue() 0 4 1
1
<?php
2
3
namespace hipanel\modules\finance\logic\bill;
4
5
use hipanel\modules\finance\forms\BillForm;
6
use hipanel\modules\finance\models\Bill;
7
use hipanel\modules\finance\models\Charge;
8
use hipanel\modules\server\models\Consumption;
9
use hiqdev\php\units\Quantity;
10
use Yii;
11
12
/**
13
 * Class MonthlyQuantity
14
 *
15
 * @author Dmytro Naumenko <[email protected]>
16
 */
17
class RackUnitQuantity extends MonthlyQuantity
18
{
19
    /** @var Charge */
20
    protected $model;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function format(): string
26
    {
27
        $text = Yii::t('hipanel:finance', '{units, plural, one{# unit} other{# units}} &times; {quantity, plural, one{# day} other{# days}}', [
28
            'units' => $this->model->quantity / $this->model->bill->quantity,
29
            'quantity' => round($this->model->bill->quantity * $this->getNumberOfDays())
30
        ]);
31
32
        return $text;
33
    }
34
35
    public function getValue(): string
36
    {
37
        return $this->getQuantity()->getQuantity();
38
    }
39
40
    public function getClientValue(): string
41
    {
42
        return $this->getQuantity()->getQuantity();
43
    }
44
}
45