ServiceProvider::registerEmailEngine()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Lanin\Laravel\EmailTemplatesOptimization;
4
5
use Illuminate\View\Engines\CompilerEngine;
6
7
class ServiceProvider extends \Illuminate\Support\ServiceProvider
8
{
9
    /**
10
     * Bootstrap any application services.
11
     *
12
     * @return void
13
     */
14 3
    public function boot()
15
    {
16 3
        $configPath = __DIR__ . '/../config/view.php';
17
18 3
        $this->mergeConfigFrom($configPath, 'view');
19 3
    }
20
21
    /**
22
     * Register the service provider.
23
     *
24
     * @return void
25
     */
26 3
    public function register()
27
    {
28 3
        $this->registerEmailEngine();
29 3
    }
30
31
    /**
32
     * Register the Blade engine implementation.
33
     *
34
     * @return void
35
     */
36 3
    public function registerEmailEngine()
37
    {
38 3
        $app = $this->app;
39
40
        $app->bind('email.compiler', function () use ($app) {
41 2
            $cache = $app['config']['view.compiled'];
42 2
            $css = $app['config']['view.emails.css_files'];
43
44 2
            return new Compiler($app['files'], $cache, $css);
45 3
        });
46
47 3
        $app['view']->addExtension('email.php', 'email', function () use ($app) {
48 1
            return new CompilerEngine($app['email.compiler']);
49 3
        });
50 3
    }
51
52
    /**
53
     * Get the services provided by the provider.
54
     *
55
     * @return array
56
     */
57 1
    public function provides()
58
    {
59
        return [
60
            'email.compiler'
61 1
        ];
62
    }
63
}