FormDataMapper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mapModelDataToForm() 0 5 1
A mapFormToData() 0 5 1
A mapRequestDataToForm() 0 5 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Component\Form\DataMapper;
14
15
use WellCommerce\Component\Form\Elements\FormInterface;
16
17
/**
18
 * Class FormDataMapper
19
 *
20
 * @author Adam Piotrowski <[email protected]>
21
 */
22
class FormDataMapper implements FormDataMapperInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function mapModelDataToForm($modelData, FormInterface $form)
28
    {
29
        $modelDataMapper = new ModelDataMapper($modelData);
30
        $modelDataMapper->mapDataToForm($form);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function mapFormToData(FormInterface $form, $modelData)
37
    {
38
        $modelDataMapper = new ModelDataMapper($modelData);
39
        $modelDataMapper->mapFormToData($form);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function mapRequestDataToForm($data, FormInterface $form)
46
    {
47
        $requestDataMapper = new RequestDataMapper($data);
0 ignored issues
show
Documentation introduced by
$data is of type array, but the function expects a object.

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...
48
        $requestDataMapper->mapDataToForm($form);
49
    }
50
}
51