| Conditions | 7 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 namespace Anomaly\Streams\Platform; |
||
| 22 | public function register() |
||
| 23 | { |
||
| 24 | $this->app->singleton( |
||
| 25 | 'mailer', |
||
| 26 | function () { |
||
| 27 | |||
| 28 | $mailer = new Mailer( |
||
| 29 | $this->app['view'], $this->app['swift.mailer'], $this->app['events'] |
||
| 30 | ); |
||
| 31 | |||
| 32 | $mailer->setContainer($this->app); |
||
| 33 | |||
| 34 | if ($this->app->bound('Psr\Log\LoggerInterface')) { |
||
| 35 | $mailer->setLogger($this->app->make('Psr\Log\LoggerInterface')); |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($this->app->bound('queue')) { |
||
| 39 | $mailer->setQueue($this->app['queue.connection']); |
||
| 40 | } |
||
| 41 | |||
| 42 | $from = $this->app['config']['mail.from']; |
||
| 43 | |||
| 44 | if (is_array($from) && isset($from['address'])) { |
||
| 45 | $mailer->alwaysFrom($from['address'], $from['name']); |
||
| 46 | } |
||
| 47 | |||
| 48 | $to = $this->app['config']['mail.to']; |
||
| 49 | |||
| 50 | if (is_array($to) && isset($to['address'])) { |
||
| 51 | $mailer->alwaysTo($to['address'], $to['name']); |
||
| 52 | } |
||
| 53 | |||
| 54 | $pretend = $this->app['config']->get('mail.pretend', false); |
||
| 55 | |||
| 56 | $mailer->pretend($pretend); |
||
| 57 | |||
| 58 | return $mailer; |
||
| 59 | } |
||
| 60 | ); |
||
| 61 | |||
| 62 | $this->app->singleton( |
||
| 63 | 'Illuminate\Mail\Mailer', |
||
| 64 | function () { |
||
| 65 | return $this->app->make('mailer'); |
||
| 66 | } |
||
| 67 | ); |
||
| 68 | |||
| 69 | $this->app->singleton( |
||
| 70 | 'Illuminate\Contracts\Mail\Mailer', |
||
| 71 | function () { |
||
| 72 | return $this->app->make('mailer'); |
||
| 73 | } |
||
| 74 | ); |
||
| 75 | } |
||
| 76 | } |
||
| 77 |