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 )
by jake
05:58 queued 03:42
created

Config::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2.1481
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\AuthFactory as Factory;
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
    const COOKIE = 'cookie';
42
43
    const FACTORY = 'aura/auth:factory';
44
    const ADAPTER = 'aura/auth:adapter';
45
46
    const AUTH   = 'aura/auth:auth';
47
48
    const LOGIN  = 'aura/auth:login';
49
    const LOGOUT = 'aura/auth:logout';
50
    const RESUME = 'aura/auth:resume';
51
52
53
    /**
54
     * Cookie
55
     *
56
     * @var array
57
     *
58
     * @access protected
59
     */
60
    protected $cookie;
61
62
    /**
63
     * __construct
64
     *
65
     * @param array $cookie Cookie array
66
     *
67
     * @access public
68
     */
69 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...
70
    {
71 7
        $this->cookie = (null === $cookie) ? $_COOKIE : $cookie;
72
    }
73
74
    /**
75
     * Define Aura\Auth factories and services
76
     *
77
     * @param Container $di DI Container
78
     *
79
     * @return void
80
     *
81
     * @access public
82
     *
83
     * @SuppressWarnings(PHPMD.ShortVariable)
84
     */
85 7
    public function define(Container $di)
86
    {
87
        if (! isset($di->values[static::COOKIE])) {
88
            $di->values[static::COOKIE] = $this->cookie;
89
        }
90
91
        $di->params[Factory::class]['cookie'] = $di->lazyValue(static::COOKIE);
92
93
        $di->set(
94 7
            static::FACTORY,
95 7
            $di->lazyNew(Factory::class)
96
        );
97
98
        if (! $di->has(static::ADAPTER)) {
99
            $di->set(
100 7
                static::ADAPTER,
101 7
                $di->lazyNew(NullAdapter::class)
102
            );
103
        }
104
105
        $di->set(
106 7
            static::AUTH,
107 7
            $di->lazyGetCall(static::FACTORY, 'newInstance')
108
        );
109
110
        $di->set(
111 7
            static::LOGIN,
112
            $di->lazyGetCall(
113 7
                static::FACTORY,
114 7
                'newLoginService',
115 7
                $di->lazyGet(static::ADAPTER)
116
            )
117
        );
118
119
        $di->set(
120 7
            static::LOGOUT,
121
            $di->lazyGetCall(
122 7
                static::FACTORY,
123 7
                'newLogoutService',
124 7
                $di->lazyGet(static::ADAPTER)
125
            )
126
        );
127
128
        $di->set(
129 7
            static::RESUME,
130
            $di->lazyGetCall(
131 7
                static::FACTORY,
132 7
                'newResumeService',
133 7
                $di->lazyGet(static::ADAPTER)
134
            )
135
        );
136
    }
137
}
138