Completed
Push — master ( 3c9f39...7900b8 )
by greg
29:19 queued 15:31
created

PostVote   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 66 1
1
<?php
2
3
namespace PlaygroundGame\Form\Admin;
4
5
use PlaygroundCore\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator;
6
use Zend\Mvc\I18n\Translator;
7
use Zend\ServiceManager\ServiceManager;
8
9
class PostVote extends Game
10
{
11
    public function __construct($name, ServiceManager $sm, Translator $translator)
12
    {
13
        $this->setServiceManager($sm);
14
        $entityManager = $sm->get('doctrine.entitymanager.orm_default');
15
16
        // Mapping of an Entity to get value by getId()... Should be taken in charge by Doctrine Hydrator Strategy...
17
        // having to fix a DoctrineModule bug :( https://github.com/doctrine/DoctrineModule/issues/180
18
        $hydrator = new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\PostVote');
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...
19
        $hydrator->addStrategy('partner', new \PlaygroundCore\Stdlib\Hydrator\Strategy\ObjectStrategy());
20
        $this->setHydrator($hydrator);
21
22
        parent::__construct($name, $sm, $translator);
23
24
        $this->add(array(
25
            'type' => 'Zend\Form\Element\Select',
26
            'name' => 'postDisplayMode',
27
            'attributes' =>  array(
28
                'id' => 'postDisplayMode',
29
                'options' => array(
30
                    'date' => $translator->translate('Date', 'playgroundgame'),
31
                    'vote' => $translator->translate('Vote number', 'playgroundgame'),
32
                    'random' => $translator->translate('Random', 'playgroundgame'),
33
                ),
34
            ),
35
            'options' => array(
36
                'empty_option' => $translator->translate('Display posts orber by', 'playgroundgame'),
37
                'label' => $translator->translate('Posts display mode', 'playgroundgame'),
38
            ),
39
        ));
40
        
41
        $this->add(array(
42
            'type' => 'Zend\Form\Element\Text',
43
            'name' => 'postDisplayNumber',
44
            'attributes' =>  array(
45
                'id' => 'postDisplayNumber',
46
            ),
47
            'options' => array(
48
                'empty_option' => $translator->translate('Number of displayed posts', 'playgroundgame'),
49
                'label' => $translator->translate('Number of displayed posts', 'playgroundgame'),
50
            ),
51
        ));
52
53
        $this->add(array(
54
            'type' => 'Zend\Form\Element\Checkbox',
55
            'name' => 'voteAnonymous',
56
            'options' => array(
57
                'label' => $translator->translate('Allow anonymous visitors to vote', 'playgroundgame'),
58
            ),
59
        ));
60
61
        $this->add(array(
62
                'type' => 'Zend\Form\Element\Select',
63
                'name' => 'moderationType',
64
                'attributes' =>  array(
65
                        'id' => 'moderationType',
66
                        'options' => array(
67
                                '0' => $translator->translate('Post moderation', 'playgroundgame'),
68
                                '1' => $translator->translate('Pre moderation', 'playgroundgame'),
69
                        ),
70
                ),
71
                'options' => array(
72
                        'empty_option' => $translator->translate('Moderation type', 'playgroundgame'),
73
                        'label' => $translator->translate('Moderation type', 'playgroundgame'),
74
                ),
75
        ));
76
    }
77
}
78