Skip to content

Commit

Permalink
Refactore code into dowhile
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Oct 27, 2023
1 parent 1445936 commit f328eb0
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private function parseSelectionSet() : \Graphpinator\Parser\Field\FieldSet
$fields = [];
$fragments = [];

while ($this->tokenizer->peekNext()->getType() !== TokenType::CUR_C) {
do {

Check warning on line 209 in src/Parser.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "DoWhile": --- Original +++ New @@ @@ default: throw new \Graphpinator\Parser\Exception\ExpectedSelectionSetBody($this->tokenizer->getNext()->getLocation(), $this->tokenizer->getCurrent()->getType()); } - } while ($this->tokenizer->peekNext()->getType() !== TokenType::CUR_C); + } while (false); $this->tokenizer->getNext(); return new \Graphpinator\Parser\Field\FieldSet($fields, new \Graphpinator\Parser\FragmentSpread\FragmentSpreadSet($fragments)); }
switch ($this->tokenizer->peekNext()->getType()) {
case TokenType::ELLIP:
$this->tokenizer->getNext();
Expand All @@ -224,14 +224,7 @@ private function parseSelectionSet() : \Graphpinator\Parser\Field\FieldSet
$this->tokenizer->getCurrent()->getType(),
);
}
}

if (\count($fields) === 0 && \count($fragments) === 0) {
throw new \Graphpinator\Parser\Exception\ExpectedSelectionSetBody(
$this->tokenizer->getNext()->getLocation(),
$this->tokenizer->getCurrent()->getType(),
);
}
} while ($this->tokenizer->peekNext()->getType() !== TokenType::CUR_C);

$this->tokenizer->getNext();

Expand Down

0 comments on commit f328eb0

Please sign in to comment.