Completed
Push — master ( d44a4d...4aa695 )
by Iman
09:02
created

Response   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 13
dl 0
loc 45
rs 10
c 0
b 0
f 0

6 Methods

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