Passed
Push — master ( d5b9c5...238a05 )
by Timo
26s
created

PromiseFactory::createFromAdaptee()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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\Adapter\PromiseFactoryInterface;
15
use React\Promise\Promise as ReactPromise;
16
17
class PromiseFactory implements PromiseFactoryInterface
18
{
19
    /**
20
     * @param callable      $resolver
21
     * @param callable|null $canceller
22
     *
23
     * @return PromiseAdapter
24
     */
25
    public function create(callable $resolver, callable $canceller = null)
26
    {
27
        return $this->createFromAdaptee(
28
            new ReactPromise(
29
                $resolver,
30
                $canceller
31
            )
32
        );
33
    }
34
35
    /**
36
     * @param ReactPromise $adaptee
37
     *
38
     * @return PromiseAdapter
39
     */
40
    public function createFromAdaptee($adaptee)
41
    {
42
        return new PromiseAdapter($adaptee);
43
    }
44
}
45