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.

ResponseRenderer::render()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.9256

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 1
dl 0
loc 23
ccs 10
cts 15
cp 0.6667
crap 5.9256
rs 9.2408
c 0
b 0
f 0
1
<?php
2
3
namespace PhpBoot\Controller;
4
5
6
use Symfony\Component\HttpFoundation\Response;
7
8
class ResponseRenderer
9
{
10
    /**
11
     * @param array $output
12
     * @return string
13
     */
14 1
    public function render(array $output)
15
    {
16 1
        $response = new Response();
17 1
        $response->headers->set('Content-Type', 'application/json');
18 1
        foreach ($output as $key=>$value){
19
            //TODO 支持自定义格式输出
20
            //TODO 支持更多的输出目标
21 1
            if($key == 'content'){
22
                //if(is_array($value) || is_object($value)){
23 1
                    $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
24
                //}
25 1
                $response->setContent($value);
26 1
            }elseif($key == 'headers'){
27
                foreach ($value as $k=>$v){
28
                    $response->headers->set($k, $v);
29
                }
30
            }else{
31
                \PhpBoot\abort(new \UnexpectedValueException("Unexpected output target $key"));
32
            }
33
34 1
        }
35 1
        return $response;
36
    }
37
}