Queue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A push() 0 4 1
A execute() 0 5 2
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
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 Hal\Application\Command\Job;
11
use Hal\Component\Result\ResultCollection;
12
13
/**
14
 * Template sequence
15
 *
16
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
17
 */
18
class Queue implements JobInterface
19
{
20
21
    /**
22
     * Jobs
23
     *
24
     * @var \SplQueue
25
     */
26
    private $jobs;
27
28
    /**
29
     * Constructor
30
     */
31
    public function __construct() {
32
        $this->jobs = new \SplQueue();
33
    }
34
35
    /**
36
     * Push in queue
37
     *
38
     * @param JobInterface $command
39
     * @return $this
40
     */
41
    public function push(JobInterface $command) {
42
        $this->jobs->push($command);
43
        return $this;
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) {
50
        foreach($this->jobs as $job) {
51
            $job->execute($collection, $aggregatedResults);
52
        }
53
    }
54
55
}
56