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

KvTransformer::transform()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
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