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 ( 3a0cec...99453a )
by Dwight
14s queued 11s
created

ClientFactory::instance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use Illuminate\Contracts\Cache\Repository;
6
use Illuminate\Contracts\Container\Container;
7
use Illuminate\Support\Carbon;
8
use Pushok\Client;
9
10
class ClientFactory
11
{
12
    /**
13
     * The number of minutes to cache the client.
14
     *
15
     * @var int
16
     */
17
    const CACHE_MINUTES = 20;
18
19
    /**
20
     * The app instance.
21
     *
22
     * @var \Illuminate\Contracts\Container\Container
23
     */
24
    protected $app;
25
26
    /**
27
     * The cache repository instance.
28
     *
29
     * @var \Illuminate\Contracts\Cache\Repository
30
     */
31
    protected $cache;
32
33
    /**
34
     * Create a new factory instance.
35
     *
36
     * @param  \Illuminate\Contracts\Container\Container  $app
37
     * @param  \Illuminate\Contracts\Cache\Repository  $cache
38
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
39
     */
40 1
    public function __construct(Container $app, Repository $cache)
41
    {
42 1
        $this->app = $app;
43 1
        $this->cache = $cache;
44 1
    }
45
46
    /**
47
     * Get an instance of the Pushok client, holding on to each in the cache for the given length of time.
48
     *
49
     * @return \Pushok\Client
50
     */
51 1
    public function instance(): Client
52
    {
53
        return $this->cache->remember(Client::class, Carbon::now()->addMinutes(static::CACHE_MINUTES), function () {
54 1
            return $this->app->make(Client::class);
55 1
        });
56
    }
57
}
58