Completed
Pull Request — master (#55)
by Timo
02:47
created

PromiseFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
/**
3
 * This file is part of the Tidal/WampWatch package.
4
 *  (c) 2016 Timo Michna <timomichna/yahoo.de>.
5
 *
6
 *  For the full copyright and license information, please view the LICENSE
7
 *  file that was distributed with this source code.
8
 */
9
10
namespace Tidal\WampWatch\Adapter\React;
11
12
use Tidal\WampWatch\Async\Adapter\PromiseFactoryInterface;
13
use React\Promise\Promise as ReactPromise;
14
15
class PromiseFactory implements PromiseFactoryInterface
16
{
17
    /**
18
     * @param callable      $resolver
19
     * @param callable|null $canceller
20
     *
21
     * @return PromiseAdapter
22
     */
23
    public function create(callable $resolver, callable $canceller = null)
24
    {
25
        return $this->createFromAdaptee(
26
            new ReactPromise(
27
                $resolver,
28
                $canceller
29
            )
30
        );
31
    }
32
33
    /**
34
     * @param ReactPromise $adaptee
35
     *
36
     * @return PromiseAdapter
37
     */
38
    public function createFromAdaptee($adaptee)
39
    {
40
        return new PromiseAdapter($adaptee);
41
    }
42
}
43