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