Browse Source

add GalaxyFactory service (skeleton)

olinox14 2 tháng trước cách đây
mục cha
commit
000715182f
1 tập tin đã thay đổi với 28 bổ sung0 xóa
  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;
+    }
+}