Completed
Push — master ( cd38f5...092672 )
by Nico
05:35
created

TokenStack   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 4 1
A getClone() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 * @link        https://github.com/nicoSWD
8
 * @author      Nicolas Oelgart <[email protected]>
9
 */
10
namespace nicoSWD\Rules\Tokenizer;
11
12
use nicoSWD\Rules\Tokens\BaseToken;
13
use SplObjectStorage;
14
15
class TokenStack extends SplObjectStorage
16
{
17
    /** @return BaseToken|null */
18 226
    public function current()
19
    {
20 226
        return parent::current();
21
    }
22
23 190
    public function getClone(): self
24
    {
25 190
        $stackClone = clone $this;
26 190
        $stackClone->rewind();
27
28
        // This is ugly and needs to be fixed
29 190
        while ($stackClone->key() < $this->key()) {
30 162
            $stackClone->next();
31
        }
32
33 190
        return $stackClone;
34
    }
35
}
36