Completed
Pull Request — master (#8)
by Alessandro
06:57
created

LoggerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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
use Symfony\Component\Stopwatch\Stopwatch;
11
12
/**
13
 * Class LoggerFactory.
14
 */
15
class LoggerFactory
16
{
17
    /**
18
     * @var string
19
     */
20
    private $environment;
21
22
    /**
23
     * LoggerFactory constructor.
24
     *
25
     * @param string $environment
26
     */
27 3
    public function __construct(string $environment)
28
    {
29 3
        $this->environment = $environment;
30 3
    }
31
32
    /**
33
     * @param Stopwatch $stopwatch
34
     *
35
     * @return DataCollectorLoggerInterface
36
     */
37 3
    public function createLogger(Stopwatch $stopwatch): DataCollectorLoggerInterface
38
    {
39 3
        if ($this->environment === 'dev') {
40 2
            return new MongoLogger($stopwatch);
41
        }
42
43 1
        return new NullLogger();
44
    }
45
}
46