Completed
Push — master ( 77d201...cbf774 )
by Tim
05:07
created

LoggerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 32
rs 10
c 1
b 0
f 0
ccs 0
cts 10
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createLoggers() 0 20 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Model\LoggerFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-cli-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Cli\Logger;
22
23
use Monolog\Logger;
24
use Psr\Log\LoggerInterface;
25
use TechDivision\Import\Utils\LoggerKeys;
26
use TechDivision\Import\ConfigurationInterface;
27
28
/**
29
 * The logger factory implementation.
30
 *
31
 * @author    Tim Wagner <[email protected]>
32
 * @copyright 2016 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/techdivision/import-cli-simple
35
 * @link      http://www.techdivision.com
36
 */
37
class LoggerFactory
38
{
39
40
    /**
41
     * Create's and return's the loggers to use.
42
     *
43
     * @param \TechDivision\Import\ConfigurationInterface $configuration The configuration with the data to create the loggers with
44
     * @param \Psr\Log\LoggerInterface                    $systemLogger  The Magento system logger instance
45
     *
46
     * @return array The array with the initialized loggers
47
     */
48
    public static function createLoggers(ConfigurationInterface $configuration, LoggerInterface $systemLogger)
49
    {
50
51
        // initialize the array for the loggers
52
        $loggers = array();
53
54
        // add it to the array
55
        $loggers[LoggerKeys::SYSTEM] = $systemLogger;
56
57
        // append the configured loggers or override the default one
58
        foreach ($configuration->getLoggers() as $loggerConfiguration) {
59
            // load the factory class that creates the logger instance
60
            $loggerFactory = $loggerConfiguration->getFactory();
61
            // create the logger instance and add it to the available loggers
62
            $loggers[$loggerConfiguration->getName()] = $loggerFactory::factory($configuration, $loggerConfiguration);
63
        }
64
65
        // return the array with the initialized loggers
66
        return $loggers;
67
    }
68
}
69