ArrayTag::splitValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\PhpdocParser\Tag;
6
7
/**
8
 * Tag value represents an array
9
 */
10
class ArrayTag extends AbstractArrayTag
11
{
12
    /**
13
     * Split value into items.
14
     *
15
     * @param string $value
16
     * @return array
17
     */
18 11
    protected function splitValue(string $value): array
19
    {
20 11
        $regexp = '/(?<=^|,)\s*(?:\'(?:[^\']++|\\\\.)*\'|(?:"(?:[^"]++|\\\\.)*"|[^,\'"]+|[\'"])+)/';
21 11
        preg_match_all($regexp, $value, $matches, PREG_PATTERN_ORDER); // regex can't fail
22
23 11
        return $matches[0];
24
    }
25
}
26