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

RangeValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A ensureRange() 0 6 2
A getValue() 0 4 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
}