Test Failed
Pull Request — master (#3)
by
unknown
18:49
created

RemoveRootPrefixProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A __invoke() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paysera\LoggingExtraBundle\Service\Processor;
6
7
use Monolog\Processor\ProcessorInterface;
8
use InvalidArgumentException;
9
10
class RemoveRootPrefixProcessor implements ProcessorInterface
11
{
12
    private $rootPrefix;
13
14
    public function __construct(string $rootPrefix)
15
    {
16
        $this->rootPrefix = realpath($rootPrefix);
17
        if ($this->rootPrefix === false) {
18
            throw new InvalidArgumentException('Invalid root prefix specified');
19
        }
20
    }
21
22
    public function __invoke(array $record)
23
    {
24
        $record['message'] = str_replace($this->rootPrefix, '<root>', $record['message']);
25
26
        return $record;
27
    }
28
}
29