Add an arrivedAt property to starship and print it.

This commit is contained in:
Krzysztof Płaczek
2024-10-19 16:53:07 +02:00
parent d5dc033be9
commit c2998606b5
3 changed files with 21 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ class Starship
private string $class, private string $class,
private string $captain, private string $captain,
private StarshipStatusEnum $status, private StarshipStatusEnum $status,
private \DateTimeImmutable $arrivedAt,
) { ) {
} }
@@ -53,4 +54,9 @@ class Starship
StarshipStatusEnum::COMPLETED => '/images/status-complete.png', StarshipStatusEnum::COMPLETED => '/images/status-complete.png',
}; };
} }
public function getArrivedAt(): \DateTimeImmutable
{
return $this->arrivedAt;
}
} }

View File

@@ -17,18 +17,18 @@ class StarshipRepository
$this->logger->info('Starship Repository: Finding Starships'); $this->logger->info('Starship Repository: Finding Starships');
return [ return [
new Starship(1, 'Starship 01', 'Heavy Starship', 'Human Captain', StarshipStatusEnum::COMPLETED), new Starship(1, 'Starship 01', 'Heavy Starship', 'Human Captain', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()),
new Starship(2, 'Starship 02', 'Light Starship', 'Robot Captain', StarshipStatusEnum::IN_PROGRESS), new Starship(2, 'Starship 02', 'Light Starship', 'Robot Captain', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()),
new Starship(3, 'USS Voyager', 'Intrepid', 'Kathryn Janeway', StarshipStatusEnum::WAITING), new Starship(3, 'USS Voyager', 'Intrepid', 'Kathryn Janeway', StarshipStatusEnum::WAITING, new \DateTimeImmutable()),
new Starship(4, 'Starblade', 'Interceptor', 'Lance Stellar', StarshipStatusEnum::COMPLETED), new Starship(4, 'Starblade', 'Interceptor', 'Lance Stellar', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()),
new Starship(5, 'Black Star', 'Battlecruiser', 'Zara Nox', StarshipStatusEnum::WAITING), new Starship(5, 'Black Star', 'Battlecruiser', 'Zara Nox', StarshipStatusEnum::WAITING, new \DateTimeImmutable()),
new Starship(6, 'SS Horizon', 'Explorer', 'James Marshall', StarshipStatusEnum::COMPLETED), new Starship(6, 'SS Horizon', 'Explorer', 'James Marshall', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()),
new Starship(7, 'Nebula Queen', 'Transport', 'Elara Trent', StarshipStatusEnum::IN_PROGRESS), new Starship(7, 'Nebula Queen', 'Transport', 'Elara Trent', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()),
new Starship(8, 'Celestial Wave', 'Frigate', 'Talon Skye', StarshipStatusEnum::IN_PROGRESS), new Starship(8, 'Celestial Wave', 'Frigate', 'Talon Skye', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()),
new Starship(9, 'Galactic Serpent', 'Destroyer', 'Viktor Helios', StarshipStatusEnum::COMPLETED), new Starship(9, 'Galactic Serpent', 'Destroyer', 'Viktor Helios', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()),
new Starship(10, 'Phoenix Wing', 'Carrier', 'Aurora Drake', StarshipStatusEnum::COMPLETED), new Starship(10, 'Phoenix Wing', 'Carrier', 'Aurora Drake', StarshipStatusEnum::COMPLETED, new \DateTimeImmutable()),
new Starship(11, 'Silver Comet', 'Scout', 'Finn O\'Neil', StarshipStatusEnum::WAITING), new Starship(11, 'Silver Comet', 'Scout', 'Finn O\'Neil', StarshipStatusEnum::WAITING, new \DateTimeImmutable()),
new Starship(12, 'Crimson Spear', 'Corvette', 'Raven Callen', StarshipStatusEnum::IN_PROGRESS), new Starship(12, 'Crimson Spear', 'Corvette', 'Raven Callen', StarshipStatusEnum::IN_PROGRESS, new \DateTimeImmutable()),
]; ];
} }

View File

@@ -28,6 +28,9 @@
href="{{ path('app_starship_show', {id: ship.id}) }}" href="{{ path('app_starship_show', {id: ship.id}) }}"
>{{ ship.name }}</a> >{{ ship.name }}</a>
</h4> </h4>
<div>
Arrived at: {{ ship.arrivedAt|date }}
</div>
</div> </div>
</div> </div>
<div class="flex justify-center min-[1174px]:justify-start mt-2 min-[1174px]:mt-0 shrink-0"> <div class="flex justify-center min-[1174px]:justify-start mt-2 min-[1174px]:mt-0 shrink-0">