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

Stack   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
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 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