MakesDeferredPromisesTrait::createDeferred()   A
last analyzed

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
c 0
b 0
f 0
rs 10
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\Behavior\Async;
13
14
use Tidal\WampWatch\Async\DeferredInterface;
15
use Tidal\WampWatch\Async\Adapter\DeferredFactoryInterface;
16
use Tidal\WampWatch\Async\DefaultDeferredFactory;
17
use Tidal\WampWatch\Async\Adapter\PromiseFactoryInterface;
18
19
/**
20
 * Trait Tidal\WampWatch\Behavior\Async\MakesDeferredPromisesTrait.
21
 */
22
trait MakesDeferredPromisesTrait
23
{
24
    /**
25
     * @var DeferredFactoryInterface
26
     */
27
    private $deferredFactory;
28
29
    /**
30
     * @param callable|null $canceller
31
     *
32
     * @return DeferredInterface
33
     */
34
    protected function createDeferred(callable $canceller = null)
35
    {
36
        return $this->getDeferredFactory()->create($canceller);
37
    }
38
39
    /**
40
     * @param DeferredFactoryInterface $deferredFactory
41
     */
42
    public function setDeferredFactory($deferredFactory)
43
    {
44
        $this->deferredFactory = $deferredFactory;
45
    }
46
47
    /**
48
     * @return DeferredFactoryInterface
49
     */
50
    public function getDeferredFactory()
51
    {
52
        if (!isset($this->deferredFactory)) {
53
            $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...
54
                $this->getPromiseFactory()
55
            );
56
        }
57
58
        return $this->deferredFactory;
59
    }
60
61
    /**
62
     * Dependency on MakesPromisesTrait.
63
     *
64
     * @return PromiseFactoryInterface
65
     */
66
    abstract public function getPromiseFactory();
67
}
68