-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRateLimiterDto.php
More file actions
94 lines (82 loc) · 1.62 KB
/
RateLimiterDto.php
File metadata and controls
94 lines (82 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace Cleantalk\Common\RateLimiter;
use Cleantalk\Common\Templates\Dto;
/**
* Data transfer object for rate limit UID records
*
* @package CleantalkSP\Common\RateLimit
*/
class RateLimiterDto extends Dto
{
/**
* Current request counter for the UID
*
* @var int
*/
public $counter = 0;
/**
* Timestamp of the last request
*
* @var int
*/
public $last_call = 0;
/**
* Timestamp when the record was created
*
* @var int
*/
public $created_at = 0;
/**
* IP address associated with the UID
*
* @var string
*/
public $ip = '';
/**
* User agent associated with the UID
*
* @var string
*/
public $ua = '';
/**
* Unique identifier for the rate limit record
*
* @var string
*/
public $uid = '';
/**
* Type of rate limit (e.g., 'login', 'comment', etc.)
*
* @var string
*/
public $type = '';
/**
* Flag indicating if all required data fields are present
*
* @var bool
*/
public $data_ok = false;
protected $obligatory_properties = [
'uid',
'type',
'ip',
'ua',
'counter',
'last_call',
'created_at',
];
/**
* RateLimitUidData constructor.
*
* @param array $raw_data Raw data array from database
*/
public function __construct($raw_data)
{
try {
parent::__construct($raw_data);
$this->data_ok = true;
} catch (\Exception $_e) {
$this->data_ok = false;
}
}
}