RegisterForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 123
ccs 59
cts 59
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B render() 0 112 3
1
<?php
2
namespace Redaxscript\View;
3
4
use Redaxscript\Html;
5
use Redaxscript\Model;
6
use Redaxscript\Module;
7
use Redaxscript\Validator;
8
9
/**
10
 * children class to create the register form
11
 *
12
 * @since 3.0.0
13
 *
14
 * @package Redaxscript
15
 * @category View
16
 * @author Henry Ruhs
17
 */
18
19
class RegisterForm extends ViewAbstract
20
{
21
	/**
22
	 * render the view
23
	 *
24
	 * @since 3.0.0
25
	 *
26
	 * @return string
27
	 */
28
29 1
	public function render() : string
30
	{
31 1
		$output = Module\Hook::trigger('registerFormStart');
32 1
		$settingModel = new Model\Setting();
33 1
		$nameValidator = new Validator\Name();
34 1
		$userValidator = new Validator\User();
35 1
		$passwordValidator = new Validator\Password();
36
37
		/* html element */
38
39 1
		$titleElement = new Html\Element();
40
		$titleElement
41 1
			->init('h2',
42
			[
43 1
				'class' => 'rs-title-content'
44
			])
45 1
			->text($this->_language->get('account_create'));
46 1
		$formElement = new Html\Form($this->_registry, $this->_language);
47 1
		$formElement->init(
48
		[
49
			'form' =>
50
			[
51 1
				'class' => 'rs-js-validate rs-form-default rs-form-register'
52
			],
53
			'button' =>
54
			[
55
				'submit' =>
56
				[
57
					'name' => self::class
58
				]
59
			]
60
		],
61
		[
62 1
			'captcha' => $settingModel->get('captcha')
63
		]);
64
65
		/* create the form */
66
67
		$formElement
68 1
			->legend()
69 1
			->append('<ul><li>')
70 1
			->label('* ' . $this->_language->get('name'),
71
			[
72 1
				'for' => 'name'
73
			])
74 1
			->text(
75
			[
76 1
				'autofocus' => 'autofocus',
77 1
				'id' => 'name',
78 1
				'name' => 'name',
79 1
				'pattern' => $nameValidator->getPattern(),
80 1
				'required' => 'required'
81
			])
82 1
			->append('</li><li>')
83 1
			->label('* ' . $this->_language->get('user'),
84
			[
85 1
				'for' => 'user'
86
			])
87 1
			->text(
88
			[
89 1
				'id' => 'user',
90 1
				'name' => 'user',
91 1
				'pattern' => $userValidator->getPattern(),
92 1
				'required' => 'required'
93
			])
94 1
			->append('</li><li>')
95 1
			->label('* ' . $this->_language->get('password'),
96
			[
97 1
				'for' => 'password'
98
			])
99 1
			->password(
100
			[
101 1
				'autocomplete' => 'new-password',
102 1
				'id' => 'password',
103 1
				'name' => 'password',
104 1
				'pattern' => $passwordValidator->getPattern(),
105 1
				'required' => 'required'
106
			])
107 1
			->append('</li><li>')
108 1
			->label('* ' . $this->_language->get('email'),
109
			[
110 1
				'for' => 'email'
111
			])
112 1
			->email(
113
			[
114 1
				'id' => 'email',
115
				'name' => 'email',
116
				'required' => 'required'
117
			])
118 1
			->append('</li>');
119 1
		if ($settingModel->get('captcha') > 0)
120
		{
121
			$formElement
122 1
				->append('<li>')
123 1
				->captcha('task')
124 1
				->append('</li>');
125
		}
126 1
		$formElement->append('</ul>');
127 1
		if ($settingModel->get('captcha') > 0)
128
		{
129 1
			$formElement->captcha('solution');
130
		}
131
		$formElement
132 1
			->token()
133 1
			->submit($this->_language->get('create'));
134
135
		/* collect output */
136
137 1
		$output .= $titleElement . $formElement;
138 1
		$output .= Module\Hook::trigger('registerFormEnd');
139 1
		return $output;
140
	}
141
}
142