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

WrapperHandlerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 45
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getHandlerFactory() 0 4 1
A factory() 0 7 1
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