GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#180)
by Rias
01:33
created

BaseCacheProfile   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A enabled() 0 4 1
A cacheRequestUntil() 0 6 1
A cacheNameSuffix() 0 8 2
A isRunningInConsole() 0 8 2
A replacers() 0 8 1
1
<?php
2
3
namespace Spatie\ResponseCache\CacheProfiles;
4
5
use DateTime;
6
use Carbon\Carbon;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\Auth;
9
10
abstract class BaseCacheProfile implements CacheProfile
11
{
12
    public function enabled(Request $request): bool
13
    {
14
        return config('responsecache.enabled');
15
    }
16
17
    /*
18
     * Return the time when the cache must be invalided.
19
     */
20
    public function cacheRequestUntil(Request $request): DateTime
21
    {
22
        return Carbon::now()->addSeconds(
23
            config('responsecache.cache_lifetime_in_seconds')
24
        );
25
    }
26
27
    /*
28
     * Set a string to add to differentiate this request from others.
29
     */
30
    public function cacheNameSuffix(Request $request): string
31
    {
32
        if (Auth::check()) {
33
            return Auth::user()->id;
34
        }
35
36
        return '';
37
    }
38
39
    public function isRunningInConsole(): bool
40
    {
41
        if (app()->environment('testing')) {
42
            return false;
43
        }
44
45
        return app()->runningInConsole();
46
    }
47
48
    public function replacers(Request $request): array
49
    {
50
        return [
51
            'csrf_token' => function () {
52
                return csrf_token() ?? '';
53
            },
54
        ];
55
    }
56
}
57