Record   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 59
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tableAlias() 0 4 1
A tableName() 0 4 1
B rules() 0 27 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/spark
7
 */
8
9
namespace flipbox\spark\records;
10
11
use craft\db\ActiveRecord as BaseRecord;
12
use craft\validators\DateTimeValidator;
13
use DateTime;
14
use flipbox\spark\helpers\RecordHelper;
15
16
/**
17
 * @property DateTime $dateCreated
18
 * @property DateTime $dateUpdated
19
 * @property string $uid
20
 *
21
 * @author Flipbox Factory <[email protected]>
22
 * @since 1.0.0
23
 */
24
abstract class Record extends BaseRecord
25
{
26
27
    /**
28
     * The table alias
29
     */
30
    const TABLE_ALIAS = '';
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public static function tableAlias()
36
    {
37
        return static::TABLE_ALIAS;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public static function tableName()
44
    {
45
        return '{{%' . static::tableAlias() . '}}';
46
    }
47
48
    /*******************************************
49
     * RULES
50
     *******************************************/
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function rules()
56
    {
57
58
        return array_merge(
59
            parent::rules(),
60
            [
61
                [
62
                    [
63
                        'dateCreated',
64
                        'dateUpdated'
65
                    ],
66
                    DateTimeValidator::class
67
                ],
68
                [
69
                    [
70
                        'uid',
71
                        'dateCreated',
72
                        'dateUpdated'
73
                    ],
74
                    'safe',
75
                    'on' => [
76
                        RecordHelper::SCENARIO_DEFAULT
77
                    ]
78
                ]
79
            ]
80
        );
81
    }
82
}
83