QuantityTrait::getQuantity()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 4
nc 3
nop 0
crap 20
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 Yii;
14
15
trait QuantityTrait
16
{
17
    public function getQuantity()
18
    {
19
        if (!$this->isNewRecord && isset($this->type)) {
0 ignored issues
show
Bug introduced by
The property isNewRecord does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
            /** @var QuantityFormatterFactoryInterface $factory */
21
            $factory = Yii::$container->get(QuantityFormatterFactoryInterface::class);
22
            $billQty = $factory->create($this);
23
24
            if ($billQty !== null) {
25
                return $billQty->getClientValue();
26
            }
27
        }
28
    }
29
}
30