OrVoter::result()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 13
loc 13
rs 9.2
cc 4
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace Vivait\Voter\Voter;
4
5
class OrVoter extends VoterAbstract {
6 View Code Duplication
    public function result($entity) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
        foreach ($this->conditions as $condition) {
8
            $result = $condition->result($entity);
9
10
            $this->logger->debug(sprintf('Condition "%s" returned result: %s', (string)$condition, $result ? 'true' : 'false'));
11
12
            if ($result == true) {
13
                return true;
14
            }
15
        }
16
17
        return false;
18
    }
19
20
    public function supports($entities)
21
    {
22
        if (!is_array($entities)) {
23
            $entities = [$entities];
24
        }
25
26
        foreach ($this->conditions as $condition) {
27
            if (!array_diff((array)$condition->requires(), $entities)) {
28
                return true;
29
            }
30
        }
31
32
        return false;
33
    }
34
}
35