Completed
Push — master ( c66842...abceac )
by Dmitry
25:06 queued 10:07
created

PriceHistory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
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 44
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 6 1
A isQuantityPredefined() 0 4 1
A instantiate() 0 7 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'], '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
        ]);
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function isQuantityPredefined(): bool
50
    {
51
        return true;
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public static function instantiate($row)
58
    {
59
        return new self([
60
            'time' => $row['time'],
61
            'old_price' => $row['old_price'],
62
        ]);
63
    }
64
}
65