Completed
Push — master ( 33dce2...bb9f86 )
by Iman
09:07
created

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