Completed
Pull Request — master (#314)
by greg
03:20
created

TradingCard::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 1
eloc 21
nc 1
nop 3
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 TradingCard 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
        // having to fix a Doctrine-module bug :( https://github.com/doctrine/DoctrineModule/issues/180
17
        $hydrator = new DoctrineHydrator($entityManager, 'PlaygroundGame\Entity\TradingCard');
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...
18
        $hydrator->addStrategy('partner', new \PlaygroundCore\Stdlib\Hydrator\Strategy\ObjectStrategy());
19
        $this->setHydrator($hydrator);
20
21
        parent::__construct($name, $sm, $translator);
22
23
        $this->add(array(
24
            'name' => 'boosterCardNumber',
25
            'type' => 'Zend\Form\Element\Text',
26
            'attributes' => array(
27
                'placeholder' => $translator->translate('Number of cards in booster', 'playgroundgame'),
28
            ),
29
            'options' => array(
30
                'label' => $translator->translate('Number of cards in booster', 'playgroundgame'),
31
            ),
32
        ));
33
34
        $this->add(array(
35
            'name' => 'boosterDrawQuantity',
36
            'type' => 'Zend\Form\Element\Text',
37
            'attributes' => array(
38
                'placeholder' => $translator->translate('Number of boosters', 'playgroundgame'),
39
            ),
40
            'options' => array(
41
                'label' => $translator->translate('Number of boosters', 'playgroundgame'),
42
            ),
43
        ));
44
    }
45
}
46