ContextSupportedVoters   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A register() 0 4 1
A vote() 0 14 4
1
<?php
2
3
namespace Behatch\HttpCall;
4
5
class ContextSupportedVoters implements ContextSupportedVoter
6
{
7
    private $voters;
8
9
    public function __construct(array $voters = array())
10
    {
11
        foreach ($voters as $voter) {
12
            $this->register($voter);
13
        }
14
    }
15
16
    public function register(ContextSupportedVoter $voter)
17
    {
18
        $this->voters[] = $voter;
19
    }
20
21
    public function vote(HttpCallResult $httpCallResult)
22
    {
23
        foreach ($this->voters as $voter) {
24
            if ($voter->vote($httpCallResult)) {
25
                if ($voter instanceof FilterableHttpCallResult) {
26
                    $httpCallResult->update($voter->filter($httpCallResult));
27
                }
28
29
                return true;
30
            }
31
        }
32
33
        return false;
34
    }
35
}
36