| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 92 | 
| Code Lines | 65 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| 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 | ||
| 331 | public function getPreferencesPane() | ||
| 332 |     { | ||
| 333 | parent::getPreferencesPane(); | ||
| 334 |         $group = new XMLElement('fieldset'); | ||
| 335 |         $group->setAttribute('class', 'settings condensed pickable'); | ||
| 336 |         $group->setAttribute('id', 'smtp'); | ||
| 337 |         $group->appendChild(new XMLElement('legend', __('Email: SMTP'))); | ||
| 338 | |||
| 339 |         $div = new XMLElement('div'); | ||
| 340 | |||
| 341 |         $readonly = array('readonly' => 'readonly'); | ||
| 342 | |||
| 343 |         $label = Widget::Label(__('HELO Hostname')); | ||
| 344 |         $label->appendChild(Widget::Input('settings[email_smtp][helo_hostname]', General::sanitize($this->_helo_hostname), 'text', $readonly)); | ||
| 345 | $div->appendChild($label); | ||
| 346 | |||
| 347 | $group->appendChild($div); | ||
| 348 |         $group->appendChild(new XMLElement('p', __('A fully qualified domain name (FQDN) of your server, e.g. "www.example.com". If left empty, Symphony will attempt to find an IP address for the EHLO/HELO greeting.'), array('class' => 'help'))); | ||
| 349 | |||
| 350 |         $div = new XMLElement('div'); | ||
| 351 |         $div->setAttribute('class', 'two columns'); | ||
| 352 | |||
| 353 |         $label = Widget::Label(__('From Name')); | ||
| 354 |         $label->setAttribute('class', 'column'); | ||
| 355 |         $label->appendChild(Widget::Input('settings[email_smtp][from_name]', General::sanitize($this->_sender_name), 'text', $readonly)); | ||
| 356 | $div->appendChild($label); | ||
| 357 | |||
| 358 |         $label = Widget::Label(__('From Email Address')); | ||
| 359 |         $label->setAttribute('class', 'column'); | ||
| 360 |         $label->appendChild(Widget::Input('settings[email_smtp][from_address]', General::sanitize($this->_sender_email_address), 'text', $readonly)); | ||
| 361 | $div->appendChild($label); | ||
| 362 | |||
| 363 | $group->appendChild($div); | ||
| 364 | |||
| 365 |         $div = new XMLElement('div'); | ||
| 366 |         $div->setAttribute('class', 'two columns'); | ||
| 367 | |||
| 368 |         $label = Widget::Label(__('Host')); | ||
| 369 |         $label->setAttribute('class', 'column'); | ||
| 370 |         $label->appendChild(Widget::Input('settings[email_smtp][host]', General::sanitize($this->_host), 'text', $readonly)); | ||
| 371 | $div->appendChild($label); | ||
| 372 | |||
| 373 |         $label = Widget::Label(__('Port')); | ||
| 374 |         $label->setAttribute('class', 'column'); | ||
| 375 |         $label->appendChild(Widget::Input('settings[email_smtp][port]', General::sanitize((string) $this->_port), 'text', $readonly)); | ||
| 376 | $div->appendChild($label); | ||
| 377 | $group->appendChild($div); | ||
| 378 | |||
| 379 | $label = Widget::Label(); | ||
| 380 |         $label->setAttribute('class', 'column'); | ||
| 381 | // To fix the issue with checkboxes that do not send a value when unchecked. | ||
| 382 | $options = array( | ||
| 383 |             array('no',$this->_secure == 'no', __('No encryption')), | ||
| 384 |             array('ssl',$this->_secure == 'ssl', __('SSL encryption')), | ||
| 385 |             array('tls',$this->_secure == 'tls', __('TLS encryption')), | ||
| 386 | ); | ||
| 387 |         $select = Widget::Select('settings[email_smtp][secure]', $options, $readonly); | ||
| 388 | $label->appendChild($select); | ||
| 389 | $group->appendChild($label); | ||
| 390 | |||
| 391 |         $group->appendChild(new XMLElement('p', __('For a secure connection, SSL and TLS are supported. Please check the manual of your email provider for more details.'), array('class' => 'help'))); | ||
| 392 | |||
| 393 | $label = Widget::Label(); | ||
| 394 |         $label->setAttribute('class', 'column'); | ||
| 395 | // To fix the issue with checkboxes that do not send a value when unchecked. | ||
| 396 |         $group->appendChild(Widget::Input('settings[email_smtp][auth]', '0', 'hidden')); | ||
| 397 |         $input = Widget::Input('settings[email_smtp][auth]', '1', 'checkbox', $readonly); | ||
| 398 | |||
| 399 |         if ($this->_auth === true) { | ||
| 400 |             $input->setAttribute('checked', 'checked'); | ||
| 401 | } | ||
| 402 | |||
| 403 |         $label->setValue(__('%s Requires authentication', array($input->generate()))); | ||
| 404 | $group->appendChild($label); | ||
| 405 | |||
| 406 |         $group->appendChild(new XMLElement('p', __('Some SMTP connections require authentication. If that is the case, enter the username/password combination below.'), array('class' => 'help'))); | ||
| 407 | |||
| 408 |         $div = new XMLElement('div'); | ||
| 409 |         $div->setAttribute('class', 'two columns'); | ||
| 410 | |||
| 411 |         $label = Widget::Label(__('Username')); | ||
| 412 |         $label->setAttribute('class', 'column'); | ||
| 413 |         $label->appendChild(Widget::Input('settings[email_smtp][username]', General::sanitize($this->_user), 'text', array_merge($readonly, array('autocomplete' => 'off')))); | ||
| 414 | $div->appendChild($label); | ||
| 415 | |||
| 416 |         $label = Widget::Label(__('Password')); | ||
| 417 |         $label->setAttribute('class', 'column'); | ||
| 418 |         $label->appendChild(Widget::Input('settings[email_smtp][password]', General::sanitize($this->_pass), 'password', array_merge($readonly, array('autocomplete' => 'off')))); | ||
| 419 | $div->appendChild($label); | ||
| 420 | $group->appendChild($div); | ||
| 421 | |||
| 422 | return $group; | ||
| 423 | } | ||
| 425 |