Passed
Push — master ( bebbb3...38c082 )
by Mattia
03:32
created

UserNotFoundCache   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
dl 0
loc 23
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A add() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Cache;
6
7
use Illuminate\Support\Facades\Cache;
8
9
class UserNotFoundCache
10
{
11
    private const PREFIX = 'not_found_';
12
    private const TTL = 86400;
13
14
    /**
15
     * @param string $usernameOrUuid
16
     *
17
     * @return bool
18
     */
19
    public static function has(string $usernameOrUuid)
20
    {
21
        return Cache::has(self::PREFIX.\md5($usernameOrUuid));
22
    }
23
24
    /**
25
     * @param $usernameOrUuid
26
     *
27
     * @return bool
28
     */
29
    public static function add($usernameOrUuid)
30
    {
31
        return Cache::add(self::PREFIX.\md5($usernameOrUuid), 1, self::TTL);
32
    }
33
}
34