@@ 45-52 (lines=8) @@ | ||
42 | return array_keys(array_column($this->tokens, 'type'), $tokenType); |
|
43 | } |
|
44 | ||
45 | public function from($tokenType, $inclusive = false) { |
|
46 | $keys = $this->getKeysOfTokenType($tokenType); |
|
47 | if (count($keys) === 0) return new Tokens([]); |
|
48 | $key = $keys[0]; |
|
49 | for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i]; |
|
50 | if (!$inclusive) $key++; |
|
51 | return new Tokens(array_slice($this->tokens, $key)); |
|
52 | } |
|
53 | ||
54 | public function to($tokenType, $inclusive = false) { |
|
55 | $keys = $this->getKeysOfTokenType($tokenType); |
|
@@ 54-61 (lines=8) @@ | ||
51 | return new Tokens(array_slice($this->tokens, $key)); |
|
52 | } |
|
53 | ||
54 | public function to($tokenType, $inclusive = false) { |
|
55 | $keys = $this->getKeysOfTokenType($tokenType); |
|
56 | if (empty($keys)) return new Tokens([]); |
|
57 | $key = $keys[0]; |
|
58 | for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i]; |
|
59 | if ($inclusive) $key++; |
|
60 | return new Tokens(array_slice($this->tokens, 0, $key)); |
|
61 | } |
|
62 | ||
63 | public function skip($count) { |
|
64 | $this->iterator += $count; |