DynamicContextProcessor   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A extract() 0 7 2
A setStdClass() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace Arquivei\LogAdapter\Processors;
4
5
use Monolog\Processor\ProcessorInterface;
6
use stdClass;
7
8
class DynamicContextProcessor implements ProcessorInterface
9
{
10
    private ?array $map;
11
    private ?stdClass $stdClass;
12
13
    public function __construct(?array $map = [], ?stdClass $stdClass = null)
14
    {
15
        $this->map = $map;
16
        $this->stdClass = $stdClass;
17
    }
18
19
    public function __invoke(array $records): array
20
    {
21
        return self::extract($records, $this->map, $this->stdClass);
0 ignored issues
show
Bug Best Practice introduced by
The method Arquivei\LogAdapter\Proc...extProcessor::extract() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        return self::/** @scrutinizer ignore-call */ extract($records, $this->map, $this->stdClass);
Loading history...
22
    }
23
24
    /**
25
     * @param stdClass|null $stdClass
26
     */
27
    public function setStdClass(?stdClass $stdClass): void
28
    {
29
        $this->stdClass = $stdClass;
30
    }
31
32
    private function extract(?array $records, ?array $map, ?stdClass $stdClass = null): array
0 ignored issues
show
Unused Code introduced by
The parameter $stdClass is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    private function extract(?array $records, ?array $map, /** @scrutinizer ignore-unused */ ?stdClass $stdClass = null): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        foreach ($map as $value) {
35
            eval($value . ";");
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
36
        }
37
38
        return $records;
39
    }
40
}
41