Request   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 11 1
1
<?php
2
3
namespace JulianoBailao\DomusApi\Core;
4
5
use GuzzleHttp\Client;
6
7
class Request
8
{
9
    /**
10
     * The client ai handle.
11
     *
12
     * @var mixed
13
     */
14
    protected $handler;
15
16
    /**
17
     * Create new Request instance.
18
     *
19
     * @param mixed $handler
20
     */
21 132
    public function __construct($handler)
22
    {
23 132
        $this->handler = $handler;
24 132
    }
25
26
    /**
27
     * Run the request.
28
     *
29
     * @param string $method
30
     * @param string $url
31
     * @param array  $data
32
     *
33
     * @return string
34
     */
35 132
    public function run($method, $url, array $data = [])
36
    {
37 132
        $client = new Client(['handler' => $this->handler]);
38
39 132
        return json_decode($client->request($method, $url, array_merge($data, [
40 132
            'Accept'       => 'application/json',
41 132
            'Content-Type' => 'application/json',
42 132
            'uSER-aGENT'   => 'JulianoBailao/DomusApi',
43 132
            'debug'        => true,
44 132
        ]))->getBody());
45
    }
46
}
47