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

TagDefinition::getProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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