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

Parsers   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 getKeyForLine() 0 8 3
A get() 0 6 2
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Parser;
4
5
use Chrisyue\PhpM3u8\Line\LineInterface;
6
7
class Parsers implements ParsersInterface
8
{
9
    private $parsers = [];
10
11
    public function set($key, ChildParserInterface $parser)
12
    {
13
        $this->parsers[$key] = $parser;
14
    }
15
16
    public function getKeyForLine(LineInterface $line)
17
    {
18
        foreach ($this->parsers as $key => $parser) {
19
            if ($parser->supports($line)) {
20
                return $key;
21
            }
22
        }
23
    }
24
25
    public function get($key)
26
    {
27
        if (isset($this->parsers[$key])) {
28
            return $this->parsers[$key];
29
        }
30
    }
31
}
32