Completed
Pull Request — master (#8)
by Alessandro
06:32
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
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