Passed
Pull Request — develop (#31)
by Kevin
02:34
created

getConfigurationFactory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace Magium\Configuration\Console\Command;
4
5
use Magium\Configuration\MagiumConfigurationFactory;
6
use Magium\Configuration\MagiumConfigurationFactoryInterface;
7
8
trait ConfigurationFactoryTrait
9
{
10
11 12
    public function setConfigurationFactory(MagiumConfigurationFactoryInterface $factory)
12
    {
13 12
        $this->factory = $factory;
0 ignored issues
show
Bug introduced by
The property factory does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14 12
    }
15
16 12
    protected function getConfigurationFactory()
17
    {
18 12
        if (!$this->factory instanceof MagiumConfigurationFactoryInterface) {
19
            $this->factory = new MagiumConfigurationFactory();
20
        }
21 12
        return $this->factory;
22
    }
23
}
24