Completed
Pull Request — master (#10)
by
unknown
01:00
created

Definition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
1
<?php
2
3
namespace Safelist\Definition;
4
5
/**
6
 * Base class for all definitions
7
 *
8
 * @author Sam Stenvall <[email protected]>
9
 * @copyright Copyright &copy; Sam Stenvall 2014-
10
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
11
 */
12
abstract class Definition implements IDefinition
13
{
14
15
	/**
16
	 * @var string the actual definition
17
	 */
18
	protected $_definition;
19
20
	/**
21
	 * Class constructor. It stores the definition string and validates it.
22
	 * @param string $definition the definition
23
	 * @throws \InvalidArgumentException if the definition is invalid
24
	 */
25
	public function __construct($definition)
26
	{
27
		$this->_definition = $definition;
28
29
		if (!$this->validate())
30
			throw new \InvalidArgumentException('The definition "'.$this->_definition.'" is invalid');
31
	}
32
33
}
34