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

AsyncHttpGenericService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 55
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getMethod() 0 4 1
A getUrl() 0 4 1
A execute() 0 7 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
}