Completed
Pull Request — develop (#27)
by Chris
01:53
created

Attribute::dump()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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