Completed
Pull Request — develop (#27)
by Chris
05:29
created

TagDefinition   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 61
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getProperty() 0 4 1
A getValueType() 0 11 2
A getTagName() 0 4 1
A isMultiple() 0 4 1
A getCategory() 0 4 1
A isUriAware() 0 4 1
A getAttributeTypes() 0 4 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Definition;
4
5
use Chrisyue\PhpM3u8\Config;
6
7
class TagDefinition
8
{
9
    private $property;
10
11
    private $config;
12
13
    private $attributeTypes;
14
15
    public function __construct($property, Config $config)
16
    {
17
        if (!is_string($property)) {
18
            throw new \InvalidArgumentException('$property can only be string, got %s', var_export($property));
19
        }
20
21
        $this->property = $property;
22
23
        $this->config = $config;
24
    }
25
26
    public function getProperty()
27
    {
28
        return $this->property;
29
    }
30
31
    public function getValueType()
32
    {
33
        $type = $this->config->get('type');
34
        if (is_array($type)) {
35
            $this->attributeTypes = $type;
36
37
            return 'attribute-list';
38
        }
39
40
        return $type;
41
    }
42
43
    public function getTagName()
44
    {
45
        return $this->config->get('tag');
46
    }
47
48
    public function isMultiple()
49
    {
50
        return $this->config->get('multiple', false);
51
    }
52
53
    public function getCategory()
54
    {
55
        return $this->config->get('category');
56
    }
57
58
    public function isUriAware()
59
    {
60
        return $this->config->get('uriAware', false);
61
    }
62
63
    public function getAttributeTypes()
64
    {
65
        return $this->attributeTypes;
66
    }
67
}
68