HasCommandsCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setCommandsCollection() 0 3 1
A newCommandsCollection() 0 3 1
A initCommandsCollection() 0 3 1
A getCommandsCollection() 0 6 2
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