Response   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 58
ccs 14
cts 22
cp 0.6364
rs 10
c 0
b 0
f 0

7 Methods

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