Completed
Push — master ( b37109...89e4ea )
by Christian
02:03
created

AsyncHttpGenericService::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Lombardo
5
 * Date: 27/12/16
6
 * Time: 16:35
7
 */
8
9
namespace AsyncHttpClient\Service;
10
11
use React\HttpClient\Response;
12
13
class AsyncHttpGenericService implements AsyncHttpService
14
{
15
16
    /**
17
     * @var string
18
     */
19
    private $method;
20
21
    /**
22
     * @var string
23
     */
24
    private $url;
25
26
    /**
27
     * @var callable
28
     */
29
    private $callback;
30
31 1
    public function __construct($method, $url, callable $callback = null)
32
    {
33 1
        $this->method   = $method;
34 1
        $this->url      = $url;
35 1
        $this->callback = $callback;
36 1
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getMethod()
42
    {
43 1
        return $this->method;
44
    }
45
46
    /**
47
     * @return string
48
     */
49 1
    public function getUrl()
50
    {
51 1
        return $this->url;
52
    }
53
54
    /**
55
     * @param          $data
56
     * @param Response $response
57
     *
58
     * @return void
59
     */
60 1
    public function execute($data, Response $response)
61
    {
62 1
        if (!is_null($this->callback)) {
63 1
            $callback = $this->callback;
64 1
            $callback($data, $response);
65 1
        }
66
    }
67
}