Completed
Branch master (a3fffb)
by Hong
33:51 queued 28:35
created

ProcessorAbstract::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Phoole (PHP7.2+)
5
 *
6
 * @category  Library
7
 * @package   Phoole\Logger
8
 * @copyright Copyright (c) 2019 Hong Zhang
9
 */
10
declare(strict_types=1);
11
12
namespace Phoole\Logger\Processor;
13
14
use Phoole\Logger\Entry\LogEntryInterface;
15
16
/**
17
 * ProcessorAbstract
18
 *
19
 * @package Phoole\Logger
20
 */
21
abstract class ProcessorAbstract
22
{
23
    /**
24
     * make it an invokable
25
     *
26
     * @param  LogEntryInterface $entry
27
     */
28
    public function __invoke(LogEntryInterface $entry)
29
    {
30
        $context = $entry->getContext();
31
        $entry->setContext($this->updateContext($context));
32
    }
33
34
    /**
35
     * update info in the $context
36
     *
37
     * ```php
38
     * protected function updateContext(array $context): array
39
     * {
40
     *     $context['bingo'] = 'wow';
41
     *     return $context;
42
     * }
43
     * ```
44
     *
45
     * @param  array $context
46
     * @return array
47
     */
48
    abstract protected function updateContext(array $context): array;
49
}