RackUnitQuantity::getClientValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
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\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