AutoFormProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateEntity() 0 6 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\Symfony;
4
5
use ScayTrase\Api\Cruds\EntityProcessorInterface;
6
7
final class AutoFormProcessor implements EntityProcessorInterface
8
{
9
    /** @var  MappedEntityFormFactory */
10
    private $factory;
11
12
    /**
13
     * AutoFormProcessor constructor.
14
     *
15
     * @param MappedEntityFormFactory $factory
16
     */
17 4
    public function __construct(MappedEntityFormFactory $factory)
18
    {
19 4
        $this->factory = $factory;
20 4
    }
21
22
    /** {@inheritdoc} */
23 4
    public function updateEntity($entity, $data)
24
    {
25 4
        $processor = new FormProcessor($this->factory->createFormForClass(get_class($entity)));
0 ignored issues
show
Documentation introduced by
$this->factory->createFo...ass(get_class($entity)) is of type object<Symfony\Component\Form\FormInterface>, but the function expects a string|object<Symfony\Co...Form\FormTypeInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
27 4
        return $processor->updateEntity($entity, $data);
28
    }
29
}
30