Passed
Push — master ( ea8435...2f16f0 )
by Evgenii
01:11
created

EventTracking::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helick\GTM;
4
5
use Helick\GTM\Contracts\Bootable;
6
7
final class EventTracking implements Bootable
8
{
9
    /**
10
     * Boot the service.
11
     *
12
     * @return void
13
     */
14
    public static function boot(): void
15
    {
16
        $self = new static;
17
18
        add_action('wp_enqueue_scripts', [$self, 'enqueueScripts']);
0 ignored issues
show
Bug introduced by
The function add_action 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

18
        /** @scrutinizer ignore-call */ 
19
        add_action('wp_enqueue_scripts', [$self, 'enqueueScripts']);
Loading history...
19
    }
20
21
    /**
22
     * Enqueue scripts.
23
     *
24
     * @return void
25
     */
26
    public function enqueueScripts(): void
27
    {
28
        /**
29
         * Control whether to load the data attribute tracking script.
30
         *
31
         * @param bool $isEnabled
32
         */
33
        $isEnabled = apply_filters('helick_gtm_enable_event_tracking', true);
0 ignored issues
show
Bug introduced by
The function apply_filters 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

33
        $isEnabled = /** @scrutinizer ignore-call */ apply_filters('helick_gtm_enable_event_tracking', true);
Loading history...
34
35
        if (!$isEnabled) {
36
            return;
37
        }
38
39
        wp_enqueue_script(
0 ignored issues
show
Bug introduced by
The function wp_enqueue_script 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

39
        /** @scrutinizer ignore-call */ 
40
        wp_enqueue_script(
Loading history...
40
            'helick-gtm-event-tracking',
41
            plugin_dir_url(dirname(__FILE__)) . 'resources/js/event-tracking.js',
0 ignored issues
show
Bug introduced by
The function plugin_dir_url 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

41
            /** @scrutinizer ignore-call */ 
42
            plugin_dir_url(dirname(__FILE__)) . 'resources/js/event-tracking.js',
Loading history...
42
            [],
43
            filemtime(plugin_dir_path(dirname(__FILE__)) . 'resources/js/event-tracking.js'),
0 ignored issues
show
Bug introduced by
The function plugin_dir_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

43
            filemtime(/** @scrutinizer ignore-call */ plugin_dir_path(dirname(__FILE__)) . 'resources/js/event-tracking.js'),
Loading history...
44
            true
45
        );
46
    }
47
}
48