ExpressionLanguageVoter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 19
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A vote() 0 13 3
1
<?php
2
3
namespace Jlis\Judge\Voters;
4
5
use Jlis\Judge\Judges\FeatureJudge;
6
use Jlis\Judge\Contracts\VoterInterface;
7
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
8
9
/**
10
 * @author Julius Ehrlich <[email protected]>
11
 */
12
class ExpressionLanguageVoter implements VoterInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 6
    public function vote($parameter = null, $user = null, array $additional = [])
18
    {
19 6
        if (empty($parameter)) {
20 1
            return false;
21
        }
22
23 5
        $language = new ExpressionLanguage();
24 5
        if (! array_key_exists('user', $additional)) {
25 4
            $additional['user'] = $user;
26 4
        }
27
28 5
        return FeatureJudge::isTrue($language->evaluate($parameter, $additional));
29
    }
30
}
31