]> git.mxchange.org Git - friendica.git/blob - src/Security/TwoFactor/Model/TrustedBrowser.php
Merge remote-tracking branch 'upstream/2021.12-rc' into lemmy
[friendica.git] / src / Security / TwoFactor / Model / TrustedBrowser.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Security\TwoFactor\Model;
23
24 use Friendica\BaseEntity;
25 use Friendica\Util\DateTimeFormat;
26
27 /**
28  * Class TrustedBrowser
29  *
30  *
31  * @property-read $cookie_hash
32  * @property-read $uid
33  * @property-read $user_agent
34  * @property-read $created
35  * @property-read $last_used
36  * @package Friendica\Model\TwoFactor
37  */
38 class TrustedBrowser extends BaseEntity
39 {
40         protected $cookie_hash;
41         protected $uid;
42         protected $user_agent;
43         protected $created;
44         protected $last_used;
45
46         /**
47          * Please do not use this constructor directly, instead use one of the method of the TrustedBroser factory.
48          *
49          * @see \Friendica\Security\TwoFactor\Factory\TrustedBrowser
50          *
51          * @param string      $cookie_hash
52          * @param int         $uid
53          * @param string      $user_agent
54          * @param string      $created
55          * @param string|null $last_used
56          */
57         public function __construct(string $cookie_hash, int $uid, string $user_agent, string $created, string $last_used = null)
58         {
59                 $this->cookie_hash = $cookie_hash;
60                 $this->uid = $uid;
61                 $this->user_agent = $user_agent;
62                 $this->created = $created;
63                 $this->last_used = $last_used;
64         }
65
66         public function recordUse()
67         {
68                 $this->last_used = DateTimeFormat::utcNow();
69         }
70 }