| Conditions | 11 |
| Paths | 20 |
| Total Lines | 37 |
| Code Lines | 30 |
| 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 |
||
| 52 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
||
| 53 | { |
||
| 54 | $config = $container->get('config'); |
||
| 55 | if ($config instanceof Traversable) { |
||
| 56 | $config = ArrayUtils::iteratorToArray($config); |
||
| 57 | } |
||
| 58 | $config = $config['OrgHeiglContact']['mail_transport']; |
||
| 59 | $class = $config['class']; |
||
| 60 | $options = $config['options']; |
||
| 61 | |||
| 62 | switch ($class) { |
||
| 63 | case 'Zend\Mail\Transport\Sendmail': |
||
| 64 | case 'Sendmail': |
||
| 65 | case 'sendmail'; |
||
| 66 | $transport = new Transport\Sendmail(); |
||
| 67 | break; |
||
| 68 | case 'Zend\Mail\Transport\Smtp'; |
||
| 69 | case 'Smtp'; |
||
| 70 | case 'smtp'; |
||
| 71 | $options = new Transport\SmtpOptions($options); |
||
| 72 | $transport = new Transport\Smtp($options); |
||
| 73 | break; |
||
| 74 | case 'Zend\Mail\Transport\File'; |
||
| 75 | case 'File'; |
||
| 76 | case 'file'; |
||
| 77 | $options = new Transport\FileOptions($options); |
||
| 78 | $transport = new Transport\File($options); |
||
| 79 | break; |
||
| 80 | default: |
||
| 81 | throw new \DomainException(sprintf( |
||
| 82 | 'Unknown mail transport type provided ("%s")', |
||
| 83 | $class |
||
| 84 | )); |
||
| 85 | } |
||
| 86 | |||
| 87 | return $transport; |
||
| 88 | } |
||
| 89 | } |
||
| 90 |