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

AttrTransformers::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Transformer;
4
5
class AttrTransformers implements AttrTransformersInterface
6
{
7
    private $transformers = [];
8
9
    public function set($key, AttrTransformerInterface $transformer)
10
    {
11
        $this->transformers[$key] = $transformer;
12
    }
13
14
    public function get($key)
15
    {
16
        if (isset($this->transformers[$key])) {
17
            return $this->transformers[$key];
18
        }
19
    }
20
21
    public function getKeyByName($name)
22
    {
23
        foreach ($this->transformers as $key => $transformer) {
24
            if ($transformer->supports($name)) {
25
                return $key;
26
            }
27
        }
28
    }
29
}
30