LoginFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 34 2
1
<?php
2
3
namespace ZfcUser\Form;
4
5
use ZfcBase\InputFilter\ProvidesEventsInputFilter;
6
use ZfcUser\Options\AuthenticationOptionsInterface;
7
8
class LoginFilter extends ProvidesEventsInputFilter
9
{
10
    public function __construct(AuthenticationOptionsInterface $options)
11
    {
12
        $identityParams = array(
13
            'name'       => 'identity',
14
            'required'   => true,
15
            'validators' => array()
16
        );
17
18
        $identityFields = $options->getAuthIdentityFields();
19
        if ($identityFields == array('email')) {
20
            $validators = array('name' => 'EmailAddress');
21
            array_push($identityParams['validators'], $validators);
22
        }
23
24
        $this->add($identityParams);
25
26
        $this->add(array(
27
            'name'       => 'credential',
28
            'required'   => true,
29
            'validators' => array(
30
                array(
31
                    'name'    => 'StringLength',
32
                    'options' => array(
33
                        'min' => 6,
34
                    ),
35
                ),
36
            ),
37
            'filters'   => array(
38
                array('name' => 'StringTrim'),
39
            ),
40
        ));
41
42
        $this->getEventManager()->trigger('init', $this);
43
    }
44
}
45