Test Failed
Push — master ( 817d84...d52e3d )
by Raffael
05:44
created

Http   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
dl 0
loc 36
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ preAuthentication() 0 6 2
A __construct() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2019 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Idp\Constructor;
13
14
use Balloon\App\Idp\Api\v2;
15
use Balloon\Hook;
16
use Balloon\Hook\AbstractHook;
17
use Micro\Auth\Adapter\None as AuthNone;
18
use Micro\Auth\Auth;
19
use Micro\Http\Router;
20
use Micro\Http\Router\Route;
21
22
class Http
23
{
24
    /**
25
     * Router.
26
     *
27
     * @var Router
28
     */
29
    protected $router;
30
31
    /**
32
     * Hook.
33
     *
34
     * @var Hook
35
     */
36
    protected $hook;
37
38
    /**
39
     * Constructor.
40
     */
41
    public function __construct(Router $router, Hook $hook)
42
    {
43
        $router
44
            ->appendRoute(new Route('/api/v2/tokens', v2\Tokens::class));
45
46
        $hook->injectHook(new class() extends AbstractHook {
47
            public function preAuthentication(Auth $auth): void
48
            {
49
                if ('/index.php/api/v2/tokens' === $_SERVER['ORIG_SCRIPT_NAME']) {
50
                    $auth->injectAdapter(new AuthNone());
51
                }
52
            }
53
        });
54
55
        return true;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
56
    }
57
}
58