Completed
Push — master ( a9845d...cc3347 )
by Adrien
02:02
created

User   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 58
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B init() 0 55 1
1
<?php
2
3
namespace mQueue\Form;
4
5
use Zend_Form;
6
use Zend_Validate_Db_NoRecordExists;
7
8
class User extends Zend_Form
9
{
10 2
    public function init(): void
11
    {
12
        // Set the method for the display form to POST
13 2
        $this->setMethod('post');
14
15
        // Add the nickname element
16 2
        $this->addElement('text', 'nickname', [
17 2
            'label' => _tr('Nickname:'),
18
            'autofocus' => true,
19
            'required' => true,
20
            'filters' => ['filter' => ['filter' => 'stringTrim']],
21
            'validators' => [
22 2
                ['validator' => new Zend_Validate_Db_NoRecordExists(['table' => 'user', 'field' => 'nickname'])],
23
            ],
24
        ]);
25
26
        // Add the email element
27 2
        $this->addElement('text', 'email', [
28 2
            'label' => _tr('Email:'),
29
            'required' => true,
30
            'filters' => ['filter' => ['filter' => 'stringTrim']],
31
            'validators' => [
32
                ['validator' => 'emailAddress'],
33 2
                ['validator' => new Zend_Validate_Db_NoRecordExists(['table' => 'user', 'field' => 'email'])],
34
            ],
35
        ]);
36
37
        // Add the password ail element
38 2
        $this->addElement('password', 'password', [
39 2
            'label' => _tr('Password:'),
40
            'required' => true,
41
        ]);
42
43
        // Add a captcha
44 2
        $this->addElement('captcha', 'captcha', [
45 2
            'label' => _tr('Are you a robot?'),
46
            'required' => true,
47 2
            'captcha' => 'figlet',
48
            'captchaOptions' => [
49
                'outputWidth' => 2000,
50
            ],
51
        ]);
52
53
        // Add the submit button
54 2
        $this->addElement('submit', 'submit', [
55 2
            'ignore' => true,
56 2
            'label' => _tr('Subscribe'),
57
        ]);
58
59
        // And finally add some CSRF protection
60 2
        $this->addElement('hash', 'csrf', [
61 2
            'ignore' => true,
62
            'decorators' => ['ViewHelper'],
63
        ]);
64 2
    }
65
}
66