Passed
Push — master ( 4f6f8e...2905b8 )
by Cesar
01:59
created

AbstractProcessor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addExtension() 0 3 1
A setFilenameSource() 0 5 1
A __construct() 0 3 1
A processed() 0 3 2
A removeExtension() 0 3 1
1
<?php
2
3
namespace Cesargb\Log\Processors;
4
5
abstract class AbstractProcessor
6
{
7
    protected string $filenameSource;
8
9
    protected string $extension = '';
10
11
    abstract public function handler(string $filename): ?string;
12
13
    public function __construct()
14
    {
15
        clearstatcache();
16
    }
17
18
    public function addExtension(string $extension): void
19
    {
20
        $this->extension = '.'.$extension;
21
    }
22
23
    public function removeExtension(string $extension): void
24
    {
25
        $this->extension = str_replace('.'.$extension, '', $this->extension);
26
    }
27
28
    public function setFilenameSource(string $filenameSource): self
29
    {
30
        $this->filenameSource = $filenameSource;
31
32
        return $this;
33
    }
34
35
    protected function processed(string $filename): ?string
36
    {
37
        return is_file($filename) ? $filename : null;
38
    }
39
}
40