MakesDeferredPromisesTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createDeferred() 0 4 1
A setDeferredFactory() 0 4 1
A getDeferredFactory() 0 10 2
getPromiseFactory() 0 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