Completed
Push — master ( 06e52a...98c39c )
by Pavel
13:39 queued 10:37
created

AutoFormProcessor::updateEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
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
    public function __construct(MappedEntityFormFactory $factory)
18
    {
19
        $this->factory = $factory;
20
    }
21
22
    /** {@inheritdoc} */
23
    public function updateEntity($entity, $data)
24
    {
25
        $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
        return $processor->updateEntity($entity, $data);
28
    }
29
}
30