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

KvTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 12 2
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Transformer;
4
5
class KvTransformer
6
{
7
    public function transform($origin)
8
    {
9
        preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\1(?=,|$)/', $origin, $matches);
10
11
        $result = [];
12
        foreach ($matches[0] as $attr) {
13
            list($name, $value) = explode('=', $attr);
14
            $result[$name] = $value;
15
        }
16
17
        return $result;
18
    }
19
}
20