getInputObjectFieldName()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 7
c 1
b 0
f 1
nc 3
nop 2
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Common;
6
7
use Andi\GraphQL\Attribute\InputObjectField;
8
9
trait InputObjectFieldNameTrait
10
{
11 9
    private function getInputObjectFieldName(\ReflectionMethod $method, ?InputObjectField $attribute): string
12
    {
13 9
        if ($attribute?->name) {
14 3
            \assert($attribute->name !== null);
15 3
            return $attribute->name;
16
        }
17
18 6
        $name = $method->getName();
19
20 6
        if (\str_starts_with($name, 'set')) {
21 5
            $name = \substr($name, 3);
22
        }
23
24 6
        return \lcfirst($name);
25
    }
26
}
27