TasksBag::addTask()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
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