Token   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 2
A rules() 0 4 1
1
<?php
2
/**
3
 * @link      https://dukt.net/videos/
4
 * @copyright Copyright (c) Dukt
5
 * @license   https://github.com/dukt/videos/blob/v2/LICENSE.md
6
 */
7
8
namespace dukt\videos\models;
9
10
use craft\base\Model;
11
use craft\helpers\Json;
12
13
class Token extends Model
14
{
15
    // Properties
16
    // =========================================================================
17
18
    /**
19
     * @var int|null ID
20
     */
21
    public $id;
22
23
    /**
24
     * @var string|null Gateway
25
     */
26
    public $gateway;
27
28
29
    /**
30
     * @var string|null Access token
31
     */
32
    public $accessToken;
33
34
    /**
35
     * @var \DateTime|null Date updated
36
     */
37
    public $dateUpdated;
38
39
    /**
40
     * @var \DateTime|null Date created
41
     */
42
    public $dateCreated;
43
44
    /**
45
     * @var string|null Uid
46
     */
47
    public $uid;
48
49
    // Public Methods
50
    // =========================================================================
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function init(): void
56
    {
57
        parent::init();
58
59
        if (is_string($this->accessToken)) {
60
            $this->accessToken = Json::decode($this->accessToken);
61
        }
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function rules(): array
68
    {
69
        return [
70
            [['id'], 'number', 'integerOnly' => true],
71
        ];
72
    }
73
}
74