1 <?php
2
3 /*
4 * This file is part of the Icybee package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Icybee\Modules\Users\NonceLogin;
13
14 use ICanBoogie\ActiveRecord;
15 use ICanBoogie\DateTime;
16
17 /**
18 * Representation of a password request.
19 *
20 * @property DateTime|mixed $expire_at Date at which the ticket expires.
21 */
22 class Ticket extends ActiveRecord
23 {
24 /**
25 * Ticket identifier.
26 *
27 * @var string
28 */
29 public $token;
30
31 /**
32 * User identifier.
33 *
34 * @var int
35 */
36 public $uid;
37
38 /**
39 * Initial IP for the nonce login request.
40 *
41 * @var string
42 */
43 public $ip;
44
45 /**
46 * Date at which the ticket expires.
47 *
48 * @var DateTime|mixed
49 */
50 private $expire_at;
51
52 /**
53 * Returns the expire date.
54 *
55 * @return \ICanBoogie\DateTime
56 */
57 protected function get_expire_at()
58 {
59 $datetime = $this->expire_at;
60
61 if ($datetime instanceof DateTime)
62 {
63 return $datetime;
64 }
65
66 return $this->expire_at = ($datetime === null) ? DateTime::none() : new DateTime($datetime, 'utc');
67 }
68
69 /**
70 * Sets the expire date.
71 *
72 * @param mixed $value
73 */
74 protected function set_expire_at($datetime)
75 {
76 $this->expire_at = $datetime;
77 }
78
79 /**
80 * @param string $model Defaults to `users.noncelogin`.
81 */
82 public function __construct($model='users.noncelogin')
83 {
84 parent::__construct($model);
85 }
86 }