RackUnitQuantity   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 28
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

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