| Conditions | 5 |
| Paths | 1 |
| Total Lines | 27 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function register() |
||
| 24 | { |
||
| 25 | $this->app->singleton(Newsletter::class, function () { |
||
| 26 | $driver = config('newsletter.driver', null); |
||
| 27 | if ($driver === null || $driver === 'log') { |
||
| 28 | return new NullDriver($driver === 'log'); |
||
| 29 | } |
||
| 30 | |||
| 31 | $config = [ |
||
| 32 | 'defaultList' => config('newsletter.defaultList'), |
||
| 33 | 'lists' => config('newsletter.lists'), |
||
| 34 | ]; |
||
| 35 | |||
| 36 | switch ($driver) { |
||
| 37 | case 'mailchimp': |
||
| 38 | $driver = new MailchimpDriver(config('newsletter.mailchimp'), $config); |
||
| 39 | break; |
||
| 40 | case 'mailjet': |
||
| 41 | $config['connection_timeout'] = config('newsletter.mailjet.connection_timeout'); |
||
| 42 | $driver = new MailjetDriver(config('newsletter.mailjet'), $config); |
||
| 43 | break; |
||
| 44 | } |
||
| 45 | |||
| 46 | return new Newsletter($driver); |
||
| 47 | }); |
||
| 48 | |||
| 49 | $this->app->alias(Newsletter::class, 'newsletter'); |
||
| 50 | } |
||
| 52 |