Conditions | 6 |
Paths | 4 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
16 | public function process(File $file, $ptr): void |
||
17 | { |
||
18 | // File path sniffs and not saved using sniff code and their config |
||
19 | // is not processed. This is a workaround. |
||
20 | if (!$this->configured) { |
||
21 | $bits = explode('\\', get_class($this)); |
||
22 | $currentClass = end($bits); |
||
23 | |||
24 | $opts = []; |
||
25 | foreach ($file->ruleset->ruleset as $ref => $rule) { |
||
26 | $bits = explode('/', $ref); |
||
27 | $cfgClass = rtrim(end($bits), '.php'); |
||
28 | if ($currentClass === $cfgClass) { |
||
29 | $opts = $rule['properties']; |
||
30 | break; |
||
31 | } |
||
32 | } |
||
33 | |||
34 | array_walk_recursive($opts, function (&$val) { |
||
35 | if ('true' === $val) { |
||
36 | $val = true; |
||
37 | } elseif ('false' === $val) { |
||
38 | $val = false; |
||
39 | } |
||
40 | }); |
||
41 | |||
42 | $this->configure($opts); |
||
43 | $this->configured = true; |
||
44 | } |
||
45 | |||
46 | $this->run($file, $ptr); |
||
47 | } |
||
56 |