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

AttrTransformer::supports()   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
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Transformer;
4
5
class AttrTransformer implements AttrTransformerInterface
6
{
7
    private $attrName;
8
9
    private $valueTransformer;
10
11
    public function __construct($attrName, TransformerInterface $valueTransformer = null)
12
    {
13
        $this->attrName = $attrName;
14
        $this->valueTransformer = $valueTransformer;
15
    }
16
17
    public function transform($origin)
18
    {
19
        if (null === $this->valueTransformer) {
20
            return $origin;
21
        }
22
23
        return $this->valueTransformer->transform($origin);
24
    }
25
26
    public function supports($attrName)
27
    {
28
        return $this->attrName === $attrName;
29
    }
30
}
31