File size: 3,209 Bytes
cf14c12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | <?php
declare(strict_types=1);
namespace User\Domain\Repositories;
use DateTimeInterface;
use Iterator;
use Shared\Domain\Repositories\RepositoryInterface;
use Shared\Domain\ValueObjects\Id;
use Shared\Domain\ValueObjects\SortDirection;
use User\Domain\Entities\UserEntity;
use User\Domain\Exceptions\EmailTakenException;
use User\Domain\Exceptions\UserNotFoundException;
use User\Domain\ValueObjects\ApiKey;
use User\Domain\ValueObjects\Email;
use User\Domain\ValueObjects\Role;
use User\Domain\ValueObjects\SortParameter;
use User\Domain\ValueObjects\Status;
interface UserRepositoryInterface extends RepositoryInterface
{
/**
* Add new user entity to the repository
*
* @param UserEntity $user
* @return static
* @throws EmailTakenException
*/
public function add(UserEntity $user): static;
/**
* Remove the user entity from the repository
*
* @param UserEntity $user
* @return static
*/
public function remove(UserEntity $user): static;
/**
* Find user entity by id
*
* @param Id $id
* @return UserEntity
* @throws UserNotFoundException
*/
public function ofId(Id $id): UserEntity;
/**
* Find a single user entity by email
*
* @param Email $email
* @return UserEntity
* @throws UserNotFoundException
*/
public function ofEmail(Email $email): UserEntity;
/**
* Find a single user entity by api key
*
* @param ApiKey $key
* @return UserEntity
* @throws UserNotFoundException
*/
public function ofApiKey(ApiKey $key): UserEntity;
/**
* Find a single user entity by unique key
*
* @param Id|Email|ApiKey $key
* @return UserEntity
* @throws UserNotFoundException
*/
public function ofUniqueKey(Id|Email|ApiKey $key): UserEntity;
/**
* @param Role $role
* @return static
*/
public function filterByRole(Role $role): static;
/**
* @param Status $status
* @return static
*/
public function filterByStatus(Status $status): static;
/**
* Filter user entities collection by the created after the date
*
* @param DateTimeInterface $date
* @return static
*/
public function createdAfter(DateTimeInterface $date): static;
/**
* Filter user entities collection by the created before the date
*
* @param DateTimeInterface $date
* @return static
*/
public function createdBefore(DateTimeInterface $date): static;
/**
* @param string $terms
* @return static
*/
public function search(string $terms): static;
/**
* @param SortDirection $dir
* @param null|SortParameter $sortParameter
* @return static
*/
public function sort(
SortDirection $dir,
?SortParameter $sortParameter = null
): static;
/**
* @param UserEntity $cursor
* @return Iterator<UserEntity>
*/
public function startingAfter(UserEntity $cursor): Iterator;
/**
* @param UserEntity $cursor
* @return Iterator<UserEntity>
*/
public function endingBefore(UserEntity $cursor): Iterator;
}
|