Completed
Push — 1.x ( 6e286e...c7aa89 )
by Daniel
45:22 queued 35:25
created

ChangePassword   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 19 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Clayton Daley
5
 * Date: 3/10/2015
6
 * Time: 9:34 AM
7
 */
8
9
namespace ZfcUser\Factory\Form;
10
11
use Zend\Form\FormElementManager;
12
use Zend\ServiceManager\FactoryInterface;
13
use Zend\ServiceManager\ServiceLocatorInterface;
14
use ZfcUser\Form;
15
16
class ChangePassword implements FactoryInterface
17
{
18
    public function createService(ServiceLocatorInterface $formElementManager)
19
    {
20
        if ($formElementManager instanceof FormElementManager) {
21
            $sm = $formElementManager->getServiceLocator();
22
            $fem = $formElementManager;
23
        } else {
24
            $sm = $formElementManager;
25
            $fem = $sm->get('FormElementManager');
26
        }
27
28
        $options = $sm->get('zfcuser_module_options');
29
        $form = new Form\ChangePassword(null, $options);
30
        // Inject the FormElementManager to support custom FormElements
31
        $form->getFormFactory()->setFormElementManager($fem);
0 ignored issues
show
Documentation introduced by
$fem is of type object|array, but the function expects a object<Zend\Form\FormElementManager>.

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...
32
33
        $form->setInputFilter(new Form\ChangePasswordFilter($options));
34
35
        return $form;
36
    }
37
}
38