Skip to content

Commit

Permalink
Updating ResultCollection::getResult() to be able to return bool
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyConnor committed Sep 27, 2024
1 parent 64b6cfa commit f6e1b2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ResultCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ public function exists($sql): bool
/**
* @throws PseudoException
*/
public function getResult(string|ParsedQuery $query): Result
public function getResult(string|ParsedQuery $query): Result|bool
{
if (!($query instanceof ParsedQuery)) {
$query = new ParsedQuery($query);
}
$result = (isset($this->queries[$query->getHash()])) ? $this->queries[$query->getHash()] : null;
if ($result instanceof Result) {
return $result;
} elseif (is_bool($result)) {
return $result;
} else {
$message = "Attempting an operation on an un-mocked query is not allowed, the raw query: "
. $query->getRawQuery();
Expand Down

0 comments on commit f6e1b2c

Please sign in to comment.