Issues (21)

src/Provider/ProviderProvider.php (1 issue)

Severity
1
<?php
2
3
namespace App\Provider;
4
5
use App\Facades\Settings;
6
use App\Provider\Bitbucket;
7
use App\Provider\Github;
8
use App\Provider\Gitlab;
9
use GuzzleHttp\Client;
10
use GuzzleHttp\ClientInterface;
11
use Ronanchilvers\Container\Container;
12
use Ronanchilvers\Container\ServiceProviderInterface;
13
14
/**
15
 * Provider for ... err... providers!
16
 *
17
 * @author Ronan Chilvers <[email protected]>
18
 */
19
class ProviderProvider implements ServiceProviderInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @author Ronan Chilvers <[email protected]>
25
     */
26
    public function register(Container $container)
27
    {
28
        $container->share(Factory::class, function($c) {
0 ignored issues
show
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

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

28
        $container->share(Factory::class, function(/** @scrutinizer ignore-unused */ $c) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
            $factory = new Factory();
30
31
            if ($token = Settings::get('providers.github.token', false)) {
32
                $client = new Client([
33
                    'headers' => [
34
                        "Authorization" => "token {$token}",
35
                    ]
36
                ]);
37
                $factory->addProvider(new Github($client, $token));
38
            }
39
40
            if ($token = Settings::get('providers.gitlab.token', false)) {
41
                $client = new Client([
42
                    'headers' => [
43
                        "Private-Token" => $token,
44
                    ]
45
                ]);
46
                $factory->addProvider(new Gitlab($client, $token));
47
            }
48
49
            if ($token = Settings::get('providers.bitbucket.token', false)) {
50
                $username = Settings::get('providers.bitbucket.username', false);
51
                $client = new Client([
52
                    'auth' => [$username, $token],
53
                ]);
54
                $factory->addProvider(new Bitbucket($client, $token));
55
            }
56
57
            return $factory;
58
        });
59
    }
60
}
61