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
Push — master ( 42a25e...777e0d )
by Freek
05:28
created

BaseCacheProfile::enabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\ResponseCache\CacheProfiles;
4
5
use DateTime;
6
use Carbon\Carbon;
7
use Illuminate\Http\Request;
8
9
abstract class BaseCacheProfile implements CacheProfile
10
{
11
    public function enabled(Request $request): bool
12
    {
13
        return config('responsecache.enabled');
14
    }
15
16
    /*
17
     * Return the time when the cache must be invalided.
18
     */
19
    public function cacheRequestUntil(Request $request): DateTime
20
    {
21
        return Carbon::now()->addMinutes(
22
            config('responsecache.cache_lifetime_in_minutes')
23
        );
24
    }
25
26
    /*
27
     * Set a string to add to differentiate this request from others.
28
     */
29
    public function cacheNameSuffix(Request $request): string
30
    {
31
        if (auth()->check()) {
0 ignored issues
show
Bug introduced by
The method check does only exist in Illuminate\Contracts\Auth\Guard, but not in Illuminate\Contracts\Auth\Factory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
32
            return auth()->user()->id;
0 ignored issues
show
Bug introduced by
The method user does only exist in Illuminate\Contracts\Auth\Guard, but not in Illuminate\Contracts\Auth\Factory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
33
        }
34
35
        return '';
36
    }
37
38
    public function isRunningInConsole(): bool
39
    {
40
        if (app()->environment('testing')) {
41
            return false;
42
        }
43
44
        return app()->runningInConsole();
45
    }
46
}
47