Passed
Push — main ( b4da1f...10c988 )
by Jesús
01:01 queued 16s
created

DocBlockParser::getClassFromMethod()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 18
rs 9.9666
ccs 10
cts 11
cp 0.9091
crap 3.0067
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\DocBlockService;
6
7
final class DocBlockParser
8
{
9 24
    public function getClassFromMethod(string $docBlock, string $method): string
10
    {
11 24
        if ($docBlock === '') {
12 1
            return '';
13
        }
14
15 23
        if (strcasecmp(substr(PHP_OS, 0, 3), 'WIN') == 0) {
16
            $docBlock = str_replace("\n", PHP_EOL, $docBlock);
17
        }
18
19 23
        $lines = array_filter(
20 23
            explode(PHP_EOL, $docBlock),
21 23
            static fn (string $l) => str_contains($l, $method),
22 23
        );
23
        /** @psalm-suppress RedundantCast */
24 23
        $lineSplit = (array)explode(' ', (string)reset($lines));
25
26 23
        return $lineSplit[3] ?? '';
27
    }
28
}
29