UserNotFoundCache::has()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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