Completed
Push — master ( 534932...26bda2 )
by Jan-Petter
02:41
created

directive   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A getArray() 0 4 1
1
<?php
2
3
namespace vipnytt\XRobotsTagParser;
4
5
use vipnytt\XRobotsTagParser\directives;
6
use vipnytt\XRobotsTagParser\directives\directiveInterface;
7
8
final class directive
9
{
10
    private $object;
11
12
    public function __construct($directive, $value)
13
    {
14
        $class = __NAMESPACE__ . "\\directives\\$directive";
15
        if (!class_exists($class)) {
16
            trigger_error('Directive class does not exist', E_USER_ERROR);
17
        }
18
        $object = new $class($value);
19
        if (!$object instanceof directiveInterface) {
20
            trigger_error('Directive class invalid', E_USER_ERROR);
21
        }
22
        $this->object = $object;
23
    }
24
25
    public function getArray()
26
    {
27
        return $this->object->getArray();
28
    }
29
}
30