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.
Passed
Push — master ( c77907...638f4c )
by Choraimy
06:10
created

UrlShortenerManager::createOuoIoDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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\OuoIoShortener;
12
use LaraCrafts\UrlShortener\Http\ShorteStShortener;
13
use LaraCrafts\UrlShortener\Http\TinyUrlShortener;
14
15
/**
16
 * @mixin \LaraCrafts\UrlShortener\Contracts\Shortener
17
 */
18
class UrlShortenerManager extends Manager implements Factory
19
{
20
    /**
21
     * Create an instance of the Bit.ly driver.
22
     *
23
     * @return \LaraCrafts\UrlShortener\Http\BitLyShortener
24
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
25
     */
26 24
    protected function createBitLyDriver()
27
    {
28 24
        $config = $this->getDriverConfig('bit_ly');
29
30 24
        return new BitLyShortener(
31 24
            $this->app->make(ClientInterface::class),
32 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

32
            /** @scrutinizer ignore-type */ Arr::get($config, 'token'),
Loading history...
33 24
            Arr::get($config, 'domain', 'bit.ly')
34
        );
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 120
    protected function createDriver($driver)
41
    {
42
        # This fixes backwards compatibility issues with this function
43 120
        if (method_exists($this, $method = 'create' . Str::studly($driver) . 'Driver')) {
44 120
            return $this->$method();
45
        }
46
47
        return parent::createDriver($driver);
48
    }
49
50
    /**
51
     * Create an instance of the Ouo.io driver.
52
     *
53
     * @return \LaraCrafts\UrlShortener\Http\OuoIoShortener
54
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
55
     */
56 24
    protected function createOuoIoDriver()
57
    {
58 24
        $config = $this->getDriverConfig('ouo_io');
59
60 24
        return new OuoIoShortener(
61 24
            $this->app->make(ClientInterface::class),
62 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

62
            /** @scrutinizer ignore-type */ Arr::get($config, 'token')
Loading history...
63
        );
64
    }
65
66
    /**
67
     * Create an instance of the Shorte.st driver.
68
     *
69
     * @return \LaraCrafts\UrlShortener\Http\ShorteStShortener
70
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
71
     */
72 24
    protected function createShorteStDriver()
73
    {
74 24
        $config = $this->getDriverConfig('shorte_st');
75
76 24
        return new ShorteStShortener(
77 24
            $this->app->make(ClientInterface::class),
78 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

78
            /** @scrutinizer ignore-type */ Arr::get($config, 'token')
Loading history...
79
        );
80
    }
81
82
    /**
83
     * Create an instance of the TinyURL driver.
84
     *
85
     * @return \LaraCrafts\UrlShortener\Http\TinyUrlShortener
86
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
87
     */
88 48
    protected function createTinyUrlDriver()
89
    {
90 48
        return new TinyUrlShortener($this->app->make(ClientInterface::class));
91
    }
92
93
    /**
94
     * {@inheritDoc}
95
     */
96 24
    public function getDefaultDriver()
97
    {
98 24
        return $this->app['config']['url-shortener.default'];
99
    }
100
101
    /**
102
     * Get the driver configuration.
103
     *
104
     * @param string $name
105
     * @return array
106
     */
107 72
    protected function getDriverConfig(string $name)
108
    {
109 72
        return $this->app['config']["url-shortener.drivers.$name"] ?: [];
110
    }
111
}
112