InputObjectFieldNameTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInputObjectFieldName() 0 14 3
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