RecoverForm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 83
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B render() 0 72 3
1
<?php
2
namespace Redaxscript\View;
3
4
use Redaxscript\Html;
5
use Redaxscript\Model;
6
use Redaxscript\Module;
7
8
/**
9
 * children class to create the recover form
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category View
15
 * @author Henry Ruhs
16
 */
17
18
class RecoverForm extends ViewAbstract
19
{
20
	/**
21
	 * render the view
22
	 *
23
	 * @since 3.0.0
24
	 *
25
	 * @return string
26
	 */
27
28 1
	public function render() : string
29
	{
30 1
		$output = Module\Hook::trigger('recoverFormStart');
31 1
		$settingModel = new Model\Setting();
32
33
		/* html element */
34
35 1
		$titleElement = new Html\Element();
36
		$titleElement
37 1
			->init('h2',
38
			[
39 1
				'class' => 'rs-title-content'
40
			])
41 1
			->text($this->_language->get('recovery'));
0 ignored issues
show
Bug introduced by redaxmedia
It seems like $this->_language->get('recovery') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
42 1
		$formElement = new Html\Form($this->_registry, $this->_language);
43 1
		$formElement->init(
44
		[
45 1
			'form' =>
46
			[
47
				'class' => 'rs-js-validate rs-form-default rs-form-recover'
48
			],
49
			'button' =>
50
			[
51
				'submit' =>
52
				[
53
					'name' => self::class
54
				]
55
			]
56
		],
57
		[
58 1
			'captcha' => $settingModel->get('captcha')
59
		]);
60
61
		/* create the form */
62
63
		$formElement
64 1
			->legend($this->_language->get('recovery_request') . $this->_language->get('point'))
65 1
			->append('<ul><li>')
66 1
			->label('* ' . $this->_language->get('email'),
67
			[
68 1
				'for' => 'email'
69
			])
70 1
			->email(
71
			[
72 1
				'autofocus' => 'autofocus',
73
				'id' => 'email',
74
				'name' => 'email',
75
				'required' => 'required'
76
			])
77 1
			->append('</li>');
78 1
		if ($settingModel->get('captcha') > 0)
79
		{
80
			$formElement
81 1
				->append('<li>')
82 1
				->captcha('task')
83 1
				->append('</li>');
84
		}
85 1
		$formElement->append('</ul>');
86 1
		if ($settingModel->get('captcha') > 0)
87
		{
88 1
			$formElement->captcha('solution');
89
		}
90
		$formElement
91 1
			->token()
92 1
			->submit();
93
94
		/* collect output */
95
96 1
		$output .= $titleElement . $formElement;
97 1
		$output .= Module\Hook::trigger('recoverFormEnd');
98 1
		return $output;
99
	}
100
}
101