GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DataLayer::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\GoogleTagManager;
4
5
use Illuminate\Support\Arr;
6
7
class DataLayer
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $data;
13
14
    public function __construct($data = [])
15
    {
16
        $this->data = $data;
17
    }
18
19
    /**
20
     * Add data to the data layer. Supports dot notation.
21
     * Inspired by laravel's config repository class.
22
     *
23
     * @param array|string $key
24
     * @param mixed        $value
25
     */
26
    public function set($key, $value = null)
27
    {
28
        if (is_array($key)) {
29
            foreach ($key as $innerKey => $innerValue) {
30
                Arr::set($this->data, $innerKey, $innerValue);
31
            }
32
33
            return;
34
        }
35
36
        Arr::set($this->data, $key, $value);
37
    }
38
39
    /**
40
     * Empty the data layer.
41
     */
42
    public function clear()
43
    {
44
        $this->data = [];
45
    }
46
47
    /**
48
     * Return an array representation of the data layer.
49
     *
50
     * @return array
51
     */
52
    public function toArray()
53
    {
54
        return $this->data;
55
    }
56
57
    /**
58
     * Return a json representation of the data layer.
59
     *
60
     * @return string
61
     */
62
    public function toJson()
63
    {
64
        return json_encode($this->data, JSON_UNESCAPED_UNICODE);
65
    }
66
}
67