Cancelled
Push — master ( 90b90a...d1d279 )
by Josh
10:16
created

BaseImplementation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
* @package   s9e\RegexpBuilder
5
* @copyright Copyright (c) 2016 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\RegexpBuilder\Output;
9
10
use InvalidArgumentException;
11
12
abstract class BaseImplementation implements OutputInterface
13
{
14
	/**
15
	* @var integer
16
	*/
17
	protected $maxValue = 0;
18
19
	/**
20
	* @var integer
21
	*/
22
	protected $minValue = 0;
23
24
	/**
25
	* @param array $options
26
	*/
27 37
	public function __construct(array $options = [])
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
	{
29 37
	}
30
31
	/**
32
	* {@inheritdoc}
33
	*/
34 37
	public function output($value)
35
	{
36 37
		if ($value < $this->minValue || $value > $this->maxValue)
37
		{
38 4
			throw new InvalidArgumentException('Value ' . $value . ' is out of bounds (' . $this->minValue . '..' . $this->maxValue . ')');
39
		}
40
41 33
		return $this->outputValidValue($value);
42
	}
43
44
	/**
45
	* Serialize a valid value into a character
46
	*
47
	* @param  integer $value
48
	* @return string
49
	*/
50
	abstract protected function outputValidValue($value);
51
}