Completed
Push — master ( 691d80...8f3098 )
by Dmitry
13:51
created

PriceHistory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A attributeLabels() 0 6 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 static function instantiate($row)
50
    {
51
        return new self([
52
            'time' => $row['time'],
53
            'old_price' => $row['old_price'],
54
        ]);
55
    }
56
}
57