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 ( af6026...753030 )
by
unknown
08:57
created

UrlShortenerManager::createFirebaseDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LaraCrafts\UrlShortener;
4
5
use GuzzleHttp\ClientInterface;
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\Manager;
8
use Illuminate\Support\Str;
9
use LaraCrafts\UrlShortener\Contracts\Factory;
10
use LaraCrafts\UrlShortener\Http\BitLyShortener;
11
use LaraCrafts\UrlShortener\Http\FirebaseShortener;
12
use LaraCrafts\UrlShortener\Http\IsGdShortener;
13
use LaraCrafts\UrlShortener\Http\OuoIoShortener;
14
use LaraCrafts\UrlShortener\Http\ShorteStShortener;
15
use LaraCrafts\UrlShortener\Http\TinyUrlShortener;
16
17
/**
18
 * @mixin \LaraCrafts\UrlShortener\Contracts\Shortener
19
 */
20
class UrlShortenerManager extends Manager implements Factory
21
{
22
    /**
23
     * Create an instance of the Bit.ly driver.
24
     *
25
     * @return \LaraCrafts\UrlShortener\Http\BitLyShortener
26
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
27
     */
28 24
    protected function createBitLyDriver()
29
    {
30 24
        $config = $this->getDriverConfig('bit_ly');
31
32 24
        return new BitLyShortener(
33 24
            $this->app->make(ClientInterface::class),
34 24
            Arr::get($config, 'token'),
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'token') can also be of type null; however, parameter $token of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
            /** @scrutinizer ignore-type */ Arr::get($config, 'token'),
Loading history...
35 24
            Arr::get($config, 'domain', 'bit.ly')
36
        );
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42 168
    protected function createDriver($driver)
43
    {
44
        # This fixes backwards compatibility issues with this function
45 168
        if (method_exists($this, $method = 'create' . Str::studly($driver) . 'Driver')) {
46 168
            return $this->$method();
47
        }
48
49
        return parent::createDriver($driver);
50
    }
51
52
    /**
53
     * Create an instance of the Firebase driver.
54
     *
55
     * @return \LaraCrafts\UrlShortener\Http\FirebaseShortener
56
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
57
     */
58 24
    protected function createFirebaseDriver()
59
    {
60 24
        $config = $this->getDriverConfig('firebase');
61
62 24
        return new FirebaseShortener(
63 24
            $this->app->make(ClientInterface::class),
64 24
            Arr::get($config, 'token'),
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'token') can also be of type null; however, parameter $token of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
            /** @scrutinizer ignore-type */ Arr::get($config, 'token'),
Loading history...
65 24
            Arr::get($config, 'prefix'),
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'prefix') can also be of type null; however, parameter $domain of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

65
            /** @scrutinizer ignore-type */ Arr::get($config, 'prefix'),
Loading history...
66 24
            Arr::get($config, 'suffix')
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'suffix') can also be of type null; however, parameter $suffix of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

66
            /** @scrutinizer ignore-type */ Arr::get($config, 'suffix')
Loading history...
67
        );
68
    }
69
70
    /**
71
     * Create an instance of the Is.gd driver.
72
     *
73
     * @return \LaraCrafts\UrlShortener\Http\IsGdShortener
74
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
75
     */
76 24
    protected function createIsGdDriver()
77
    {
78 24
        $config = $this->getDriverConfig('is_gd');
79
80 24
        return new IsGdShortener(
81 24
            $this->app->make(ClientInterface::class),
82 24
            Arr::get($config, 'link_previews'),
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::...onfig, 'link_previews') can also be of type null; however, parameter $linkPreviews of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
            /** @scrutinizer ignore-type */ Arr::get($config, 'link_previews'),
Loading history...
83 24
            Arr::get($config, 'statistics')
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::...($config, 'statistics') can also be of type null; however, parameter $statistics of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

83
            /** @scrutinizer ignore-type */ Arr::get($config, 'statistics')
Loading history...
84
        );
85
    }
86
87
    /**
88
     * Create an instance of the Ouo.io driver.
89
     *
90
     * @return \LaraCrafts\UrlShortener\Http\OuoIoShortener
91
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
92
     */
93 24
    protected function createOuoIoDriver()
94
    {
95 24
        $config = $this->getDriverConfig('ouo_io');
96
97 24
        return new OuoIoShortener(
98 24
            $this->app->make(ClientInterface::class),
99 24
            Arr::get($config, 'token')
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'token') can also be of type null; however, parameter $token of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
            /** @scrutinizer ignore-type */ Arr::get($config, 'token')
Loading history...
100
        );
101
    }
102
103
    /**
104
     * Create an instance of the Shorte.st driver.
105
     *
106
     * @return \LaraCrafts\UrlShortener\Http\ShorteStShortener
107
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
108
     */
109 24
    protected function createShorteStDriver()
110
    {
111 24
        $config = $this->getDriverConfig('shorte_st');
112
113 24
        return new ShorteStShortener(
114 24
            $this->app->make(ClientInterface::class),
115 24
            Arr::get($config, 'token')
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Arr::get($config, 'token') can also be of type null; however, parameter $token of LaraCrafts\UrlShortener\...hortener::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

115
            /** @scrutinizer ignore-type */ Arr::get($config, 'token')
Loading history...
116
        );
117
    }
118
119
    /**
120
     * Create an instance of the TinyURL driver.
121
     *
122
     * @return \LaraCrafts\UrlShortener\Http\TinyUrlShortener
123
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
124
     */
125 48
    protected function createTinyUrlDriver()
126
    {
127 48
        return new TinyUrlShortener($this->app->make(ClientInterface::class));
128
    }
129
130
    /**
131
     * {@inheritDoc}
132
     */
133 24
    public function getDefaultDriver()
134
    {
135 24
        return $this->app['config']['url-shortener.default'];
136
    }
137
138
    /**
139
     * Get the driver configuration.
140
     *
141
     * @param string $name
142
     * @return array
143
     */
144 120
    protected function getDriverConfig(string $name)
145
    {
146 120
        return $this->app['config']["url-shortener.drivers.$name"] ?: [];
147
    }
148
}
149