Conditions | 11 |
Paths | 1024 |
Total Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
31 | public function __construct(array $data = []) |
||
32 | { |
||
33 | if (isset($data['id'])) { |
||
34 | $this->id = $data['id']; |
||
35 | } |
||
36 | |||
37 | if (isset($data['project_id'])) { |
||
38 | $this->projectId = $data['project_id']; |
||
39 | } |
||
40 | |||
41 | if (isset($data['name'])) { |
||
42 | $this->name = $data['name']; |
||
43 | } |
||
44 | |||
45 | if (isset($data['type'])) { |
||
46 | $this->type = $data['type']; |
||
47 | } |
||
48 | |||
49 | if (isset($data['show_in_leads'])) { |
||
50 | $this->showInLeads = $data['show_in_leads']; |
||
51 | } |
||
52 | |||
53 | if (isset($data['show_in_deals'])) { |
||
54 | $this->showInDeals = $data['show_in_deals']; |
||
55 | } |
||
56 | |||
57 | if (isset($data['is_multi_select'])) { |
||
58 | $this->isMultiSelect = $data['is_multi_select']; |
||
59 | } |
||
60 | |||
61 | if (isset($data['is_required'])) { |
||
62 | $this->isRequired = $data['is_required']; |
||
63 | } |
||
64 | |||
65 | if (isset($data['description'])) { |
||
66 | $this->description = $data['description']; |
||
67 | } |
||
68 | |||
69 | if (isset($data['is_multi_line'])) { |
||
70 | $this->isMultiLine = $data['is_multi_line']; |
||
71 | } |
||
72 | |||
73 | } |
||
74 | |||
106 | } |