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

JsonContentWrapper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getWrappedContent() 0 4 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