NullFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A __invoke() 0 9 1
1
<?php
2
namespace Germania\NullFactory;
3
4
use Psr\Log\LoggerInterface;
5
use Psr\Log\LoggerAwareTrait;
6
use Psr\Log\NullLogger;
7
8
class NullFactory
9
{
10
11
    use LoggerAwareTrait;
12
13
    public $default_return = null;
14
15 35
    public function __construct( $default_return = null, LoggerInterface $logger = null )
16
    {
17 35
        $this->default_return = $default_return;
18 35
        $this->setLogger( $logger ?: new NullLogger );
19 35
    }
20
21
22 35
    public function __invoke()
23
    {
24 35
        $this->logger->debug("NullFactory", [
25 35
            'num_args' => func_num_args(),
26 35
            'return_value' => $this->default_return
27 7
        ]);
28
29 35
        return $this->default_return;
30
    }
31
}
32