Passed
Push — main ( 21a5e3...5e30dc )
by Sammy
01:44
created

Traitor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 18
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A traitor() 0 16 4
1
<?php
2
3
namespace HexMakina\Traitor;
4
5
trait Traitor
6
{
7
    public function traitor($method_name)
8
    {
9
        $regex = sprintf('/.+Traitor_%s$/', $method_name);
10
        $errors = [];
11
        $traits = (new \ReflectionClass($this))->getTraitNames();
12
13
        foreach ($traits as $trait_name) {
14
            $trait_methods = (new \ReflectionClass($trait_name))->getMethods();
15
            foreach ($trait_methods as $method) {
16
                if (preg_match($regex, $method->name, $match) === 1) {
17
                    $callable = current($match);
18
                    $errors ["$trait_name::" . $method->name] = $this->$callable();
19
                }
20
            }
21
        }
22
        return $errors;
23
    }
24
}
25