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 ( 317e01...f677f7 )
by jake
13:56 queued 07:11
created

Config::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Aura\Auth Provider for Aura\Di
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Config
13
 * @package   Fusible\AuthProvider
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      https://github.com/fusible/fusible.auth-provider
18
 */
19
20
namespace Fusible\AuthProvider;
21
22
use Aura\Di\Container;
23
use Aura\Di\ContainerConfig;
24
25
use Aura\Auth;
26
use Aura\Auth\Adapter\NullAdapter;
27
28
/**
29
 * Config
30
 *
31
 * @category Config
32
 * @package  Fusible\AuthProvider
33
 * @author   Jake Johns <[email protected]>
34
 * @license  http://jnj.mit-license.org/2016 MIT License
35
 * @link     https://github.com/fusible/fusible.auth-provider
36
 *
37
 * @see ContainerConfig
38
 */
39
class Config extends ContainerConfig
40
{
41
    /**
42
     * Cookie
43
     *
44
     * @var array
45
     *
46
     * @access protected
47
     */
48
    protected $cookie;
49
50
    /**
51
     * __construct
52
     *
53
     * @param array $cookie Cookie array
54
     *
55
     * @access public
56
     */
57 7
    public function __construct(array $cookie = null)
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $_COOKIE which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
58
    {
59 7
        $this->cookie = (null === $cookie) ? $_COOKIE : $cookie;
60 7
    }
61
62
    /**
63
     * Define Aura\Auth factories and services
64
     *
65
     * @param Container $di DI Container
66
     *
67
     * @return void
68
     *
69
     * @access public
70
     *
71
     * @SuppressWarnings(PHPMD.ShortVariable)
72
     */
73 7
    public function define(Container $di)
74
    {
75 7
        if (! isset($di->values['_COOKIE'])) {
76 7
            $di->values['_COOKIE'] = $this->cookie;
77 7
        }
78
79 7
        $di->params[Auth\AuthFactory::class]['cookie'] = $di->lazyValue('_COOKIE');
80
81 7
        $di->set(
82 7
            Auth\AuthFactory::class,
83 7
            $di->lazyNew(Auth\AuthFactory::class)
84 7
        );
85
86 7
        if (! $di->has(Auth\Adapter::class)) {
87 7
            $di->set(
88 7
                Auth\Adapter::class,
89 7
                $di->lazyNew(Auth\Adapter\NullAdapter::class)
90 7
            );
91 7
        }
92
93 7
        $di->set(
94 7
            Auth\Auth::class,
95 7
            $di->lazyGetCall(Auth\AuthFactory::class, 'newInstance')
96 7
        );
97
98 7
        $di->set(
99 7
            Auth\Service\LoginService::class,
100 7
            $di->lazyGetCall(
101 7
                Auth\AuthFactory::class,
102 7
                'newLoginService',
103 7
                $di->lazyGet(Auth\Adapter::class)
104 7
            )
105 7
        );
106
107 7
        $di->set(
108 7
            Auth\Service\LogoutService::class,
109 7
            $di->lazyGetCall(
110 7
                Auth\AuthFactory::class,
111 7
                'newLogoutService',
112 7
                $di->lazyGet(Auth\Adapter::class)
113 7
            )
114 7
        );
115
116 7
        $di->set(
117 7
            Auth\Service\ResumeService::class,
118 7
            $di->lazyGetCall(
119 7
                Auth\AuthFactory::class,
120 7
                'newResumeService',
121 7
                $di->lazyGet(Auth\Adapter::class)
122 7
            )
123 7
        );
124 7
    }
125
}
126