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

LoggerFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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
     * @return DataCollectorLoggerInterface
34
     */
35 3
    public function createLogger(): DataCollectorLoggerInterface
36
    {
37 3
        if ($this->environment === 'dev') {
38 2
            return new MongoLogger();
39
        }
40
41 1
        return new NullLogger();
42
    }
43
}
44