AttributesValueTagTrait::extractAttributes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 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