Skip to content

Commit

Permalink
Merge pull request #42 from mtarld/chore/add-readonly
Browse files Browse the repository at this point in the history
chore: add readonly classes
  • Loading branch information
mtarld authored Jun 9, 2023
2 parents a257c3d + b569f7f commit 4ebf1d3
Show file tree
Hide file tree
Showing 29 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/BookStore/Application/Command/AnonymizeBooksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use App\Shared\Application\Command\CommandInterface;

final class AnonymizeBooksCommand implements CommandInterface
final readonly class AnonymizeBooksCommand implements CommandInterface
{
public function __construct(
public readonly string $anonymizedName,
public string $anonymizedName,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\BookStore\Domain\ValueObject\Author;
use App\Shared\Application\Command\CommandHandlerInterface;

final class AnonymizeBooksCommandHandler implements CommandHandlerInterface
final readonly class AnonymizeBooksCommandHandler implements CommandHandlerInterface
{
public function __construct(private BookRepositoryInterface $bookRepository)
{
Expand Down
12 changes: 6 additions & 6 deletions src/BookStore/Application/Command/CreateBookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use App\BookStore\Domain\ValueObject\Price;
use App\Shared\Application\Command\CommandInterface;

final class CreateBookCommand implements CommandInterface
final readonly class CreateBookCommand implements CommandInterface
{
public function __construct(
public readonly BookName $name,
public readonly BookDescription $description,
public readonly Author $author,
public readonly BookContent $content,
public readonly Price $price,
public BookName $name,
public BookDescription $description,
public Author $author,
public BookContent $content,
public Price $price,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Command\CommandHandlerInterface;

final class CreateBookCommandHandler implements CommandHandlerInterface
final readonly class CreateBookCommandHandler implements CommandHandlerInterface
{
public function __construct(private readonly BookRepositoryInterface $bookRepository)
{
Expand Down
4 changes: 2 additions & 2 deletions src/BookStore/Application/Command/DeleteBookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use App\BookStore\Domain\ValueObject\BookId;
use App\Shared\Application\Command\CommandInterface;

final class DeleteBookCommand implements CommandInterface
final readonly class DeleteBookCommand implements CommandInterface
{
public function __construct(
public readonly BookId $id,
public BookId $id,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Command\CommandHandlerInterface;

final class DeleteBookCommandHandler implements CommandHandlerInterface
final readonly class DeleteBookCommandHandler implements CommandHandlerInterface
{
public function __construct(private readonly BookRepositoryInterface $bookRepository)
public function __construct(private BookRepositoryInterface $bookRepository)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/BookStore/Application/Command/DiscountBookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use App\BookStore\Domain\ValueObject\Discount;
use App\Shared\Application\Command\CommandInterface;

final class DiscountBookCommand implements CommandInterface
final readonly class DiscountBookCommand implements CommandInterface
{
public function __construct(
public readonly BookId $id,
public readonly Discount $discount,
public BookId $id,
public Discount $discount,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Command\CommandHandlerInterface;

final class DiscountBookCommandHandler implements CommandHandlerInterface
final readonly class DiscountBookCommandHandler implements CommandHandlerInterface
{
public function __construct(private readonly BookRepositoryInterface $bookRepository)
public function __construct(private BookRepositoryInterface $bookRepository)
{
}

Expand Down
14 changes: 7 additions & 7 deletions src/BookStore/Application/Command/UpdateBookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
use App\BookStore\Domain\ValueObject\Price;
use App\Shared\Application\Command\CommandInterface;

final class UpdateBookCommand implements CommandInterface
final readonly class UpdateBookCommand implements CommandInterface
{
public function __construct(
public readonly BookId $id,
public readonly ?BookName $name = null,
public readonly ?BookDescription $description = null,
public readonly ?Author $author = null,
public readonly ?BookContent $content = null,
public readonly ?Price $price = null,
public BookId $id,
public ?BookName $name = null,
public ?BookDescription $description = null,
public ?Author $author = null,
public ?BookContent $content = null,
public ?Price $price = null,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Command\CommandHandlerInterface;

final class UpdateBookCommandHandler implements CommandHandlerInterface
final readonly class UpdateBookCommandHandler implements CommandHandlerInterface
{
public function __construct(private readonly BookRepositoryInterface $bookRepository)
public function __construct(private BookRepositoryInterface $bookRepository)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/BookStore/Application/Query/FindBookQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use App\BookStore\Domain\ValueObject\BookId;
use App\Shared\Application\Query\QueryInterface;

final class FindBookQuery implements QueryInterface
final readonly class FindBookQuery implements QueryInterface
{
public function __construct(
public readonly BookId $id,
public BookId $id,
) {
}
}
2 changes: 1 addition & 1 deletion src/BookStore/Application/Query/FindBookQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Query\QueryHandlerInterface;

final class FindBookQueryHandler implements QueryHandlerInterface
final readonly class FindBookQueryHandler implements QueryHandlerInterface
{
public function __construct(private BookRepositoryInterface $repository)
{
Expand Down
8 changes: 4 additions & 4 deletions src/BookStore/Application/Query/FindBooksQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use App\BookStore\Domain\ValueObject\Author;
use App\Shared\Application\Query\QueryInterface;

final class FindBooksQuery implements QueryInterface
final readonly class FindBooksQuery implements QueryInterface
{
public function __construct(
public readonly ?Author $author = null,
public readonly ?int $page = null,
public readonly ?int $itemsPerPage = null,
public ?Author $author = null,
public ?int $page = null,
public ?int $itemsPerPage = null,
) {
}
}
2 changes: 1 addition & 1 deletion src/BookStore/Application/Query/FindBooksQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Query\QueryHandlerInterface;

final class FindBooksQueryHandler implements QueryHandlerInterface
final readonly class FindBooksQueryHandler implements QueryHandlerInterface
{
public function __construct(private BookRepositoryInterface $bookRepository)
{
Expand Down
4 changes: 2 additions & 2 deletions src/BookStore/Application/Query/FindCheapestBooksQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

use App\Shared\Application\Query\QueryInterface;

final class FindCheapestBooksQuery implements QueryInterface
final readonly class FindCheapestBooksQuery implements QueryInterface
{
public function __construct(public readonly int $size = 10)
public function __construct(public int $size = 10)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\BookStore\Domain\Repository\BookRepositoryInterface;
use App\Shared\Application\Query\QueryHandlerInterface;

final class FindCheapestBooksQueryHandler implements QueryHandlerInterface
final readonly class FindCheapestBooksQueryHandler implements QueryHandlerInterface
{
public function __construct(private BookRepositoryInterface $bookRepository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use ApiPlatform\Api\FilterInterface;
use Symfony\Component\PropertyInfo\Type;

final class AuthorFilter implements FilterInterface
final readonly class AuthorFilter implements FilterInterface
{
public function getDescription(string $resourceClass): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use Symfony\Component\Validator\Constraints as Assert;

final class DiscountBookPayload
final readonly class DiscountBookPayload
{
public function __construct(
#[Assert\Range(min: 0, max: 100)]
public readonly int $discountPercentage,
public int $discountPercentage,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Shared\Application\Command\CommandBusInterface;
use Webmozart\Assert\Assert;

final class AnonymizeBooksProcessor implements ProcessorInterface
final readonly class AnonymizeBooksProcessor implements ProcessorInterface
{
public function __construct(
private CommandBusInterface $commandBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use App\Shared\Application\Command\CommandBusInterface;
use Webmozart\Assert\Assert;

final class CreateBookProcessor implements ProcessorInterface
final readonly class CreateBookProcessor implements ProcessorInterface
{
public function __construct(
private CommandBusInterface $commandBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use App\Shared\Application\Command\CommandBusInterface;
use Webmozart\Assert\Assert;

final class DeleteBookProcessor implements ProcessorInterface
final readonly class DeleteBookProcessor implements ProcessorInterface
{
public function __construct(
private CommandBusInterface $commandBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use App\Shared\Application\Query\QueryBusInterface;
use Webmozart\Assert\Assert;

final class DiscountBookProcessor implements ProcessorInterface
final readonly class DiscountBookProcessor implements ProcessorInterface
{
public function __construct(
private CommandBusInterface $commandBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use App\Shared\Application\Command\CommandBusInterface;
use Webmozart\Assert\Assert;

final class UpdateBookProcessor implements ProcessorInterface
final readonly class UpdateBookProcessor implements ProcessorInterface
{
public function __construct(
private CommandBusInterface $commandBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @implements ProviderInterface<BookResource>
*/
final class BookCollectionProvider implements ProviderInterface
final readonly class BookCollectionProvider implements ProviderInterface
{
public function __construct(
private QueryBusInterface $queryBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @implements ProviderInterface<BookResource>
*/
final class BookItemProvider implements ProviderInterface
final readonly class BookItemProvider implements ProviderInterface
{
public function __construct(
private QueryBusInterface $queryBus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @implements ProviderInterface<BookResource>
*/
final class CheapestBooksProvider implements ProviderInterface
final readonly class CheapestBooksProvider implements ProviderInterface
{
public function __construct(private QueryBusInterface $queryBus)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Infrastructure/ApiPlatform/State/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @implements PaginatorInterface<T>
* @implements \IteratorAggregate<T>
*/
final class Paginator implements PaginatorInterface, \IteratorAggregate
final readonly class Paginator implements PaginatorInterface, \IteratorAggregate
{
/**
* @param \Traversable<T> $items
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/Infrastructure/Doctrine/DoctrinePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
*
* @implements PaginatorInterface<T>
*/
final class DoctrinePaginator implements PaginatorInterface
final readonly class DoctrinePaginator implements PaginatorInterface
{
private readonly int $firstResult;
private readonly int $maxResults;
private int $firstResult;
private int $maxResults;

/**
* @param Paginator<T> $paginator
*/
public function __construct(
private readonly Paginator $paginator,
private Paginator $paginator,
) {
$firstResult = $paginator->getQuery()->getFirstResult();
$maxResults = $paginator->getQuery()->getMaxResults();
Expand Down
16 changes: 8 additions & 8 deletions src/Shared/Infrastructure/InMemory/InMemoryPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
*
* @implements PaginatorInterface<T>
*/
final class InMemoryPaginator implements PaginatorInterface
final readonly class InMemoryPaginator implements PaginatorInterface
{
private readonly int $offset;
private readonly int $limit;
private readonly int $lastPage;
private int $offset;
private int $limit;
private int $lastPage;

/**
* @param \Traversable<T> $items
*/
public function __construct(
private readonly \Traversable $items,
private readonly int $totalItems,
private readonly int $currentPage,
private readonly int $itemsPerPage,
private \Traversable $items,
private int $totalItems,
private int $currentPage,
private int $itemsPerPage,
) {
Assert::greaterThanEq($totalItems, 0);
Assert::positiveInteger($currentPage);
Expand Down

0 comments on commit 4ebf1d3

Please sign in to comment.