Conditions | 10 |
Paths | 10 |
Total Lines | 38 |
Code Lines | 24 |
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 |
||
87 | public function build(array $parameters) |
||
88 | { |
||
89 | foreach ($parameters as $property => $value) { |
||
90 | switch ($property) { |
||
91 | case 'forwarding_rules': |
||
92 | |||
93 | foreach ($value as $forwardingRule) { |
||
94 | $this->forwardingRules[] = new ForwardingRule($forwardingRule); |
||
95 | } |
||
96 | |||
97 | unset($parameters[$property]); |
||
98 | break; |
||
99 | |||
100 | case 'health_check': |
||
101 | if (is_object($value)) { |
||
102 | $this->healthCheck = new HealthCheck($value); |
||
103 | } |
||
104 | unset($parameters[$property]); |
||
105 | break; |
||
106 | |||
107 | case 'sticky_sessions': |
||
108 | if (is_object($value)) { |
||
109 | $this->stickySessions = new StickySession($value); |
||
110 | } |
||
111 | unset($parameters[$property]); |
||
112 | break; |
||
113 | |||
114 | case 'region': |
||
115 | if (is_object($value)) { |
||
116 | $this->region = new Region($value); |
||
117 | } |
||
118 | unset($parameters[$property]); |
||
119 | break; |
||
120 | } |
||
121 | } |
||
122 | |||
123 | parent::build($parameters); |
||
124 | } |
||
125 | |||
145 |