Completed
Pull Request — develop (#27)
by Chris
01:36
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
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <https://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8\Definition;
13
14
use Chrisyue\PhpM3u8\Config;
15
16
class TagDefinition
17
{
18
    private $property;
19
20
    private $config;
21
22
    private $attributeTypes;
23
24
    public function __construct($property, Config $config)
25
    {
26
        if (!is_string($property)) {
27
            throw new \InvalidArgumentException('$property can only be string, got %s', var_export($property));
28
        }
29
30
        $this->property = $property;
31
32
        $this->config = $config;
33
    }
34
35
    public function getProperty()
36
    {
37
        return $this->property;
38
    }
39
40
    public function getValueType()
41
    {
42
        $type = $this->config->get('type');
43
        if (is_array($type)) {
44
            $this->attributeTypes = $type;
45
46
            return 'attribute-list';
47
        }
48
49
        return $type;
50
    }
51
52
    public function getTagName()
53
    {
54
        return $this->config->get('tag');
55
    }
56
57
    public function isMultiple()
58
    {
59
        return $this->config->get('multiple', false);
60
    }
61
62
    public function getCategory()
63
    {
64
        return $this->config->get('category');
65
    }
66
67
    public function isUriAware()
68
    {
69
        return $this->config->get('uriAware', false);
70
    }
71
72
    public function getAttributeTypes()
73
    {
74
        return $this->attributeTypes;
75
    }
76
}
77