HardwareSale::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\models;
12
13
/**
14
 * Class HardwareSale.
15
 *
16
 * @property int $id
17
 * @property int $tariff_id
18
 * @property int $price_id
19
 * @property int $part_id
20
 * @property string $sale_time
21
 * @property string $part
22
 * @property string|null $serialno
23
 * @property string $usage_type
24
 * @property string $leasing_since
25
 * @property string $leasing_till
26
 * @property array|null $data
27
 */
28
class HardwareSale extends \hipanel\base\Model
29
{
30
    public const USAGE_TYPE_LEASING = 'leasing';
31
    public const USAGE_TYPE_RENT = 'rent';
32
    public const USAGE_TYPE_COLO = 'colo';
33
34
    public function rules()
35
    {
36
        return [
37
            [['id', 'tariff_id', 'price_id', 'part_id'], 'integer'],
38
            [['scenario', 'sale_time', 'serialno', 'part', 'usage_type', 'leasing_till', 'leasing_since'], 'string'],
39
            [['data'], 'safe'],
40
        ];
41
    }
42
43
    public function saleTime(): \DateTime
44
    {
45
        return new \DateTime($this->sale_time);
46
    }
47
}
48