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

JsonContentWrapper::getContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace suda\framework\response\wrapper;
3
4
use function json_encode;
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 JsonContentWrapper 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('json');
24
        return new StringStream(json_encode($this->content));
25
    }
26
}
27