Completed
Push — master ( 0501a9...9176f8 )
by Iman
13:27 queued 10:05
created

Response   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 14
dl 0
loc 56
ccs 21
cts 21
cp 1
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 assert() 0 3 1
A success() 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 17
    public function __construct($chain)
15
    {
16 17
        $this->chain = $chain;
17 17
    }
18
19 2
    public function redirect($url, $status = null)
20
    {
21 2
        $this->assert('assertRedirect', $url);
22
23 2
        if (!is_null($status)) {
24 2
            $this->assert('assertStatus', $status);
25
        }
26
27 2
        return $this;
28
    }
29
30 14
    public function statusCode($code)
31
    {
32 14
        $this->assert('assertStatus', $code);
33
34 14
        return $this;
35
    }
36
37 1
    public function success()
38
    {
39 1
        $this->assert('assertSuccessful', null);
40 1
    }
41
42 1
    public function withError($value)
43
    {
44 1
        $this->assert('assertSessionHasErrors', $value);
45
46 1
        return $this;
47
    }
48
49 9
    public function forbiddenStatus()
50
    {
51 9
        return $this->statusCode(403);
52
    }
53
54
    /**
55
     * @param $value
56
     * @param $assertion
57
     */
58 17
    private function assert($assertion, $value)
59
    {
60 17
        $this->chain->addAssertion($assertion, $value);
61 17
    }
62
}
63