GoogleTagManagerServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 1
A register() 0 14 2
A provides() 0 4 1
1
<?php
2
3
namespace Spatie\GoogleTagManager;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class GoogleTagManagerServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     */
12
    public function boot()
13
    {
14
        $this->package('spatie/googletagmanager', null, __DIR__.'/../resources');
15
16
        $this->app['view']->creator(
17
            ['googletagmanager::script'],
18
            'Spatie\GoogleTagManager\ScriptViewCreator'
19
        );
20
    }
21
22
    /**
23
     * Register the application services.
24
     */
25
    public function register()
26
    {
27
        $this->app['googletagmanager'] = $this->app->share(function ($app) {
28
            $googleTagManager = new GoogleTagManager($app['config']->get('googletagmanager::id'));
29
30
            if ($app['config']->get('googletagmanager::enabled') === false) {
31
                $googleTagManager->disable();
32
            }
33
34
            return $googleTagManager;
35
        });
36
37
        $this->app->bind('Spatie\GoogleTagManager\GoogleTagManager', 'googletagmanager');
0 ignored issues
show
Bug introduced by
The method bind cannot be called on $this->app (of type array<string,?,{"googletagmanager":"?"}>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
38
    }
39
40
    public function provides()
41
    {
42
        return ['googletagmanager'];
43
    }
44
}
45