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

directive::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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