Passed
Push — master ( b45126...8af3f1 )
by 世昌
03:18
created

HtmlContentWrapper::getWrappedContent()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
namespace suda\framework\response\wrapper;
3
4
use function is_object;
5
use suda\framework\Response;
6
use suda\framework\http\Stream;
7
use suda\framework\http\stream\StringStream;
8
use suda\framework\response\AbstractContentWrapper;
9
10
/**
11
 * 响应包装器
12
 */
13
class HtmlContentWrapper extends AbstractContentWrapper
14
{
15
    /**
16
     * 获取内容
17
     *
18
     * @param Response $response
19
     * @return Stream
20
     */
21
    public function getWrappedContent(Response $response): Stream
22
    {
23
        $response->setType('html');
24
        if (is_object($this->content)) {
25
            if ($this->content instanceof Stream) {
26
                return $this->content;
27
            }
28
        }
29
        return new StringStream($this->content);
30
    }
31
}
32