diff --git a/psalm.xml b/psalm.xml index 8be3a1d..424fc7d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ randomRule(); $game = new Game(array_merge($rules, [$rule]), $crime); @@ -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; } @@ -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,