Skip to content

Commit

Permalink
feature: Further structural adjustments
Browse files Browse the repository at this point in the history
Fundamental changes to the account and core structure.
  • Loading branch information
BibaltiK committed Dec 5, 2023
1 parent f5a5f30 commit a91a572
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/App/Entity/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

readonly class Account implements AccountInterface, Collectible
{
public const AUTHENTICATED = 'authenticated User';

public function __construct(
private int $id,
private UuidInterface $uuid,
Expand Down
6 changes: 4 additions & 2 deletions src/App/Enum/AccountRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ enum AccountRole: int
{
case OWNER = 1;
case ADMINISTRATOR = 2;
case MODERATOR = 3;
case USER = 4;
case GAME_MASTER = 3;
case MODERATOR = 4;
case USER = 5;

public function getRoleName(): string
{
return match ($this) {
AccountRole::OWNER => 'Eigentümer',
AccountRole::ADMINISTRATOR => 'Administrator',
AccountRole::GAME_MASTER => 'Spielleiter',
AccountRole::MODERATOR => 'Moderator',
AccountRole::USER => 'Spieler'
};
Expand Down
13 changes: 4 additions & 9 deletions src/App/Handler/Account/ListAllAccountsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Stormannsgal\App\Handler\Account;

use Fig\Http\Message\StatusCodeInterface as HTTP;
use Laminas\Diactoros\Response\JsonResponse;
use OpenApi\Attributes as OA;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Fig\Http\Message\StatusCodeInterface as HTTP;
use OpenApi\Attributes as OA;
use Psr\Http\Server\RequestHandlerInterface;

class ListAllAccountsHandler implements RequestHandlerInterface
Expand All @@ -15,14 +15,9 @@ class ListAllAccountsHandler implements RequestHandlerInterface
path: '/api/account/list/all',
description: 'All accounts are listed in the list. Whether active, inactive, banned or deleted',
summary: 'Listing of all accounts',
tags: ['Account'],
responses: [
new OA\Response(
response: HTTP::STATUS_OK,
description: 'Success',
),
]
tags: ['Account']
)]
#[OA\Response(response: HTTP::STATUS_OK, description: 'Success')]
public function handle(ServerRequestInterface $request): ResponseInterface
{
return new JsonResponse([], HTTP::STATUS_OK);
Expand Down
3 changes: 1 addition & 2 deletions src/App/Hydrator/AccountHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DateTimeImmutable;
use Exception;
use InvalidArgumentException;
use Ramsey\Uuid\Uuid;
use Stormannsgal\App\Entity\Account;
use Stormannsgal\App\Enum\AccountRole;
Expand All @@ -14,9 +13,9 @@

class AccountHydrator extends Hydrator
{

/**
* @throws Exception
* @throws InvalidArgumentException
*/
public function hydrate(array $data): AccountInterface
{
Expand Down
7 changes: 3 additions & 4 deletions src/App/Repository/AccountRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Stormannsgal\Core\Entity\AccountInterface;
use Stormannsgal\Core\Exception\EmptyResultException;
use Stormannsgal\Core\Repository\AccountRepositoryInterface as AccountRepositoryInterface;

use Stormannsgal\Core\Store\AccountStoreInterface;

use Stormannsgal\Core\Type\Email;

use function sprintf;
Expand Down Expand Up @@ -61,6 +59,7 @@ public function findByUuid(UuidInterface $uuid): AccountInterface

/**
* @throws EmptyResultException
* @throws \Exception
*/
public function findByName(string $name): AccountInterface
{
Expand All @@ -77,6 +76,7 @@ public function findByName(string $name): AccountInterface

/**
* @throws EmptyResultException
* @throws \Exception
*/
public function findByEmail(Email $email): AccountInterface
{
Expand All @@ -92,12 +92,11 @@ public function findByEmail(Email $email): AccountInterface
}

/**
* @throws Exception|\Exception
* @throws \Exception
*/
public function findAll(): AccountCollectionInterface
{
$accounts = $this->store->findAll();

$accountCollection = new AccountCollection();

foreach ($accounts as $account) {
Expand Down
3 changes: 2 additions & 1 deletion src/App/Table/AbstractTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use Envms\FluentPDO\Exception;
use Envms\FluentPDO\Query;
use ReflectionClass;
use Stormannsgal\Core\Store\StoreInterface;

use function is_array;
use function substr;

class AbstractTable
class AbstractTable implements StoreInterface
{
protected readonly string $table;

Expand Down
1 change: 1 addition & 0 deletions src/Core/Type/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private function prepareValue(string $value): string
'Value must be an e-mail'
);
}

return $value;
}
}

0 comments on commit a91a572

Please sign in to comment.