GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CommandQueueingDecorator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A execute() 0 9 2
1
<?php
2
3
namespace Chief\Decorators;
4
5
use Chief\Busses\SynchronousCommandBus;
6
use Chief\Command;
7
use Chief\CommandBus;
8
use Chief\CommandQueuer;
9
use Chief\Decorator;
10
use Chief\QueueableCommand;
11
12
/**
13
 * Queue commands which implement QueueableCommand into a CommandQueuer
14
 */
15
class CommandQueueingDecorator implements Decorator
16
{
17
    use InnerBusTrait;
18
19
    /**
20
     * @var \Chief\CommandQueuer
21
     */
22
    protected $queuer;
23
24
    /**
25
     * @param CommandQueuer $queuer
26
     * @param CommandBus $innerCommandBus
27
     */
28
    public function __construct(CommandQueuer $queuer, CommandBus $innerCommandBus = null)
29
    {
30
        $this->queuer = $queuer;
31
        $this->setInnerBus($innerCommandBus ?: new SynchronousCommandBus());
32
    }
33
34
    /**
35
     * Execute a command
36
     *
37
     * @param Command $command
38
     * @return void|mixed
39
     */
40
    public function execute(Command $command)
41
    {
42
        if ($command instanceof QueueableCommand) {
43
            $this->queuer->queue($command);
44
            return null;
45
        }
46
47
        return $this->innerCommandBus->execute($command);
48
    }
49
}
50