Completed
Pull Request — master (#57)
by Iman
12:24 queued 08:57
created

Response   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 8
eloc 14
dl 0
loc 56
ccs 18
cts 21
cp 0.8571
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A statusCode() 0 5 1
A forbiddenStatus() 0 3 1
A __construct() 0 3 1
A withError() 0 5 1
A redirect() 0 9 2
A success() 0 3 1
A assert() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure\Expectations;
4
5
class Response
6
{
7
    private $chain;
8
9
    /**
10
     * Response constructor.
11
     *
12
     * @param $chain
13
     */
14 15
    public function __construct($chain)
15
    {
16 15
        $this->chain = $chain;
17 15
    }
18
19 2
    public function redirect($url, $status = null)
20
    {
21 2
        $this->assert($url, 'assertRedirect');
22
23 2
        if (!is_null($status)) {
24 2
            $this->assert($status, 'assertStatus');
25
        }
26
27 2
        return $this;
28
    }
29
30 13
    public function statusCode($code)
31
    {
32 13
        $this->assert($code, 'assertStatus');
33
34 13
        return $this;
35
    }
36
37
    public function success()
38
    {
39
        $this->assert(null, 'assertSuccessful');
40
    }
41
42 1
    public function withError($value)
43
    {
44 1
        $this->assert($value, 'assertSessionHasErrors');
45
46 1
        return $this;
47
    }
48
49 8
    public function forbiddenStatus()
50
    {
51 8
        return $this->statusCode(403);
52
    }
53
54
    /**
55
     * @param $url
56
     * @param $str
57
     */
58 15
    private function assert($url, $str)
59
    {
60 15
        $this->chain->assertion[] = ['type' => $str, 'value' => $url];
61 15
    }
62
}
63