SimpleMethodCallGeneratorTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateCode() 0 5 1
1
<?php
2
3
namespace Bdf\Form\Attribute\Processor\Element;
4
5
use Bdf\Form\Attribute\Processor\CodeGenerator\AttributesProcessorGenerator;
6
use ReflectionAttribute;
7
8
/**
9
 * Trait for implements method `generateCode()` using a simple builder method call
10
 * with the current attribute as parameter (i.e. generate the new expression according to the attribute class and parameters)
11
 *
12
 * @psalm-require-implements ElementAttributeProcessorInterface
13
 */
14
trait SimpleMethodCallGeneratorTrait
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 28
    public function generateCode(string $name, AttributesProcessorGenerator $generator, ReflectionAttribute $attribute): void
20
    {
21
        /** @var class-string $constraint */
22 28
        $constraint = $attribute->getName();
23 28
        $generator->line('$?->?(?);', [$name, $this->methodName(), $generator->new($constraint, $attribute->getArguments())]);
24
    }
25
26
    /**
27
     * Called method name
28
     *
29
     * @return literal-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment literal-string at position 0 could not be parsed: Unknown type name 'literal-string' at position 0 in literal-string.
Loading history...
30
     */
31
    abstract private function methodName(): string;
32
}
33