Completed
Pull Request — master (#8)
by Alessandro
02:54
created

LoggerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
ccs 6
cts 7
cp 0.8571
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createLogger() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Services;
6
7
use Facile\MongoDbBundle\Services\Loggers\DataCollectorLoggerInterface;
8
use Facile\MongoDbBundle\Services\Loggers\MongoLogger;
9
use Facile\MongoDbBundle\Services\Loggers\NullLogger;
10
11
/**
12
 * Class LoggerFactory.
13
 */
14
class LoggerFactory
15
{
16
    /**
17
     * @var string
18
     */
19
    private $environment;
20
21
    /**
22
     * LoggerFactory constructor.
23
     *
24
     * @param string $environment
25
     */
26 2
    public function __construct(string $environment)
27
    {
28 2
        $this->environment = $environment;
29 2
    }
30
31
    /**
32
     * @return DataCollectorLoggerInterface
33
     */
34 2
    public function createLogger(): DataCollectorLoggerInterface
35
    {
36 2
        if ($this->environment === 'dev') {
37 2
            return new MongoLogger();
38
        }
39
40
        return new NullLogger();
41
    }
42
}
43