Passed
Push — master ( 72dc09...0a81c1 )
by Iman
07:49
created

Response::addAssertion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure\Expectations;
4
5
use Imanghafoori\HeyMan\MakeSure\Chain;
6
7
class Response
8
{
9
    private $chain;
10
11
    /**
12
     * Response constructor.
13
     *
14
     * @param $chain
15
     */
16 19
    public function __construct(Chain $chain)
17
    {
18 19
        $this->chain = $chain;
19 19
    }
20
21 2
    public function redirect($url, $status = null)
22
    {
23 2
        $this->addAssertion('assertRedirect', $url);
24
25 2
        if (!is_null($status)) {
26 2
            $this->statusCode($status);
27
        }
28
29 2
        return $this;
30
    }
31
32 17
    public function statusCode($code)
33
    {
34 17
        $this->addAssertion('assertStatus', $code);
35
36 17
        return $this;
37
    }
38
39 2
    public function success()
40
    {
41 2
        $this->addAssertion('assertSuccessful');
42 2
    }
43
44 1
    public function withError($value)
45
    {
46 1
        $this->addAssertion('assertSessionHasErrors', $value);
47
48 1
        return $this;
49
    }
50
51 9
    public function forbiddenStatus()
52
    {
53 9
        return $this->statusCode(403);
54
    }
55
56
    /**
57
     * @param $value
58
     * @param $type
59
     */
60
    public function addAssertion($type, $value = null)
61
    {
62
        $this->chain->data['assertion'][] = [$type, $value];
63
    }
64
}
65