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

TokenStack::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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