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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 10
cts 15
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 23 5
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
}