HasCommandsCollection::newCommandsCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Nip\Dispatcher\Traits;
4
5
use Nip\Dispatcher\Commands\CommandsCollection;
6
7
/**
8
 * Trait HasCommandsCollection
9
 * @package Nip\Dispatcher\Traits
10
 */
11
trait HasCommandsCollection
12
{
13
    protected $commandsCollection = null;
14
15
    /**
16
     * @return mixed
17
     */
18 3
    public function getCommandsCollection()
19
    {
20 3
        if ($this->commandsCollection === null) {
21 3
            $this->initCommandsCollection();
22
        }
23 3
        return $this->commandsCollection;
24
    }
25
26
    /**
27
     * @param mixed $commandsCollection
28
     */
29 3
    public function setCommandsCollection($commandsCollection)
30
    {
31 3
        $this->commandsCollection = $commandsCollection;
32 3
    }
33
34 3
    protected function initCommandsCollection()
35
    {
36 3
        $this->setCommandsCollection($this->newCommandsCollection());
37 3
    }
38
39
    /**
40
     * @return CommandsCollection
41
     */
42 3
    protected function newCommandsCollection()
43
    {
44 3
        return new CommandsCollection();
45
    }
46
}
47