Skip to content

Commit

Permalink
Fix psaml error in level 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JonAtrapalo committed Nov 5, 2023
1 parent 3ef43d6 commit ff28b2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/GameGenerator/RandomGameGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __invoke(): Game
$crime = Crime::CAKE;
$gameWithOnlyOneSolution = false;
$lastNumberOfSolutions = 9999999999999;
$game = null;
while (!$gameWithOnlyOneSolution) {
$rule = $this->randomRule();
$game = new Game(array_merge($rules, [$rule]), $crime);
Expand All @@ -56,6 +57,10 @@ public function __invoke(): Game
echo $exception->getMessage() . PHP_EOL;
}
}

if ($game === null) {
throw new \LogicException('This should not happen');
}
echo 'Se ha conseguido crear un juego! ' . PHP_EOL;
return $game;
}
Expand Down Expand Up @@ -83,8 +88,12 @@ private function randomRule(): Rule

private function randomDogAcrossToDogRule(string $className): TwoDogPlaced
{
if (!is_subclass_of($className, TwoDogPlaced::class)) {
throw new \InvalidArgumentException("$className must be a subclass of TwoDogPlaced");
}
$firstDogDefinition = $this->randomDogDefinition();
$secondDogDefinition = $this->randomDogDefinition();

return new $className(
'El perro %s está enfrente del perro %s',
$firstDogDefinition,
Expand Down

0 comments on commit ff28b2e

Please sign in to comment.