Completed
Pull Request — master (#268)
by greg
07:26 queued 04:08
created

MissionGameConditionFieldset   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 51
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 48 1
1
<?php
2
3
namespace PlaygroundGame\Form\Admin;
4
5
use PlaygroundGame\Entity\MissionGameCondition;
6
use Zend\Form\Fieldset;
7
use Zend\Mvc\I18n\Translator;
8
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
9
use Zend\ServiceManager\ServiceManager;
10
11
class MissionGameConditionFieldset extends Fieldset
12
{
13
    public function __construct($name, ServiceManager $serviceManager, Translator $translator)
14
    {
15
        parent::__construct($name);
16
        $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
17
18
        $this->setHydrator(new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\MissionGameCondition'))
0 ignored issues
show
Documentation introduced by
$entityManager is of type object|array, but the function expects a object<Doctrine\Common\Persistence\ObjectManager>.

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...
Documentation introduced by
'PlaygroundGame\\Entity\\MissionGameCondition' is of type string, but the function expects a boolean.

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...
19
        ->setObject(new MissionGameCondition());
20
21
        $this->add(array(
22
            'type' => 'Zend\Form\Element\Hidden',
23
            'name' => 'id'
24
        ));
25
26
        $this->add(array(
27
            'type' => 'Zend\Form\Element\Select',
28
            'name' => 'attribute',
29
            'options' => array(
30
                'empty_option' => $translator->translate('Select the attribute', 'playgroundgame'),
31
                'value_options' => array(
32
                    'winner' => $translator->translate('status of previous game', 'playgroundgame'),
33
                    'points' => $translator->translate('Points of previous game', 'playgroundgame'),
34
                ),
35
                'label' => $translator->translate('Attribute', 'playgroundgame'),
36
            ),
37
        ));
38
        
39
        $this->add(array(
40
            'type' => 'Zend\Form\Element\Select',
41
            'name' => 'comparison',
42
            'options' => array(
43
                'empty_option' => $translator->translate('Type of comparison', 'playgroundgame'),
44
                'value_options' => array(
45
                    '==' => $translator->translate('equals', 'playgroundgame'),
46
                    '>' => $translator->translate('more than', 'playgroundgame'),
47
                    '<' => $translator->translate('less than', 'playgroundgame'),
48
                ),
49
                'label' => $translator->translate('Comparison', 'playgroundgame'),
50
            ),
51
        ));
52
53
        $this->add(array(
54
            'name' => 'value',
55
            'options' => array(
56
                'label' => $translator->translate('Value'),
57
            ),
58
        ));
59
60
    }
61
}
62