Completed
Push — master ( b5c840...3d5461 )
by Marcus
04:46
created

LineFormatterFactory::factory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Loggers\LineFormatterFactory
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 2019 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
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Loggers;
22
23
use Monolog\Formatter\LineFormatter;
24
use TechDivision\Import\Utils\ConfigurationUtil;
25
use TechDivision\Import\Configuration\Logger\FormatterConfigurationInterface;
26
27
/**
28
 * Line Formatter factory implementation.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2019 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/techdivision/import
34
 * @link      http://www.techdivision.com
35
 */
36
class LineFormatterFactory implements FormatterFactoryInterface
37
{
38
39
    /**
40
     * Creates a new formatter instance based on the passed configuration.
41
     *
42
     * @param \TechDivision\Import\Configuration\Logger\FormatterConfigurationInterface $formatterConfiguration The formatter configuration
43
     *
44
     * @return object The formatter instance
45
     */
46
    public function factory(FormatterConfigurationInterface $formatterConfiguration)
47
    {
48
        $reflectionClass = new \ReflectionClass(LineFormatter::class);
49
        return $reflectionClass->newInstanceArgs(ConfigurationUtil::prepareConstructorArgs($reflectionClass, $formatterConfiguration->getParams()));
50
    }
51
}
52