Completed
Push — master ( f68f3b...859d26 )
by Josh
02:07
created

BaseImplementation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 9 3
outputValidValue() 0 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
	* {@inheritdoc}
26
	*/
27 36
	public function output($value)
28
	{
29 36
		if ($value < $this->minValue || $value > $this->maxValue)
30
		{
31 4
			throw new InvalidArgumentException('Value ' . $value  .' is out of bounds (' . $this->minValue . '..' . $this->maxValue . ')');
32
		}
33
34 32
		return $this->outputValidValue($value);
35
	}
36
37
	/**
38
	* Serialize a valid value into a character
39
	*
40
	* @param  integer $value
41
	* @return string
42
	*/
43
	abstract protected function outputValidValue($value);
44
}