Completed
Push — master ( 53c325...333209 )
by Iman
07:33 queued 04:14
created

HttpClient::exceptionIsThrown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
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 $app
15
     */
16 33
    public function __construct($app)
17
    {
18 33
        $this->chain = new Chain($app);
19 33
        $this->app = $app;
20 33
    }
21
22 3
    public function sendingPostRequest($uri, array $data = [], array $headers = []): IsRespondedWith
23
    {
24 3
        $this->chain->http($uri, $data, $headers, 'post');
25
26 3
        return new IsRespondedWith($this->chain);
27
    }
28
29 1
    public function sendingDeleteRequest($uri, array $data = [], array $headers = [])
30
    {
31 1
        $this->chain->http($uri, $data, $headers, 'delete');
32
33 1
        return new IsRespondedWith($this->chain);
34
    }
35
36 1
    public function sendingPutRequest($uri, array $data = [], array $headers = [])
37
    {
38 1
        $this->chain->http($uri, $data, $headers, 'put');
39
40 1
        return new IsRespondedWith($this->chain);
41
    }
42
43 1
    public function sendingPatchRequest($uri, array $data = [], array $headers = [])
44
    {
45 1
        $this->chain->http($uri, $data, $headers, 'patch');
46
47 1
        return new IsRespondedWith($this->chain);
48
    }
49
50 26
    public function sendingGetRequest($url): IsRespondedWith
51
    {
52 26
        $this->chain->http = [
53 26
            'method' => 'get',
54 26
            'url'    => $url,
55
            'data'   => [],
56
        ];
57
58 26
        return new IsRespondedWith($this->chain);
59
    }
60
61 1
    public function exceptionIsThrown($type)
62
    {
63 1
        $this->chain->exception = $type;
64 1
    }
65
66 1
    public function whenEventHappens($event)
67
    {
68 1
        $this->chain->event = $event;
69
70 1
        return $this;
71
    }
72
}
73