Php   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B match() 0 34 9
1
<?php
2
3
namespace Spinzar\Firewall\Middleware;
4
5
use Spinzar\Firewall\Abstracts\Middleware;
6
7
class Php extends Middleware
8
{
9
    public function match($pattern, $input)
10
    {
11
        $result = false;
12
13
        if (!is_array($input) && !is_string($input)) {
14
            return false;
15
        }
16
17
        if (!is_array($input)) {
18
            return (stripos($input, $pattern) === 0);
19
        }
20
21
        foreach ($input as $key => $value) {
22
            if (is_array($value)) {
23
                if (!$result = $this->match($pattern, $value)) {
24
                    continue;
25
                }
26
27
                break;
28
            }
29
30
            if (!$this->isInput($key)) {
31
                continue;
32
            }
33
34
            if (!$result = (stripos($value, $pattern) === 0)) {
35
                continue;
36
            }
37
38
            break;
39
        }
40
41
        return $result;
42
    }
43
}
44