LaravelFacebookPixelServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 16
c 5
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 11 1
A register() 0 14 3
1
<?php
2
3
namespace WebLAgence\LaravelFacebookPixel;
4
5
use Illuminate\Support\ServiceProvider;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\ServiceProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * Class LaravelFacebookPixelServiceProvider
9
 * @package WebLAgence\LaravelFacebookPixel
10
 */
11
class LaravelFacebookPixelServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application events.
15
     */
16
    public function boot()
17
    {
18
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'facebook-pixel');
19
    
20
        $this->publishes([
21
            __DIR__.'/../resources/config/facebook-pixel.php' => config_path('facebook-pixel.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
            __DIR__.'/../resources/config/facebook-pixel.php' => /** @scrutinizer ignore-call */ config_path('facebook-pixel.php'),
Loading history...
22
        ], 'config');
23
        
24
        $this->app['view']->creator(
25
            ['facebook-pixel::head', 'facebook-pixel::body'],
26
            'WebLAgence\LaravelFacebookPixel\ScriptViewCreator'
27
        );
28
    }
29
    
30
    /**
31
     * Register the service provider.
32
     */
33
    public function register()
34
    {
35
        $this->mergeConfigFrom(__DIR__.'/../resources/config/facebook-pixel.php', 'facebook-pixel');
36
        
37
        $id = !empty(config('facebook-pixel.facebook_pixel_ids')) ? config('facebook-pixel.facebook_pixel_ids') : [config('facebook-pixel.facebook_pixel_id')];
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $id = !empty(/** @scrutinizer ignore-call */ config('facebook-pixel.facebook_pixel_ids')) ? config('facebook-pixel.facebook_pixel_ids') : [config('facebook-pixel.facebook_pixel_id')];
Loading history...
38
        
39
        $laravelFacebookPixel = new LaravelFacebookPixel($id);
40
        $laravelFacebookPixel->addCspNonce(config('facebook-pixel.csp_callback'));
41
        if (config('facebook-pixel.enabled') === false) {
42
            $laravelFacebookPixel->disable();
43
        }
44
        
45
        $this->app->instance('WebLAgence\LaravelFacebookPixel\LaravelFacebookPixel', $laravelFacebookPixel);
46
        $this->app->alias(LaravelFacebookPixel::class, 'facebook-pixel');
47
    }
48
}