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

TradingCard   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
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 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 34 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 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