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 (#103)
by Dwight
07:22
created

ClientFactory::instance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use Illuminate\Contracts\Cache\Repository;
6
use Illuminate\Contracts\Container\Container;
7
use Pushok\Client;
8
9
class ClientFactory
10
{
11
    /**
12
     * The number of minutes to cache the client.
13
     *
14
     * @var int
15
     */
16
    const CACHE_MINUTES = 20;
17
18
    /**
19
     * The app instance.
20
     *
21
     * @var \Illuminate\Contracts\Container\Container
22
     */
23
    protected $app;
24
25
    /**
26
     * The cache repository instance.
27
     *
28
     * @var \Illuminate\Contracts\Cache\Repository
29
     */
30
    protected $cache;
31
32
    /**
33
     * Create a new factory instance.
34
     *
35
     * @param  \Illuminate\Contracts\Container\Container  $app
36
     * @param  \Illuminate\Contracts\Cache\Repository  $cache
37
     * @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...
38
     */
39
    public function __construct(Container $app, Repository $cache)
40
    {
41
        $this->app = $app;
42
        $this->cache = $cache;
43
    }
44
45
    /**
46
     * Get an instance of the Pushok client, holding on to each in the cache for the given length of time.
47
     *
48
     * @return \Pushok\Client
49
     */
50
    public function instance(): Client
51
    {
52
        return $this->cache->remember(Client::class, now()->addMinutes(static::CACHE_MINUTES), function () {
53
            $this->app->make(Client::class);
54
        });
55
    }
56
}
57