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

RemoveRootPrefixProcessor::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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