Passed
Push — master ( 3924c7...4adc95 )
by Dmitry
13:16
created

HardwareSale   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A saleTime() 0 3 1
A rules() 0 6 1
1
<?php
2
3
namespace hipanel\modules\server\models;
4
5
/**
6
 * Class HardwareSale
7
 *
8
 * @property int $id
9
 * @property int $tariff_id
10
 * @property int $price_id
11
 * @property int $part_id
12
 * @property string $sale_time
13
 * @property string $part
14
 * @property string|null $serialno
15
 * @property string $usage_type
16
 * @property string $leasing_since
17
 * @property string $leasing_till
18
 * @property array|null $data
19
 */
20
class HardwareSale extends \hipanel\base\Model
21
{
22
    public const USAGE_TYPE_LEASING = 'leasing';
23
    public const USAGE_TYPE_RENT = 'rent';
24
    public const USAGE_TYPE_COLO = 'colo';
25
26
    public function rules()
27
    {
28
        return [
29
            [['id', 'tariff_id', 'price_id', 'part_id'], 'integer'],
30
            [['scenario', 'sale_time', 'serialno', 'part', 'usage_type', 'leasing_till', 'leasing_since'], 'string'],
31
            [['data'], 'safe'],
32
        ];
33
    }
34
35
    public function saleTime(): \DateTime
36
    {
37
        return new \DateTime($this->sale_time);
38
    }
39
}
40