Completed
Push — master ( 2fb104...0c9ed9 )
by Basil
03:25
created

RangeValue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace luya\web\jsonld;
4
5
use yii\base\InvalidConfigException;
6
7
8
class RangeValue extends BaseValue
9
{
10
    private $_value;
11
12
    public function __construct($value)
13
    {
14
        $this->_value = $value;    
15
    }
16
17
    public function ensureRange($min, $max)
18
    {
19
        if (!in_array($this->_value, range($min, $max))) {
20
            throw new InvalidConfigException("Value {$this->_value} must be min {$min} or max {$max}.");
21
        }
22
    }
23
24
    public function getValue()
25
    {
26
        return $this->_value;
27
    }
28
}