CounterProcessor   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 1
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Logger
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Logger\Processor;
16
17
use Phossa2\Logger\Entry\LogEntryInterface;
18
19
/**
20
 * CounterProcessor
21
 *
22
 * Store a counter in context. Mostly for testing purpose.
23
 *
24
 * @package Phossa2\Logger
25
 * @author  Hong Zhang <[email protected]>
26
 * @see     ProcessorAbstract
27
 * @version 2.0.0
28
 * @since   2.0.0 added
29
 */
30
class CounterProcessor extends ProcessorAbstract
31
{
32
    /**
33
     * @var    int
34
     * @access protected
35
     */
36
    protected static $counter = 0;
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function __invoke(LogEntryInterface $logEntry)
42
    {
43
        $context = $logEntry->getContext();
44
        $context['counter'] = ++static::$counter;
45
        $logEntry->setContext($context);
46
    }
47
}
48