29 lines
545 B
PHP
29 lines
545 B
PHP
<?php
|
|
|
|
namespace Tests\Fakes;
|
|
|
|
use App\Plan\CreatePlanDto;
|
|
use App\Plan\Plan;
|
|
use App\Plan\PlanRepository;
|
|
|
|
class FakePlanRepository implements PlanRepository
|
|
{
|
|
private array $existingPlans = [];
|
|
|
|
public function create(CreatePlanDto $dto): Plan
|
|
{
|
|
$id = $this->nextId();
|
|
$plan = new Plan(
|
|
id: $id,
|
|
name: $dto->name,
|
|
);
|
|
$this->existingPlans[$id] = $plan;
|
|
|
|
return $plan;
|
|
}
|
|
|
|
private function nextId(): int
|
|
{
|
|
return count($this->existingPlans);
|
|
}
|
|
}
|