Completed
Push — develop ( c61561...247dd8 )
by
unknown
09:15
created

PreferredJobFieldset::init()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 88
Code Lines 61

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 88
rs 8.6012
cc 1
eloc 61
nc 1
nop 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
namespace Cv\Form;
4
5
use Cv\Entity\PreferredJob;
6
use Zend\Form\Fieldset;
7
use Core\Entity\Hydrator\EntityHydrator;
8
9
class PreferredJobFieldset extends Fieldset
10
{
11
    /**
12
     * Type of Application Options
13
     *
14
     * @var array
15
     */
16
    public static $typoOfApplicationOptions = [
17
        '' => '', // needed for jquery select2 to render the placeholder
18
        "temporary" => /*@translate*/ "Temporary",
19
        "permanent" => /*@translate*/ "Permanent",
20
        "contract"=> /*@translate*/ "Contracting",
21
        "freelance" => /*@translate*/ "Freelance",
22
        "internship" => /*@translate*/ "Internship"
23
    ];
24
25
    public static $willingnessToTravelOptions = [
26
        '' => '', // needed for jquery select2 to render the placeholder
27
        "yes"=>/*@translate*/ "Yes",
28
        "conditioned" => /*@translate*/ "conditioned",
29
        "no"=>/*@translate*/ "No"
30
    ];
31
32
    public function init()
33
    {
34
        $this->setName('preferredJob')
35
             ->setHydrator(new EntityHydrator())
36
             ->setObject(new PreferredJob())
37
             ->setLabel('Desired Employment');
38
39
        $this->add(
40
            array(
41
                'name' => 'typeOfApplication',
42
                'type' => 'select',
43
                'options' => [
44
                    'value_options' => self::$typoOfApplicationOptions,
45
                    'label' => /*@translate */ 'desired type of work',
46
                    'description' => /*@translate*/ 'Do you want to work permanently or temporary?',
47
                ],
48
                'attributes' => array(
49
                    'title' => /*@translate */ 'please describe your position',
50
                    'description' => 'what kind of ',
51
                    'data-placeholder' => /*@translate*/ 'please select',
52
                    'data-allowclear' => 'false',
53
                    'data-searchbox' => -1,
54
                    'multiple' => true,
55
                    'data-width' => '100%',
56
                ),
57
            )
58
        );
59
60
        $this->add(
61
            array(
62
                'name' => 'desiredJob',
63
                'type' => 'Text',
64
                'options' => array(
65
                        'label' => /*@translate */ 'desired job position',
66
                        'description' => /*@translate*/ 'Enter the title of your desired job. Eg. "Software Developer" or "Customer Service Representative"',
67
                ),
68
                'attributes' => array(
69
                        'title' => /*@translate */ 'please describe your position',
70
                ),
71
            )
72
        );
73
74
        $this->add(
75
            array(
76
                'name' => 'desiredLocations',
77
                'type' => 'Location',
78
                'options' => array(
79
                    'label' => /*@translate */ 'desired job location',
80
                    'description' => /*@translate*/ 'Where do you want to work?',
81
                ),
82
                'attributes' => array(
83
                    'title' => /*@translate */ 'please describe your position',
84
                ),
85
            )
86
        );
87
88
        $this->add(
89
            array(
90
                'name' => 'willingnessToTravel',
91
                'type' => 'Select',
92
                'options' => array(
93
                    'value_options' => self::$willingnessToTravelOptions,
94
                    'label' => /*@translate*/ 'Willingness to travel',
95
                    'description' => /*@translate*/ 'Enter your willingness to travel.',
96
                ),
97
                'attributes' => array(
98
                    'data-placeholder' => /*@translate*/ 'please select',
99
                    'data-allowclear' => 'false',
100
                    'data-searchbox' => -1,
101
                    'data-width' => '100%'
102
                ),
103
            )
104
        );
105
106
        $this->add(
107
            array(
108
                'name' => 'expectedSalary',
109
                'type' => 'Text',
110
                'options' => array(
111
                    'label' => /*@translate */ 'expected Salary',
112
                    'description' => /*@translate*/ 'What is your expected Salary?',
113
                ),
114
                'attributes' => array(
115
                    'title' => /*@translate */ 'please describe your position',
116
                ),
117
            )
118
        );
119
    }
120
}
121