Response   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 54
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A statusCode() 0 4 1
A reasonPhrase() 0 4 1
A assertHtml() 0 4 1
1
<?php
2
3
namespace Psr7Unitesting;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
/**
8
 * Class to execute assertions with a ResponseInterface instance.
9
 */
10
class Response extends Message
11
{
12
    /**
13
     * @var ResponseInterface
14
     */
15
    protected $message;
16
17
    /**
18
     * Constructor.
19
     *
20
     * @param ResponseInterface   $message
21
     * @param AbstractAssert|null $previous
22
     */
23
    public function __construct(ResponseInterface $message, Utils\AbstractAssert $previous = null)
24
    {
25
        parent::__construct($message, $previous);
26
    }
27
28
    /**
29
     * Asserts the status code of the response.
30
     *
31
     * @param int    $code
32
     * @param string $message
33
     *
34
     * @return self
35
     */
36
    public function statusCode($code, $message = '')
37
    {
38
        return $this->assert($this->message, new Response\StatusCode($code), $message);
39
    }
40
41
    /**
42
     * Asserts the reason phrase.
43
     *
44
     * @param string $reasonPhrase
45
     * @param string $message
46
     *
47
     * @return self
48
     */
49
    public function reasonPhrase($reasonPhrase, $message = '')
50
    {
51
        return $this->assert($this->message, new Response\ReasonPhrase($reasonPhrase), $message);
52
    }
53
54
    /**
55
     * Creates an instance of Html to execute assertions with the html code.
56
     *
57
     * @return Html
58
     */
59
    public function assertHtml()
60
    {
61
        return new Html($this->message->getBody(), $this);
62
    }
63
}
64