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.

Collection   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 65
rs 10
c 1
b 0
f 0
wmc 14

12 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 3 1
A offsetExists() 0 3 1
A offsetSet() 0 6 2
A jsonSerialize() 0 3 1
A all() 0 3 1
A toArray() 0 3 1
A join() 0 5 2
A offsetGet() 0 3 1
A offsetUnset() 0 3 1
A __construct() 0 2 1
A toJson() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace Overtrue\Pinyin;
4
5
use ArrayAccess;
6
use JsonSerializable;
7
use Stringable;
8
9
class Collection implements ArrayAccess, JsonSerializable, Stringable
10
{
11
    public function __construct(protected $items = [])
12
    {
13
    }
14
15
    public function join(string $separator = ' '): string
16
    {
17
        return implode($separator, \array_map(function ($item) {
18
            return \is_array($item) ? '['.\implode(', ', $item).']' : $item;
19
        }, $this->items));
20
    }
21
22
    public function map(callable $callback): Collection
23
    {
24
        return new static(array_map($callback, $this->all()));
25
    }
26
27
    public function all(): array
28
    {
29
        return $this->items;
30
    }
31
32
    public function toArray(): array
33
    {
34
        return $this->all();
35
    }
36
37
    public function toJson(int $options = 0): string
38
    {
39
        return json_encode($this->all(), $options);
40
    }
41
42
    public function __toString()
43
    {
44
        return $this->join();
45
    }
46
47
    public function offsetExists(mixed $offset): bool
48
    {
49
        return isset($this->items[$offset]);
50
    }
51
52
    public function offsetGet(mixed $offset): mixed
53
    {
54
        return $this->items[$offset] ?? null;
55
    }
56
57
    public function offsetSet(mixed $offset, mixed $value): void
58
    {
59
        if (null === $offset) {
60
            $this->items[] = $value;
61
        } else {
62
            $this->items[$offset] = $value;
63
        }
64
    }
65
66
    public function offsetUnset(mixed $offset): void
67
    {
68
        unset($this->items[$offset]);
69
    }
70
71
    public function jsonSerialize(): mixed
72
    {
73
        return $this->items;
74
    }
75
}
76