Completed
Push — 15.x ( b45baa...4ca9b4 )
by Tim
02:13
created

WrapperHandlerFactory::getHandlerFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Loggers\StreamHandlerFactory
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 TechDivision\Import\Loggers\Handlers\HandlerWrapper;
24
use TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface;
25
26
/**
27
 * Factory implementation that wraps other handler factories.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2019 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 */
35
class WrapperHandlerFactory implements HandlerFactoryInterface
36
{
37
38
    /**
39
     * The wrapped handler factory.
40
     *
41
     * @var \TechDivision\Import\Loggers\HandlerFactoryInterface
42
     */
43
    protected $handlerFactory;
44
45
    /**
46
     * Initialize the processor with the handler factory instance that has to be wrapped
47
     *
48
     * @param \TechDivision\Import\Loggers\HandlerFactoryInterface $handlerFactory The handler factory we want to wrap
49
     */
50
    public function __construct(HandlerFactoryInterface $handlerFactory)
51
    {
52
        $this->handlerFactory = $handlerFactory;
53
    }
54
55
    /**
56
     * Return's the wrapped handler factory.
57
     *
58
     * @return \TechDivision\Import\Loggers\HandlerFactoryInterface The wrapped handler factory
59
     */
60
    protected function getHandlerFactory()
61
    {
62
        return $this->handlerFactory;
63
    }
64
65
    /**
66
     * Creates a new formatter instance based on the passed configuration.
67
     *
68
     * @param \TechDivision\Import\Configuration\Logger\HandlerConfigurationInterface $handlerConfiguration The handler configuration
69
     *
70
     * @return \Monolog\Handler\HandlerInterface The handler instance
71
     */
72
    public function factory(HandlerConfigurationInterface $handlerConfiguration)
73
    {
74
75
        // create and return the wrapped handlerinstance
76
        $reflectionClass = new \ReflectionClass(HandlerWrapper::class);
77
        return $reflectionClass->newInstance($this->getHandlerFactory(), $handlerConfiguration);
78
    }
79
}
80