AttributesValueTagTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractAttributes() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <http://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8\Tag;
13
14
trait AttributesValueTagTrait
15
{
16
    use SingleValueTagTrait;
17
18 1
    private static function extractAttributes($line)
19
    {
20 1
        $attrsText = self::extractValue($line);
21
22 1
        preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\1(?=,|$)/', $attrsText, $matches);
23 1
        $attributes = [];
24 1
        foreach ($matches[0] as $attr) {
25 1
            list($key, $value) = explode('=', $attr);
26 1
            $attributes[$key] = trim($value);
27 1
        }
28
29 1
        return $attributes;
30
    }
31
}
32