Completed
Pull Request — 1.x (#637)
by Daniel
07:58
created

ChangePassword   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 3
c 4
b 1
f 1
lcom 0
cbo 2
dl 0
loc 87
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthenticationOptions() 0 4 1
A __construct() 0 57 1
A setAuthenticationOptions() 0 5 1
1
<?php
2
3
namespace ZfcUser\Form;
4
5
use ZfcBase\Form\ProvidesEventsForm;
6
use ZfcUser\Options\AuthenticationOptionsInterface;
7
8
class ChangePassword extends ProvidesEventsForm
9
{
10
    /**
11
     * @var AuthenticationOptionsInterface
12
     */
13
    protected $authOptions;
14
15
    public function __construct($name, AuthenticationOptionsInterface $options)
16
    {
17
        $this->setAuthenticationOptions($options);
18
        parent::__construct($name);
19
20
        $this->add(array(
21
            'name' => 'identity',
22
            'options' => array(
23
                'label' => '',
24
            ),
25
            'attributes' => array(
26
                'type' => 'hidden'
27
            ),
28
        ));
29
30
        $this->add(array(
31
            'name' => 'credential',
32
            'type' => 'password',
33
            'options' => array(
34
                'label' => 'Current Password',
35
            ),
36
            'attributes' => array(
37
                'type' => 'password',
38
            ),
39
        ));
40
41
        $this->add(array(
42
            'name' => 'newCredential',
43
            'options' => array(
44
                'label' => 'New Password',
45
            ),
46
            'attributes' => array(
47
                'type' => 'password',
48
            ),
49
        ));
50
51
        $this->add(array(
52
            'name' => 'newCredentialVerify',
53
            'type' => 'password',
54
            'options' => array(
55
                'label' => 'Verify New Password',
56
            ),
57
            'attributes' => array(
58
                'type' => 'password',
59
            ),
60
        ));
61
62
        $this->add(array(
63
            'name' => 'submit',
64
            'attributes' => array(
65
                'value' => 'Submit',
66
                'type'  => 'submit'
67
            ),
68
        ));
69
70
        $this->getEventManager()->trigger('init', $this);
71
    }
72
73
    /**
74
     * Set Authentication-related Options
75
     *
76
     * @param AuthenticationOptionsInterface $authOptions
77
     * @return Login
78
     */
79
    public function setAuthenticationOptions(AuthenticationOptionsInterface $authOptions)
80
    {
81
        $this->authOptions = $authOptions;
82
        return $this;
83
    }
84
85
    /**
86
     * Get Authentication-related Options
87
     *
88
     * @return AuthenticationOptionsInterface
89
     */
90
    public function getAuthenticationOptions()
91
    {
92
        return $this->authOptions;
93
    }
94
}
95