Test Failed
Push — master ( 1eee01...3150c9 )
by Gabor
02:29
created

ApplicationCreateForm::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 52
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 37
nc 1
nop 0
dl 0
loc 52
rs 9.328
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Form\Preset;
15
16
use WebHemi\Form\Element\Html\HtmlElement;
17
18
/**
19
 * Class ApplicationEditForm
20
 *
21
 * @codeCoverageIgnore - only composes an object.
22
 */
23
class ApplicationCreateForm extends AbstractPreset
24
{
25
    /**
26
     * Initialize the adapter
27
     */
28
    protected function initAdapter()
29
    {
30
        $this->formAdapter->initialize('application', '[URL]', 'POST');
31
    }
32
33
    /**
34
     * Initialize and add elements to the form.
35
     *
36
     * @return void
37
     *
38
     * @codeCoverageIgnore - only composes an object.
39
     */
40
    protected function init() : void
41
    {
42
        $this->initAdapter();
43
44
        $name = $this->createElement(
45
            HtmlElement::class,
46
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
47
            'name',
48
            'Application name'
49
        );
50
51
        $title = $this->createElement(
52
            HtmlElement::class,
53
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
54
            'title',
55
            'Display name (title)'
56
        );
57
58
        $introduction = $this->createElement(
59
            HtmlElement::class,
60
            HtmlElement::HTML_ELEMENT_TEXTAREA,
61
            'introduction',
62
            'Introduction'
63
        );
64
65
        $subject = $this->createElement(
66
            HtmlElement::class,
67
            HtmlElement::HTML_ELEMENT_TEXTAREA,
68
            'subject',
69
            'Subject'
70
        );
71
72
        $description = $this->createElement(
73
            HtmlElement::class,
74
            HtmlElement::HTML_ELEMENT_TEXTAREA,
75
            'description',
76
            'Description'
77
        );
78
79
        $submit = $this->createElement(
80
            HtmlElement::class,
81
            HtmlElement::HTML_ELEMENT_SUBMIT,
82
            'submit',
83
            'Save'
84
        );
85
86
        $this->formAdapter->addElement($name)
87
            ->addElement($title)
88
            ->addElement($introduction)
89
            ->addElement($subject)
90
            ->addElement($description)
91
            ->addElement($submit);
92
    }
93
}
94