Completed
Push — master ( 35baa9...a350c4 )
by Timo
02:24
created

PromiseAdapter::progress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 *
4
 *  * This file is part of the Tidal/WampWatch package.
5
 *  * (c) 2016 Timo Michna <timomichna/yahoo.de>
6
 *  *
7
 *  * For the full copyright and license information, please view the LICENSE
8
 *  * file that was distributed with this source code.
9
 *
10
 */
11
12
namespace Tidal\WampWatch\Adapter\React;
13
14
use Tidal\WampWatch\Async\PromiseInterface;
15
use React\Promise\Promise;
16
17
18
class PromiseAdapter implements PromiseInterface
19
{
20
21
    /**
22
     * @var Promise
23
     */
24
    private $adaptee;
25
26
    /**
27
     * PromiseAdapter constructor.
28
     *
29
     * @param \React\Promise\Promise $adaptee
30
     */
31
    public function __construct(Promise $adaptee)
32
    {
33
        $this->setAdaptee($adaptee);
34
    }
35
36
    /**
37
     * @param \React\Promise\Promise $adaptee
38
     */
39
    private function setAdaptee(Promise $adaptee)
40
    {
41
        $this->adaptee = $adaptee;
42
    }
43
44
    /**
45
     * @return \React\Promise\Promise
46
     */
47
    public function getAdaptee()
48
    {
49
        return $this->adaptee;
50
    }
51
52
    /**
53
     * @param callable|null $onFulfilled
54
     * @param callable|null $onRejected
55
     * @param callable|null $onProgress
56
     *
57
     * @return self
58
     */
59
    public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
60
    {
61
        $this->adaptee->then($onFulfilled, $onRejected, $onProgress);
62
63
        return $this;
64
    }
65
66
    /**
67
     * @param callable|null $onFulfilled
68
     * @param callable|null $onRejected
69
     * @param callable|null $onProgress
70
     *
71
     * @return self
72
     */
73
    public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
74
    {
75
        $this->adaptee->done($onFulfilled, $onRejected, $onProgress);
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param callable $onRejected
82
     *
83
     * @return self
84
     */
85
    public function otherwise(callable $onRejected)
86
    {
87
        $this->adaptee->otherwise($onRejected);
88
89
        return $this;
90
    }
91
92
    /**
93
     * @param callable $onFulfilledOrRejected
94
     *
95
     * @return self
96
     */
97
    public function always(callable $onFulfilledOrRejected)
98
    {
99
        $this->adaptee->always($onFulfilledOrRejected);
100
101
        return $this;
102
    }
103
104
    /**
105
     * @param callable $onProgress
106
     *
107
     * @return self
108
     */
109
    public function progress(callable $onProgress)
110
    {
111
        $this->adaptee->progress($onProgress);
112
113
        return $this;
114
    }
115
}