Controller   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 33
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A accessToken() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the HRis Software package.
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * Licensed under the 3-clause BSD License.
9
 *
10
 * This source file is subject to the 3-clause BSD License that is
11
 * bundled with this package in the LICENSE file.
12
 *
13
 * @version    alpha
14
 *
15
 * @author     Bertrand Kintanar <[email protected]>
16
 * @license    BSD License (3-clause)
17
 * @copyright  (c) 2014-2016, b8 Studios, Ltd
18
 *
19
 * @link       http://github.com/HB-Co/HRis
20
 */
21
22
namespace HRis\Api\Controllers\Auth\OAuth;
23
24
use Exception;
25
use Irradiate\Api\Controllers\BaseController;
26
use LucaDegasperi\OAuth2Server\Authorizer;
27
use Symfony\Component\HttpFoundation\Response;
28
29
class Controller extends BaseController
30
{
31
    /**
32
     * @var Authorizer
33
     */
34
    protected $authorizer;
35
36
    /**
37
     * OAuthController constructor.
38
     *
39
     * @param Authorizer $authorizer
40
     *
41
     * @author Bertrand Kintanar <[email protected]>
42
     */
43
    public function __construct(Authorizer $authorizer)
44
    {
45
        $this->authorizer = $authorizer;
46
    }
47
48
    /**
49
     * @return array
50
     *
51
     * @author Bertrand Kintanar <[email protected]>
52
     */
53
    public function accessToken()
54
    {
55
        try {
56
            return $this->authorizer->issueAccessToken();
57
        } catch (Exception $e) {
58
            return $this->responseAPI(Response::HTTP_UNAUTHORIZED, 'Forbidden');
59
        }
60
    }
61
}
62