Passed
Push — master ( c45116...86df6f )
by Iman
06:48
created

HttpClient::sendingJsonDeleteRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A HttpClient::exceptionIsThrown() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\MakeSure;
4
5
class HttpClient
6
{
7
    private $chain;
8
9
    private $methods = [
10
        'sendingPostRequest' => 'post',
11
        'sendingJsonPostRequest' => 'postJson',
12
        'sendingDeleteRequest' => 'delete',
13
        'sendingJsonDeleteRequest' => 'deleteJson',
14
        'sendingPutRequest' => 'put',
15
        'sendingJsonPutRequest' => 'putJson',
16 38
        'sendingPatchRequest' => 'patch',
17
        'sendingJsonPatchRequest' => 'patchJson',
18 38
        'sendingGetRequest' => 'get',
19 38
        'sendingJsonGetRequest' => 'getJson',
20
    ];
21 3
22
    /**
23 3
     * HttpClient constructor.
24
     *
25 3
     * @param $phpunit
26
     */
27
    public function __construct($phpunit)
28 1
    {
29
        $this->chain = new Chain($phpunit);
30 1
    }
31
32 1
    public function __call($method, $params)
33
    {
34
        return $this->sendRequest($method, ...$params);
35 2
    }
36
37 2
    public function sendRequest($method, ...$data): IsRespondedWith
38
    {
39 2
        $this->chain->http($this->methods[$method], ...$data);
40
41
        return new IsRespondedWith($this->chain);
42
    }
43
44
    public function exceptionIsThrown($type)
45
    {
46
        $this->chain->data['exception'] = $type;
47
    }
48
49 1
    public function whenEventHappens($event)
50
    {
51 1
        $this->chain->data['event'] = $event;
52
53 1
        return $this;
54
    }
55
}