Definition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

1 Method

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