Completed
Push — master ( d44a4d...4aa695 )
by Iman
09:02
created

HttpClient::exceptionIsThrown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure;
4
5
class HttpClient
6
{
7
    public $http = [];
8
9
    public $assertion;
10
11
    public $app;
12
13
    public $event;
14
15
    public $exception;
16
17
    /**
18
     * HttpClient constructor.
19
     *
20
     * @param $app
21
     */
22
    public function __construct($app)
23
    {
24
        $this->app = $app;
25
    }
26
27
    public function sendingPostRequest($url, $data = []): IsRespondedWith
28
    {
29
        $this->http = [
30
            'method' => 'post',
31
            'url' => $url,
32
            'data' => $data
33
        ];
34
35
        return new IsRespondedWith($this);
36
    }
37
38
    public function sendingGetRequest($url): IsRespondedWith
39
    {
40
        $this->http = [
41
            'method' => 'get',
42
            'url' => $url,
43
            'data' => [],
44
        ];
45
46
        return new IsRespondedWith($this);
47
    }
48
49
    public function exceptionIsThrown($type)
50
    {
51
        $this->exception = $type;
52
    }
53
54
    public function whenEventHappens($event)
55
    {
56
        $this->event = $event;
57
        return $this;
58
    }
59
60
    public function __destruct()
61
    {
62
        (new CheckExpectations($this))->check();
63
    }
64
}