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

SerialProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Loggers\SerialProcessor
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\Processor\ProcessorInterface;
24
use TechDivision\Import\ConfigurationInterface;
25
26
/**
27
 * Serial processor implementation.
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 SerialProcessor implements ProcessorInterface
36
{
37
38
    /**
39
     * The serial of the actual import process.
40
     *
41
     * @var string
42
     */
43
    protected $serial;
44
45
    /**
46
     * Initialize the processor with the serial of the actual import process.
47
     *
48
     * @param \TechDivision\Import\ConfigurationInterface $configuration The serial of the actual import process
49
     */
50
    public function __construct(ConfigurationInterface $configuration)
51
    {
52
        $this->serial = $configuration->getSerial();
53
    }
54
55
    /**
56
     * Will be invoked by the logger processor chain to append the serial.
57
     *
58
     * @param  array $record The record to append the serial to
59
     *
60
     * @return array The record with the appended serial
61
     */
62
    public function __invoke(array $record)
63
    {
64
        return array_merge($record, array('extra' => array('serial' => $this->serial)));
65
    }
66
}
67