Completed
Pull Request — master (#90)
by Arnaud
02:08
created

ViewFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace LAG\AdminBundle\View\Factory;
4
5
use LAG\AdminBundle\Action\Configuration\ActionConfiguration;
6
use LAG\AdminBundle\Action\Factory\ConfigurationFactory;
7
use LAG\AdminBundle\Admin\Configuration\AdminConfiguration;
8
use LAG\AdminBundle\Field\Factory\FieldFactory;
9
use LAG\AdminBundle\View\View;
10
11
class ViewFactory
12
{
13
    /**
14
     * @var ConfigurationFactory
15
     */
16
    private $configurationFactory;
17
    /**
18
     * @var FieldFactory
19
     */
20
    private $fieldFactory;
21
    
22
    /**
23
     * ViewFactory constructor.
24
     *
25
     * @param ConfigurationFactory $configurationFactory
26
     * @param FieldFactory         $fieldFactory
27
     */
28
    public function __construct(ConfigurationFactory $configurationFactory, FieldFactory $fieldFactory)
29
    {
30
        $this->configurationFactory = $configurationFactory;
31
        $this->fieldFactory = $fieldFactory;
32
    }
33
    
34
    /**
35
     * Create a view for a given Admin and Action.
36
     *
37
     * @param string              $actionName
38
     * @param string              $adminName
39
     * @param AdminConfiguration  $adminConfiguration
40
     * @param ActionConfiguration $actionConfiguration
41
     *
42
     * @return View
43
     */
44
    public function create(
45
        $actionName,
46
        $adminName,
47
        AdminConfiguration $adminConfiguration,
48
        ActionConfiguration $actionConfiguration
49
    ) {
50
        $configuration = $this
51
            ->configurationFactory
52
            ->create($actionName, $adminName, $adminConfiguration, $actionConfiguration)
0 ignored issues
show
Documentation introduced by
$actionConfiguration is of type object<LAG\AdminBundle\A...on\ActionConfiguration>, but the function expects a array.

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...
53
        ;
54
    
55
        $fields = $this
56
            ->fieldFactory
57
            ->getFields($configuration)
58
        ;
59
        $view = new View($actionName, $adminName, $configuration, $adminConfiguration, $fields);
60
    
61
        return $view;
62
    }
63
}
64