Completed
Push — master ( c0eda5...1ea1f4 )
by Sergey
03:04
created

Request   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A promise() 0 3 1
A __construct() 0 4 1
A reject() 0 3 1
A resolve() 0 3 1
A command() 0 3 1
1
<?php
2
3
namespace seregazhuk\React\Memcached\Request;
4
5
use Exception;
6
use React\Promise\Deferred;
7
use React\Promise\Promise;
8
use React\Promise\PromiseInterface;
9
10
class Request
11
{
12
    /**
13
     * @var Deferred
14
     */
15
    private $deferred;
16
17
    /**
18
     * @var string
19
     */
20
    private $command;
21
22
    /**
23
     * @param string $command
24
     */
25
    public function __construct($command)
26
    {
27
        $this->deferred = new Deferred();
28
        $this->command = $command;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function command()
35
    {
36
        return $this->command;
37
    }
38
39
    /**
40
     * @return Promise|PromiseInterface
41
     */
42
    public function promise()
43
    {
44
        return $this->deferred->promise();
45
    }
46
47
    /**
48
     * @param mixed $value
49
     */
50
    public function resolve($value)
51
    {
52
        $this->deferred->resolve($value);
53
    }
54
55
    /**
56
     * @param Exception $exception
57
     */
58
    public function reject(Exception $exception)
59
    {
60
        $this->deferred->reject($exception);
61
    }
62
}
63