Completed
Push — master ( aea954...9f22d1 )
by Iman
1312:51 queued 1306:32
created

Response   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 84.21%

Importance

Changes 0
Metric Value
wmc 7
eloc 13
dl 0
loc 47
ccs 16
cts 19
cp 0.8421
rs 10
c 0
b 0
f 0

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