PriceHistory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 46
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A attributeLabels() 0 7 1
A isQuantityPredefined() 0 4 1
A instantiate() 0 8 1
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;
12
13
use hipanel\base\ModelTrait;
14
15
/**
16
 * Class PlanHistory
17
 *
18
 * @property \DateTime $time
19
 * @property float $old_price
20
 */
21
class PriceHistory extends Price
22
{
23
    use ModelTrait;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function rules()
29
    {
30
        return array_merge(parent::rules(), [
31
            [['old_price', 'old_quantity'], 'number'],
32
            [['time'], 'date'],
33
        ]);
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function attributeLabels()
40
    {
41
        return array_merge(parent::attributeLabels(), [
42
            'old_price' => \Yii::t('hipanel.finance.price', 'Old price'),
43
            'old_quantity' => \Yii::t('hipanel.finance.price', 'Old quantity'),
44
        ]);
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function isQuantityPredefined(): bool
51
    {
52
        return true;
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public static function instantiate($row)
59
    {
60
        return new self([
61
            'time' => $row['time'],
62
            'old_price' => $row['old_price'],
63
            'old_quantity' => $row['old_quantity'],
64
        ]);
65
    }
66
}
67