Ver código fonte

add GalaxyFactory service (skeleton)

olinox14 2 meses atrás
pai
commit
000715182f
1 arquivos alterados com 28 adições e 0 exclusões
  1. 28 0
      api/src/Services/GalaxyFactory.php

+ 28 - 0
api/src/Services/GalaxyFactory.php

@@ -0,0 +1,28 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Services;
+
+use App\Entity\Galaxy;
+use App\Entity\Sector;
+
+class GalaxyFactory
+{
+    public function createGalaxy(int $nbSectors = 1000): Galaxy
+    {
+        $galaxy = new Galaxy();
+
+        for ($i = 0; $i < $nbSectors; $i++) {
+            $sector = $this->createSector();
+            $galaxy->addSector($sector);
+        }
+
+        return $galaxy;
+    }
+
+    protected function createSector(): Sector {
+        $sector = new Sector();
+
+        return $sector;
+    }
+}