ExpressionLanguageVoter::vote()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 3
crap 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