Passed
Pull Request — master (#11)
by Joao
01:36
created

MockOutputProcessor::getDetailedErrorHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ByJG\RestServer\OutputProcessor;
4
5
use ByJG\RestServer\HttpResponse;
6
use ByJG\Serializer\Formatter\FormatterInterface;
7
use Whoops\Handler\Handler;
8
9
class MockOutputProcessor extends BaseOutputProcessor
10
{
11
    /**
12
     * @var OutputProcessorInterface
13
     */
14
    protected $originalOutputProcessor;
15
16
    public function __construct($class)
17
    {
18
        $this->originalOutputProcessor = new $class();
19
    }
20
21
    protected function writeHeader(HttpResponse $response)
22
    {
23
        echo "HTTP/1.1 " . $response->getResponseCode() . "\r\n";
24
        echo "Content-Type: " . $this->getContentType() . "\r\n";
25
26
        foreach ($response->getHeaders() as $header) {
27
            if (is_array($header)) {
28
                echo "${header[0]}: ${header[1]}\n";
29
                continue;
30
            }
31
            echo "$header\n";
32
        }
33
34
        echo "\r\n";
35
    }
36
37
    public function getContentType()
38
    {
39
        return $this->originalOutputProcessor->getContentType();
40
    }
41
42
43
    /**
44
     * @return void
45
     */
46
    public function writeContentType()
47
    {
48
        // Do nothing;
49
    }
50
51
52
    /**
53
     * @return Handler
54
     */
55
    public function getDetailedErrorHandler()
56
    {
57
        return $this->originalOutputProcessor->getDetailedErrorHandler();
58
    }
59
60
    /**
61
     * @return Handler
62
     */
63
    public function getErrorHandler()
64
    {
65
        return $this->originalOutputProcessor->getErrorHandler();
66
    }
67
68
69
    /**
70
     * @return FormatterInterface
71
     */
72
    public function getFormatter()
73
    {
74
        return $this->originalOutputProcessor->getFormatter();
75
    }
76
}
77