| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @link https://dukt.net/analytics/ |
||
| 4 | * @copyright Copyright (c) 2022, Dukt |
||
| 5 | * @license https://github.com/dukt/analytics/blob/master/LICENSE.md |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace dukt\analytics\models; |
||
| 9 | |||
| 10 | use craft\base\Model; |
||
| 11 | use craft\helpers\Json; |
||
| 12 | |||
| 13 | class Info extends Model |
||
| 14 | { |
||
| 15 | // Properties |
||
| 16 | // ========================================================================= |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var int|null ID |
||
| 20 | */ |
||
| 21 | public $id; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var bool Force connect |
||
| 25 | */ |
||
| 26 | public $forceConnect = false; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string|null Token |
||
| 30 | */ |
||
| 31 | public $token; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var \DateTime|null Date updated |
||
| 35 | */ |
||
| 36 | public $dateUpdated; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var \DateTime|null Date created |
||
| 40 | */ |
||
| 41 | public $dateCreated; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string|null Uid |
||
| 45 | */ |
||
| 46 | public $uid; |
||
| 47 | |||
| 48 | // Public Methods |
||
| 49 | // ========================================================================= |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @inheritdoc |
||
| 53 | */ |
||
| 54 | public function init() |
||
| 55 | { |
||
| 56 | parent::init(); |
||
| 57 | |||
| 58 | // Make sure $forceConnect is going to be a boolean |
||
| 59 | if (is_string($this->forceConnect)) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 60 | $this->forceConnect = (bool)$this->forceConnect; |
||
| 61 | } |
||
| 62 | |||
| 63 | if (is_string($this->token)) { |
||
| 64 | $this->token = Json::decode($this->token); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @inheritdoc |
||
| 70 | */ |
||
| 71 | public function rules() |
||
| 72 | { |
||
| 73 | return [ |
||
| 74 | [['id', 'edition'], 'number', 'integerOnly' => true], |
||
| 75 | ]; |
||
| 76 | } |
||
| 77 | } |
||
| 78 |