Conditions | 13 |
Paths | 22 |
Total Lines | 26 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
90 | public function getEffectiveStyle(string $key) |
||
91 | { |
||
92 | // first look if key style is defined in this element |
||
93 | if (array_key_exists($key, $this->styles)){ |
||
94 | return $this->styles[$key]; |
||
95 | } |
||
96 | |||
97 | // look into parent |
||
98 | if (!$this->parent instanceof HtmlEmailBuilder){ |
||
99 | $style = $this->parent->getEffectiveStyle($key); |
||
100 | if (!empty($style)){ |
||
101 | return $style; |
||
102 | } |
||
103 | } |
||
104 | |||
105 | // get default |
||
106 | if (in_array($key, $this->knowStyles)){ |
||
107 | switch ($key){ |
||
108 | case 'padding-top': return '0'; |
||
109 | case 'padding-bottom': return '0'; |
||
110 | case 'padding-left': return '0'; |
||
111 | case 'padding-right': return '0'; |
||
112 | case 'font-size': return $this->getBuilder()->emailBodyFontSize(); |
||
113 | case 'font-family': return $this->getBuilder()->emailBodyFont(); |
||
114 | case 'color': return $this->getBuilder()->emailBodyColor(); |
||
115 | case 'background-color': return $this->getBuilder()->emailBodyBackground(); |
||
116 | } |
||
147 | } |