AbstractValueJudge::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Jlis\Judge\Judges;
4
5
use Jlis\Judge\Adapters\AdapterInterface;
6
7
/**
8
 * @author Julius Ehrlich <[email protected]>
9
 */
10
abstract class AbstractValueJudge extends Judge implements ValueJudgeInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $values = [];
16
17
    /**
18
     * Constructor.
19
     *
20
     * @param AdapterInterface $adapter
21
     * @param array            $voters
22
     */
23 26
    public function __construct(AdapterInterface $adapter, array $voters = [])
24
    {
25 26
        parent::__construct($adapter, $voters);
26 26
        $this->reloadValues();
27 26
    }
28
29
    /**
30
     * Reloads the values from the adapter.
31
     */
32 26
    public function reloadValues()
33
    {
34 26
        $this->values = $this->getValues();
35 26
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    abstract public function decide($value, $user = null, $defaultValue = false);
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    abstract public function valueExists($value);
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    abstract public function getValues();
51
}
52