From f328eb06b3c8cfdf308a98823ac2fb47dbb4f08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pel=C3=AD=C5=A1ek?= Date: Fri, 27 Oct 2023 22:28:19 +0200 Subject: [PATCH] Refactore code into dowhile --- src/Parser.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index 979e04a..b77ac01 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -206,7 +206,7 @@ private function parseSelectionSet() : \Graphpinator\Parser\Field\FieldSet $fields = []; $fragments = []; - while ($this->tokenizer->peekNext()->getType() !== TokenType::CUR_C) { + do { switch ($this->tokenizer->peekNext()->getType()) { case TokenType::ELLIP: $this->tokenizer->getNext(); @@ -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();