Completed
Pull Request — develop (#27)
by Chris
12:02
created

Attribute   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 3
A reverse() 0 12 3
A getName() 0 4 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\Transformer;
4
5
use Chrisyue\PhpM3u8\M3u8\OptionsTrait;
6
7
/**
8
 * @Annotation
9
 * @Target("PROPERTY")
10
 */
11
class Attribute implements AttributeValueTransformerInterface
12
{
13
    use OptionsTrait;
14
15
    public function transform($value)
16
    {
17
        if (empty($this->options['transformers'])) {
18
            return $value;
19
        }
20
21
        foreach ($this->options['transformers'] as $transformer) {
22
            $value = $transformer->transform($value);
23
        }
24
25
        return $value;
26
    }
27
28
    public function reverse($value)
29
    {
30
        if (empty($this->options['transformers'])) {
31
            return $value;
32
        }
33
34
        foreach (array_reverse($this->options['transformers']) as $transformer) {
35
            $value = $transformer->reverse($value);
36
        }
37
38
        return $value;
39
    }
40
41
    public function getName()
42
    {
43
        return $this->options['name'];
44
    }
45
}
46