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

Response::statusCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
}