Passed
Push — feature/custom-services-v2 ( f3d61c...0bc47e )
by Chema
03:49
created

DocBlockParser::getClassFromMethod()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\CustomService;
6
7
final class DocBlockParser
8
{
9 3
    public function getClassFromMethod(string $docBlock, string $method): string
10
    {
11 3
        if ($docBlock === '') {
12 1
            return '';
13
        }
14
15 2
        $lines = array_filter(
16 2
            explode(PHP_EOL, $docBlock),
17 2
            static fn (string $l) => str_contains($l, $method)
18
        );
19
20 2
        $lineSplit = (array)explode(' ', (string)reset($lines));
21
22 2
        return $lineSplit[3] ?? '';
23
    }
24
}
25