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.
22 lines
381 B
PHP
22 lines
381 B
PHP
<?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;
|
|
}
|