JsonResponder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A notAuthorized() 0 10 1
1
<?php
2
/**
3
 * Cheka - Authorization
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  Responder
13
 * @package   Jnjxp\Cheka
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/jnjxp/jnjxp.cheka
18
 */
19
20
namespace Jnjxp\Cheka\Responder;
21
22
/**
23
 * JsonResponder
24
 *
25
 * @category Responder
26
 * @package  Jnjxp\Cheka
27
 * @author   Jake Johns <[email protected]>
28
 * @license  http://jnj.mit-license.org/ MIT License
29
 * @link     https://github.com/jnjxp/jnjxp.cheka
30
 *
31
 * @see AbstractResponder
32
 */
33
class JsonResponder extends AbstractResponder
34
{
35
    /**
36
     * Not Authorized
37
     *
38
     * @return Response
39
     *
40
     * @access protected
41
     */
42 1
    protected function notAuthorized()
43
    {
44 1
        $data = ['error' => $this->getAuthorizationMessage()];
45
46 1
        $this->response = $this->response
47 1
            ->withStatus(403)
48 1
            ->withHeader('Content-Type', 'application/json');
49
50 1
        $this->response->getBody()->write(json_encode($data));
51 1
    }
52
}
53