Completed
Push — master ( 82b31e...62eba7 )
by Márk
06:10 queued 02:58
created

ResponseDecorator::withStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Http\Message\Decorator;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * @author Márk Sági-Kazár <[email protected]>
9
 */
10
trait ResponseDecorator
11
{
12
    use MessageDecorator {
13
        getMessage as getResponse;
14
    }
15
16
    /**
17
     * Exchanges the underlying response with another.
18
     *
19
     * @param ResponseInterface $response
20
     *
21
     * @return self
22
     */
23 1
    public function withResponse(ResponseInterface $response)
24
    {
25 1
        $new = clone $this;
26 1
        $new->message = $response;
27
28 1
        return $new;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function getStatusCode()
35
    {
36 1
        return $this->message->getStatusCode();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function withStatus($code, $reasonPhrase = '')
43
    {
44 1
        $new = clone $this;
45 1
        $new->message = $this->message->withStatus($code, $reasonPhrase);
46
47 1
        return $new;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    public function getReasonPhrase()
54
    {
55 1
        return $this->message->getReasonPhrase();
56
    }
57
}
58