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

PromiseFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A createFromAdaptee() 0 4 1
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