Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6.7458 |
Changes | 0 |
1 | <?php |
||
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 | 1 | //if(is_array($value) || is_object($value)){ |
|
|
|||
23 | $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 | } |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.