Completed
Push — master ( 6cffc0...1584cb )
by Iman
12:58 queued 09:45
created

HttpClient::whenEventHappens()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure;
4
5
class HttpClient
6
{
7
    public $app;
8
9
    private $chain;
10
11
    /**
12
     * HttpClient constructor.
13
     *
14
     * @param $phpunit
15
     */
16 38
    public function __construct($phpunit)
17
    {
18 38
        $this->chain = new Chain($phpunit);
19 38
    }
20
21 3
    public function sendingPostRequest($uri, array $data = [], array $headers = []): IsRespondedWith
22
    {
23 3
        $this->chain->http($uri, $data, $headers, 'post');
24
25 3
        return new IsRespondedWith($this->chain);
26
    }
27
28 1
    public function sendingJsonPostRequest($uri, array $data = [], array $headers = []): IsRespondedWith
29
    {
30 1
        $this->chain->http($uri, $data, $headers, 'postJson');
31
32 1
        return new IsRespondedWith($this->chain);
33
    }
34
35 2
    public function sendingDeleteRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
36
    {
37 2
        $this->chain->http($uri, $data, $headers, 'delete');
38
39 2
        return new IsRespondedWith($this->chain);
40
    }
41
42
    public function sendingJsonDeleteRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
43
    {
44
        $this->chain->http($uri, $data, $headers, 'deleteJson');
45
46
        return new IsRespondedWith($this->chain);
47
    }
48
49 1
    public function sendingPutRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
50
    {
51 1
        $this->chain->http($uri, $data, $headers, 'put');
52
53 1
        return new IsRespondedWith($this->chain);
54
    }
55
56 1
    public function sendingJsonPutRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
57
    {
58 1
        $this->chain->http($uri, $data, $headers, 'putJson');
59
60 1
        return new IsRespondedWith($this->chain);
61
    }
62
63 1
    public function sendingPatchRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
64
    {
65 1
        $this->chain->http($uri, $data, $headers, 'patch');
66
67 1
        return new IsRespondedWith($this->chain);
68
    }
69
70 1
    public function sendingJsonPatchRequest($uri, array $data = [], array $headers = []) : IsRespondedWith
71
    {
72 1
        $this->chain->http($uri, $data, $headers, 'patchJson');
73
74 1
        return new IsRespondedWith($this->chain);
75
    }
76
77 26
    public function sendingGetRequest($uri, array $headers = []): IsRespondedWith
78
    {
79 26
        $this->chain->http($uri, [], $headers, 'get');
80
81 26
        return new IsRespondedWith($this->chain);
82
    }
83
84 1
    public function sendingJsonGetRequest($uri, array $headers = []): IsRespondedWith
85
    {
86 1
        $this->chain->http($uri, [], $headers, 'getJson');
87
88 1
        return new IsRespondedWith($this->chain);
89
    }
90
91 1
    public function exceptionIsThrown($type)
92
    {
93 1
        $this->chain->exception = $type;
94 1
    }
95
96 1
    public function whenEventHappens($event)
97
    {
98 1
        $this->chain->event = $event;
99
100 1
        return $this;
101
    }
102
}
103