Completed
Pull Request — develop (#27)
by Chris
04:25
created

Attribute::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\Core;
4
5
use Chrisyue\PhpM3u8\M3u8\OptionsTrait;
6
use Chrisyue\PhpM3u8\M3u8\Transformer\TransformerInterface;
7
8
/**
9
 * @Annotation
10
 */
11
class Attribute implements AttributeInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    public $name;
17
18
    /**
19
     * @var Chrisyue\PhpM3u8\M3u8\Transformer\TransformerInterface
20
     */
21
    public $transformer;
22
23
    public function parse($origin)
24
    {
25
        if (!$this->transformer instanceof TransformerInterface) {
26
            return $origin;
27
        }
28
29
        return $this->transformer->transform($origin);
30
    }
31
32
    public function dump($parsed)
33
    {
34
        if (!$this->transformer instanceof TransformerInterface) {
35
            return $parsed;
36
        }
37
38
        return $this->transformer->reverse($parsed);
39
    }
40
41
    public function getName()
42
    {
43
        return $this->name;
44
    }
45
}
46