Filter   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 14
c 1
b 0
f 0
dl 0
loc 34
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addTreat() 0 3 1
A treat() 0 5 2
A check() 0 5 2
A addMessage() 0 4 1
A getMessage() 0 3 1
1
<?php
2
3
namespace HnrAzevedo\Filter;
4
5
class Filter{
6
    use CheckTrait;
7
    
8
    protected array $messages = [];
9
    protected array $treat = [];
10
11
    public function getMessage(string $filter): string
12
    {
13
        return strval($this->messages[$filter]);
14
    }
15
16
    public function check(string $filter): bool
17
    {
18
        $this->check_method($filter);
19
        $result = $this->$filter();
20
        return (is_bool($result)) ? $result : false;
21
    }
22
23
    protected function addMessage(string $filter, string $message): Filter
24
    {
25
        $this->messages[$filter] = $message;
26
        return $this;
27
    }
28
29
    protected function addTreat(string $filter, string $treat): void
30
    {
31
        $this->treat[$filter] = $treat;
32
    }
33
34
    protected function treat(string $filter): void
35
    {
36
        if(array_key_exists($filter,$this->treat)){
37
            $treat = $this->treat[$filter];
38
            $this->$treat();
39
        }
40
    }
41
42
}