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

HttpResponder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 3
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