remove set creation

This commit is contained in:
Yisroel Baum 2026-05-25 08:25:17 +03:00
parent f62b05bc37
commit 914cbd37a1
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 0 additions and 71 deletions

View file

@ -1,10 +0,0 @@
<?php
namespace App\Set;
class CreateSetDto
{
public function __construct(
public string $name,
) {}
}

View file

@ -4,15 +4,6 @@ namespace App\Set;
class EloquentSetRepository implements SetRepository
{
public function create(CreateSetDto $dto): Set
{
$model = SetModel::create([
'name' => $dto->name,
]);
return $this->toDomain($model);
}
public function find(int $id): ?Set
{
$model = SetModel::find($id);

View file

@ -4,8 +4,6 @@ namespace App\Set;
interface SetRepository
{
public function create(CreateSetDto $dto): Set;
public function find(int $id): ?Set;
/**

View file

@ -1,40 +0,0 @@
<?php
namespace App\Set\UseCases\CreateSet;
use App\Element\CreateElementDto;
use App\Element\ElementRepository;
use App\Exceptions\BadRequestException;
use App\Set\CreateSetDto;
use App\Set\Set;
use App\Set\SetRepository;
class CreateSet
{
public function __construct(
private SetRepository $setRepo,
private ElementRepository $elementRepo,
) {}
/**
* @throws BadRequestException
*/
public function execute(CreateSetRequest $request): Set
{
if ($request->name === null || $request->name === '') {
throw new BadRequestException('name is required');
}
$set = $this->setRepo->create(new CreateSetDto(
name: $request->name,
));
$this->elementRepo->create(new CreateElementDto(
set: $set,
title: $set->getName(),
parentElement: null,
));
return $set;
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Set\UseCases\CreateSet;
class CreateSetRequest
{
public function __construct(
public ?string $name,
) {}
}