Test Failed
Push — master ( 4321c6...27997e )
by Constantin
05:35
created

ScheduledCommandsDispatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A run() 0 8 1
1
<?php
2
/******************************************************************************
3
 * Copyright (c) 2016 Constantin Galbenu <[email protected]>             *
4
 ******************************************************************************/
5
6
namespace Gica\Cqrs\Scheduling;
7
8
9
use Gica\Cqrs\Command\CommandDispatcher;
10
use Gica\Cqrs\ScheduledCommandStore;
11
12
class ScheduledCommandsDispatcher
13
{
14
    /**
15
     * @var ScheduledCommandStore
16
     */
17
    private $store;
18
    /**
19
     * @var CommandDispatcher
20
     */
21
    private $dispatcher;
22
23
    public function __construct(
24
        ScheduledCommandStore $store,
25
        CommandDispatcher $dispatcher
26
    )
27
    {
28
        $this->store = $store;
29
        $this->dispatcher = $dispatcher;
30
    }
31
32
    public function run()
33
    {
34
        $this->store->loadAndProcessScheduledCommands(function (ScheduledCommand $scheduledCommand) {
35
36
            $this->dispatcher->dispatchCommand($scheduledCommand);
37
38
        });
39
    }
40
}