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

Attribute   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 8 2
A dump() 0 8 2
A getName() 0 4 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