Passed
Push — master ( c01ad7...11b010 )
by Evgenii
01:14
created

dataLayer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helick\GTM;
4
5
/**
6
 * Get the container ID.
7
 *
8
 * @return string
9
 */
10
function containerId(): string
11
{
12
    return defined('GTM_CONTAINER_ID') ? GTM_CONTAINER_ID : '';
0 ignored issues
show
Bug introduced by
The constant Helick\GTM\GTM_CONTAINER_ID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
13
}
14
15
/**
16
 * Get the data layer variable.
17
 *
18
 * @return string
19
 */
20
function dataLayerVariable(): string
21
{
22
    $dataLayerVar = 'dataLayer';
23
24
    /**
25
     * Control the data layer variable.
26
     *
27
     * @param string $dataLayerVar
28
     */
29
    $dataLayerVar = apply_filters('helick_gtm_data_layer_variable', $dataLayerVar);
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

29
    $dataLayerVar = /** @scrutinizer ignore-call */ apply_filters('helick_gtm_data_layer_variable', $dataLayerVar);
Loading history...
30
31
    $dataLayerVar = preg_replace('/[^a-z0-9_\-]/i', '', (string)$dataLayerVar);
32
33
    return $dataLayerVar;
34
}
35
36
/**
37
 * Get the data layer.
38
 *
39
 * @return array
40
 */
41
function dataLayer(): array
42
{
43
    $dataLayer = [];
44
45
    /**
46
     * Control the data layer.
47
     *
48
     * @param array $dataLayer
49
     */
50
    $dataLayer = apply_filters('helick_gtm_data_layer', $dataLayer);
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

50
    $dataLayer = /** @scrutinizer ignore-call */ apply_filters('helick_gtm_data_layer', $dataLayer);
Loading history...
51
52
    return (array)$dataLayer;
53
}
54