TasksBag   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addTask() 0 7 2
A getTasks() 0 6 1
1
<?php
2
3
namespace Dekalee\NightlyTaskBundle\Bag;
4
5
use Symfony\Component\Console\Command\Command;
6
7
/**
8
 * Class TasksBag
9
 */
10
class TasksBag
11
{
12
    protected $tasks = [];
13
14
    /**
15
     * @param Command $task
16
     * @param int     $priority
17
     */
18 1
    public function addTask(Command $task, $priority)
19
    {
20 1
        if (!array_key_exists($priority, $this->tasks)) {
21 1
            $this->tasks[$priority] = [];
22
        }
23 1
        $this->tasks[$priority][] = $task;
24 1
    }
25
26
    /**
27
     * @return array
28
     */
29 1
    public function getTasks()
30
    {
31 1
        krsort($this->tasks, SORT_NUMERIC);
32
33 1
        return $this->tasks;
34
    }
35
}
36