Completed
Pull Request — master (#57)
by Iman
12:24 queued 08:57
created

HttpClient::sendingPostRequest()   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 3
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 32
    public function __construct($app)
17
    {
18 32
        $this->chain = new Chain($app);
19 32
        $this->app = $app;
20 32
    }
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 25
    public function sendingGetRequest($url): IsRespondedWith
51
    {
52 25
        $this->chain->http = [
53 25
            'method' => 'get',
54 25
            'url'    => $url,
55
            'data'   => [],
56
        ];
57
58 25
        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
    public function whenYouReachCheckPoint($name)
74
    {
75
        return $this->whenEventHappens('heyman_checkpoint_'.$name);
76
    }
77
}
78