Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?hh //strict
- final class Arugments
- {
- private int $position = 0;
- private Vector<string> $args;
- public function __construct(
- Traversable<string> $args = []
- )
- {
- $this->args = Vector::fromItems($args);
- }
- public function current(): string {
- return $this->args->at($this->position);
- }
- public function valid(): bool {
- return $this->args->count() > $this->position;
- }
- public function next(): string {
- return $this->args->at($this->position + 1);
- }
- public function has(int $number): int {
- $willConsumedAt = $this->position + $number;
- return $this->args->count() >= $willConsumedAt;
- }
- public function take(int $value): Vector<string> {
- return $this->args->slice($this->position, $value);
- }
- public function consume(int $value = 1) {
- $this->position += $value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement