RuleViolationDetector::inspect()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace DependencyAnalyzer\Inspector;
3
4
use DependencyAnalyzer\Inspector\RuleViolationDetector\DependencyRule;
5
use DependencyAnalyzer\DependencyGraph;
6
use DependencyAnalyzer\Inspector\Responses\VerifyDependencyResponse;
7
8
class RuleViolationDetector
9
{
10
    /**
11
     * @var DependencyRule[]
12
     */
13
    protected $rules;
14
15
    /**
16
     * @param DependencyRule[] $rules
17
     */
18
    public function __construct(array $rules = [])
19
    {
20
        $this->rules = $rules;
21
    }
22
23
    /**
24
     * @param DependencyGraph $graph
25
     * @return VerifyDependencyResponse[]
26
     */
27
    public function inspect(DependencyGraph $graph): array
28
    {
29
        $verifyDependencyResponses = [];
30
        foreach ($this->rules as $rule) {
31
            $verifyDependencyResponses[] = $rule->isSatisfyBy($graph);
32
        }
33
34
        return $verifyDependencyResponses;
35
    }
36
}
37