UserNotFoundCache   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A has() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Minepic\Cache;
6
7
class UserNotFoundCache
8
{
9
    private const PREFIX = 'not_found_';
10
    private const TTL = 86400;
11
12
    public static function has(string $usernameOrUuid): bool
13
    {
14
        if (\Cache::has(self::PREFIX.md5($usernameOrUuid))) {
15
            \Log::debug('User not found cache hit: '.$usernameOrUuid);
16
17
            return true;
18
        }
19
20
        return false;
21
    }
22
23
    public static function add(string $usernameOrUuid): bool
24
    {
25
        return \Cache::add(self::PREFIX.md5($usernameOrUuid), 1, self::TTL);
26
    }
27
}
28