Passed
Push — 2.x ( 80852e...f92d9a )
by Akihito
11:07 queued 14s
created

TokenIterator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getToken() 0 6 2
A skipExtends() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop;
6
7
use ArrayIterator;
8
9
use function is_array;
10
11
/**
12
 * @template TKey of array-key
13
 * @template TValue of array{int, string, int}|string
14
 * @template-extends ArrayIterator<TKey, TValue>
15
 */
16
final class TokenIterator extends ArrayIterator
17
{
18
    /** @return array{int, string} */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{int, string} at position 2 could not be parsed: Expected ':' at position 2, but found 'int'.
Loading history...
19
    public function getToken(): array
20
    {
21
        /** @var array{int, string, int}|string $token */
22
        $token = $this->current();
23
24
        return is_array($token) ? [$token[0], $token[1]] : [0, $token];
25
    }
26
27
    public function skipExtends(): void
28
    {
29
        $this->next();  // Skip extends keyword
30
        $this->next();  // Skip parent class name
31
        $this->next();  // Skip space
32
    }
33
}
34