CreateFieldCommand::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
rs 8.8571
cc 1
eloc 27
nc 1
nop 13

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\FieldGenerator;
4
5
/**
6
 * Class FieldGeneratorCommand
7
 * @package Hechoenlaravel\JarvisFoundation\FieldGenerator
8
 */
9
class CreateFieldCommand
10
{
11
    /**
12
     * The entity related to the field
13
     * @var
14
     */
15
    public $entity_id;
16
17
    /**
18
     * The field namespace
19
     * @var
20
     */
21
    public $namespace;
22
23
    /**
24
     * the field name
25
     * @var
26
     */
27
    public $name;
28
29
    /**
30
     * The field description
31
     * @var
32
     */
33
    public $description;
34
35
    /**
36
     * the field Slug
37
     * @var
38
     */
39
    public $slug;
40
41
    /**
42
     * is the field locked? meaning cant be removed
43
     * @var
44
     */
45
    public $locked;
46
47
    /**
48
     * Should the field be created in the DB table
49
     * @var
50
     */
51
    public $create_field;
52
53
    /**
54
     * what is the fieldtype
55
     * @var
56
     */
57
    public $type;
58
59
    /**
60
     * is the field required?
61
     * @var
62
     */
63
    public $required;
64
65
    /**
66
     * The field options
67
     * @var
68
     */
69
    public $options;
70
71
    /**
72
     * The field default value
73
     * @var
74
     */
75
    public $default;
76
77
    /**
78
     * is a hidden field?
79
     * @var
80
     */
81
    public $hidden;
82
83
    /**
84
     * Order of the field?
85
     * @var
86
     */
87
    public $order;
88
89
    /**
90
     * @param string $entity_id
91
     * @param string $namespace
92
     * @param string $name
93
     * @param string $description
94
     * @param string $slug
95
     * @param bool $locked
96
     * @param bool $create_field
97
     * @param string $type
98
     */
99
    public function __construct(
100
        $entity_id = "",
101
        $namespace = "",
102
        $name = "",
103
        $description = "",
104
        $slug = "",
105
        $locked = true,
106
        $create_field = true,
107
        $type = "",
108
        $required = false,
109
        $options = [],
110
        $default = null,
111
        $hidden = 0,
112
        $order = null
113
    ) {
114
        $this->entity_id = $entity_id;
115
        $this->namespace = $namespace;
116
        $this->name = $name;
117
        $this->description = $description;
118
        $this->slug = $slug;
119
        $this->locked = $locked;
120
        $this->create_field = $create_field;
121
        $this->type = $type;
122
        $this->required = $required;
123
        $this->options = $options;
124
        $this->default = $default;
125
        $this->hidden = $hidden;
126
        $this->order = $order;
127
    }
128
}
129