add Post entity, dto, repository interface

Post: id, userId (fk -> User), title, body, createdAt as
DateTimeImmutable. CreatePostDto readonly with explicit
createdAt (use case supplies it via Clock; entity remains pure).
PostRepository: create, find, findByUserId, findRecent (limit),
delete.
This commit is contained in:
yisroel 2026-05-06 15:19:00 +03:00
parent 9ca58f3a9d
commit 73a3acd39f
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
3 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,22 @@
<?php
namespace App\Post;
interface PostRepository
{
public function create(CreatePostDto $dto): Post;
public function find(int $id): ?Post;
/**
* @return Post[]
*/
public function findByUserId(int $userId): array;
/**
* @return Post[]
*/
public function findRecent(int $limit): array;
public function delete(int $id): void;
}