Conditions | 11 |
Paths | 33 |
Total Lines | 50 |
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 |
||
128 | protected function _validates() |
||
129 | { |
||
130 | // Verifica que se pueda escribir en el directorio |
||
131 | if (!is_writable($this->_path)) { |
||
132 | Flash::error('Error: no se puede escribir en el directorio'); |
||
133 | return FALSE; |
||
134 | } |
||
135 | |||
136 | |||
137 | $image = $this->_imgInfo; |
||
138 | // Verifica que sea un archivo de imagen |
||
139 | if (!$image){ |
||
140 | Flash::error('Error: el archivo debe ser una imagen'); |
||
141 | return FALSE; |
||
142 | } |
||
143 | |||
144 | // Verifica ancho minimo de la imagen |
||
145 | if ($this->_minWidth !== NULL) { |
||
146 | if ($image[0] < $this->_minWidth) { |
||
147 | Flash::error("Error: el ancho de la imagen debe ser superior o igual a {$this->_minWidth}px"); |
||
148 | return FALSE; |
||
149 | } |
||
150 | } |
||
151 | |||
152 | // Verifica ancho maximo de la imagen |
||
153 | if ($this->_maxWidth !== NULL) { |
||
154 | if ($image[0] > $this->_maxWidth) { |
||
155 | Flash::error("Error: el ancho de la imagen debe ser inferior o igual a {$this->_maxWidth}px"); |
||
156 | return FALSE; |
||
157 | } |
||
158 | } |
||
159 | |||
160 | // Verifica alto minimo de la imagen |
||
161 | if ($this->_minHeight !== NULL) { |
||
162 | if ($image[1] < $this->_minHeight) { |
||
163 | Flash::error("Error: el alto de la imagen debe ser superior o igual a {$this->_minHeight}px"); |
||
164 | return FALSE; |
||
165 | } |
||
166 | } |
||
167 | |||
168 | // Verifica alto maximo de la imagen |
||
169 | if ($this->_maxHeight !== NULL) { |
||
170 | if ($image[1] > $this->_maxHeight) { |
||
171 | Flash::error("Error: el alto de la imagen debe ser inferior o igual a {$this->_maxHeight}px"); |
||
172 | return FALSE; |
||
173 | } |
||
174 | } |
||
175 | |||
176 | // Validaciones |
||
177 | return parent::_validates(); |
||
178 | } |
||
209 |