Completed
Pull Request — master (#62)
by Timo
06:19
created

MakesDeferredPromisesTrait::getDeferredFactory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
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\Behavior\Async;
11
12
use Tidal\WampWatch\Async\DeferredInterface;
13
use Tidal\WampWatch\Async\Adapter\DeferredFactoryInterface;
14
use Tidal\WampWatch\Async\DefaultDeferredFactory;
15
use Tidal\WampWatch\Async\Adapter\PromiseFactoryInterface;
16
17
/**
18
 * Trait Tidal\WampWatch\Behavior\Async\MakesDeferredPromisesTrait *
19
 */
20
trait MakesDeferredPromisesTrait
21
{
22
23
    /**
24
     * @var DeferredFactoryInterface
25
     */
26
    private $deferredFactory;
27
28
    /**
29
     * @param callable|null $canceller
30
     *
31
     * @return DeferredInterface
32
     */
33
    protected function createDeferred(callable $canceller = null)
34
    {
35
        return $this->getDeferredFactory()->create($canceller);
36
    }
37
38
    /**
39
     * @param DeferredFactoryInterface $deferredFactory
40
     */
41
    public function setDeferredFactory($deferredFactory)
42
    {
43
        $this->deferredFactory = $deferredFactory;
44
    }
45
46
    /**
47
     * @return DeferredFactoryInterface
48
     */
49
    public function getDeferredFactory()
50
    {
51
        if (!isset($this->deferredFactory)) {
52
            $this->deferredFactory = new DefaultDeferredFactory(
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Tidal\WampWatch\Asy...s->getPromiseFactory()) of type object<Tidal\WampWatch\A...DefaultDeferredFactory> is incompatible with the declared type object<Tidal\WampWatch\A...ferredFactoryInterface> of property $deferredFactory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
                $this->getPromiseFactory()
54
            );
55
        }
56
57
        return $this->deferredFactory;
58
    }
59
60
    /**
61
     * Dependency on MakesPromisesTrait
62
     *
63
     * @return PromiseFactoryInterface
64
     */
65
    abstract public function getPromiseFactory();
66
}
67