Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SmsRateLimitEntity | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| increment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isExpired | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Modules\NotificationModule\Entities; |
| 4 | |
| 5 | use CodeIgniter\Entity\Entity; |
| 6 | |
| 7 | class SmsRateLimitEntity extends Entity |
| 8 | { |
| 9 | protected $datamap = []; |
| 10 | protected $dates = ['window_start', 'created_at', 'updated_at']; |
| 11 | protected $casts = [ |
| 12 | 'sent_count' => 'integer', |
| 13 | ]; |
| 14 | |
| 15 | public function increment(): void |
| 16 | { |
| 17 | $this->attributes['sent_count'] = ((int) $this->sent_count) + 1; |
| 18 | } |
| 19 | |
| 20 | public function isExpired(): bool |
| 21 | { |
| 22 | return strtotime($this->window_start) < strtotime('-1 minute'); |
| 23 | } |
| 24 | } |