Completed
Push — master ( f06ad0...9cb85d )
by Nico
06:26
created

Stack::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 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
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 Stack extends SplObjectStorage
16
{
17
    /**
18
     * @return BaseToken|null
19
     */
20 226
    public function current()
21
    {
22 226
        return parent::current();
23
    }
24
25 190
    public function getClone(): self
26
    {
27 190
        $stackClone = clone $this;
28 190
        $stackClone->rewind();
29
30
        // This is ugly and needs to be fixed
31 190
        while ($stackClone->key() < $this->key()) {
32 162
            $stackClone->next();
33
        }
34
35 190
        return $stackClone;
36
    }
37
}
38