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

AttrTransformers   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 1
A get() 0 6 2
A getKeyByName() 0 8 3
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