Completed
Push — 1.x ( fd0140...2593ab )
by Akihito
15s
created

HttpResponder::__invoke()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 4
nop 2
dl 0
loc 18
ccs 0
cts 8
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the BEAR.Sunday package.
6
 *
7
 * @license http://opensource.org/licenses/MIT MIT
8
 */
9
namespace BEAR\Sunday\Provide\Transfer;
10
11
use BEAR\Resource\ResourceObject;
12
use BEAR\Sunday\Extension\Transfer\TransferInterface;
13
14
class HttpResponder implements TransferInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function __invoke(ResourceObject $ro, array $server)
20
    {
21
        unset($server);
22
        // render
23
        if (! $ro->view) {
24
            $ro->toString();
25
        }
26
27
        // header
28
        foreach ($ro->headers as $label => $value) {
29
            header("{$label}: {$value}", false);
30
        }
31
32
        // code
33
        http_response_code($ro->code);
34
35
        // body
36
        echo $ro->view;
37
    }
38
}
39