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.
Completed
Push — master ( f7073b...51f9c3 )
by Robert
01:20
created

Store::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace HiHaHo\LaravelJsStore;
4
5
use HiHaHo\LaravelJsStore\Exceptions\JsonEncodeStoreDataException;
6
use Illuminate\Contracts\Support\Arrayable;
7
use Illuminate\Contracts\Support\Jsonable;
8
use Illuminate\Support\Collection;
9
10
class Store implements Jsonable, Arrayable
11
{
12
    protected $data;
13
14
    public function __construct()
15
    {
16
        $this->data = new Collection;
17
    }
18
19
    public function put(string $key, $data): self
20
    {
21
        $this->data->put($key, $data);
22
23
        return $this;
24
    }
25
26
    public function data(): Collection
27
    {
28
        return $this->data;
29
    }
30
31
    /**
32
     * Get the instance as an array.
33
     *
34
     * @return array
35
     */
36
    public function toArray()
37
    {
38
        return $this->data->toArray();
39
    }
40
41
    /**
42
     * Convert the object to its JSON representation.
43
     *
44
     * @param  int $options
45
     * @return string
46
     * @throws \Exception
47
     */
48
    public function toJson($options = 0)
49
    {
50
        $json = json_encode($this->data, $options);
51
52
        if (JSON_ERROR_NONE !== json_last_error()) {
53
            throw new JsonEncodeStoreDataException('Unable to encode store data: '. json_last_error_msg());
54
        }
55
56
        return $json;
57
    }
58
59
    /**
60
     * Convert the store to its string representation.
61
     *
62
     * @return string
63
     */
64
    public function __toString()
65
    {
66
        return $this->toJson();
67
    }
68
}
69