[General] PHP-CS-FIXER
This commit is contained in:
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Chapter7;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\Chapter7\Application\QueryBus;
|
||||
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQuery;
|
||||
use Cheeper\Chapter7\Application\QueryBus;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
@@ -5,11 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Chapter7;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQuery;
|
||||
use Cheeper\Chapter7\Application\Author\Query\TimelineQuery;
|
||||
use Cheeper\Chapter7\Application\QueryBus;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
@@ -8,13 +8,13 @@ use App\Messenger\CommandBus;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\Chapter7\Application\Cheep\Command\PostCheepCommand;
|
||||
use InvalidArgumentException;
|
||||
use function Safe\json_decode;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use function Safe\json_decode;
|
||||
|
||||
//snippet chapter7-postcheep-controller
|
||||
final class PostCheepController extends AbstractController
|
||||
@@ -69,4 +69,4 @@ final class PostCheepController extends AbstractController
|
||||
}
|
||||
//end-ignore
|
||||
}
|
||||
//end-snippet
|
||||
//end-snippet
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace App\Controller\Chapter8;
|
||||
use Cheeper\Chapter7\Application\Author\Query\TimelineQuery;
|
||||
use Cheeper\Chapter7\Application\QueryBus;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
@@ -15,7 +15,9 @@ use Ramsey\Uuid\UuidInterface;
|
||||
class PopularCheep
|
||||
{
|
||||
public function __construct(
|
||||
#[ORM\Id, ORM\GeneratedValue(strategy: "NONE"), ORM\Column(type: UuidType::NAME)]
|
||||
#[ORM\Id,
|
||||
ORM\GeneratedValue(strategy: "NONE"),
|
||||
ORM\Column(type: UuidType::NAME)]
|
||||
private UuidInterface $id,
|
||||
#[ORM\Column(type: UuidType::NAME)]
|
||||
private UuidInterface $authorId,
|
||||
@@ -45,4 +47,4 @@ class PopularCheep
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ declare(strict_types=1);
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
|
||||
final class Kernel extends BaseKernel
|
||||
{
|
||||
|
||||
@@ -5,11 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PopularCheep;
|
||||
use Cheeper\Chapter7\DomainModel\Author\Author;
|
||||
use Cheeper\Chapter7\DomainModel\Follow\Follow;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use function Doctrine\ORM\QueryBuilder;
|
||||
|
||||
final class PopularCheepRepository extends ServiceEntityRepository
|
||||
{
|
||||
@@ -25,7 +23,7 @@ final class PopularCheepRepository extends ServiceEntityRepository
|
||||
public function of(array $follows): array
|
||||
{
|
||||
return $this->findBy([
|
||||
'id' => array_map(static fn(Follow $f) => $f->toAuthorId()->id(), $follows)
|
||||
'id' => array_map(static fn (Follow $f) => $f->toAuthorId()->id(), $follows),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,15 @@ class Clock
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
public function now(): DateTimeImmutable {
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return $this->strategy->now();
|
||||
}
|
||||
|
||||
public function changeStrategy(ClockStrategy $clockStrategy): self {
|
||||
public function changeStrategy(ClockStrategy $clockStrategy): self
|
||||
{
|
||||
$this->strategy = $clockStrategy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ use DateTimeImmutable;
|
||||
interface ClockStrategy
|
||||
{
|
||||
public function now(): DateTimeImmutable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ class DateCollectionClockStrategy implements ClockStrategy
|
||||
|
||||
public function __construct(
|
||||
private array $collection = []
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->iterator = 0;
|
||||
}
|
||||
|
||||
@@ -28,4 +27,4 @@ class DateCollectionClockStrategy implements ClockStrategy
|
||||
|
||||
return $currentDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ use DateTimeImmutable;
|
||||
|
||||
class DefaultClockStrategy implements ClockStrategy
|
||||
{
|
||||
public function now(): DateTimeImmutable {
|
||||
public function now(): DateTimeImmutable
|
||||
{
|
||||
return new DateTimeImmutable(
|
||||
'now',
|
||||
new \DateTimeZone(
|
||||
@@ -16,4 +17,4 @@ class DefaultClockStrategy implements ClockStrategy
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ use Cheeper\AllChapters\DomainModel\Author\EmailAddress;
|
||||
use Cheeper\AllChapters\DomainModel\Author\UserName;
|
||||
use Cheeper\AllChapters\DomainModel\Author\Website;
|
||||
use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpCommand;
|
||||
use Cheeper\Chapter4\Application\EventBus;
|
||||
use Cheeper\Chapter4\DomainModel\Author\Author;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Cheeper\Chapter4\Application\EventBus;
|
||||
|
||||
//snippet sign-up-handler-with-events
|
||||
final class SignUpCommandHandler
|
||||
|
||||
@@ -8,11 +8,11 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
|
||||
use Cheeper\AllChapters\DomainModel\Cheep\CheepMessage;
|
||||
use Cheeper\Chapter4\Application\EventBus;
|
||||
use Cheeper\Chapter4\DomainModel\Author\Author;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Cheeper\Chapter4\DomainModel\Cheep\Cheep;
|
||||
use Cheeper\Chapter4\DomainModel\Cheep\CheepRepository;
|
||||
use Cheeper\Chapter4\Application\EventBus;
|
||||
|
||||
//snippet post-cheep-handler
|
||||
final class PostCheepCommandHandler
|
||||
|
||||
@@ -34,8 +34,7 @@ final class Cheep
|
||||
private string $cheepId,
|
||||
private string $authorId,
|
||||
private string $message,
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->date = Clock::instance()->now();
|
||||
$this->setMessage($message);
|
||||
$this->notifyDomainEvent(
|
||||
@@ -68,7 +67,7 @@ final class Cheep
|
||||
return CheepId::fromString($this->cheepId);
|
||||
}
|
||||
|
||||
final public function recomposeWith(CheepMessage $cheepMessage): void
|
||||
public function recomposeWith(CheepMessage $cheepMessage): void
|
||||
{
|
||||
$this->setMessage($cheepMessage->message());
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Cheeper\Chapter4\DomainModel\Follow;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
|
||||
use Cheeper\Chapter4\DomainModel\TriggerEventsTrait;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
|
||||
use Cheeper\Chapter4\DomainModel\TriggerEventsTrait;
|
||||
|
||||
// snippet follow-entity-with-events
|
||||
class Follow
|
||||
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Cheeper\Chapter4\Infrastructure\DomainModel\Author;
|
||||
|
||||
use Cheeper\Chapter4\DomainModel\Author\Author;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\AllChapters\DomainModel\Author\UserName;
|
||||
use Cheeper\Chapter4\DomainModel\Author\Author;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ final class CountFollowersQuery implements Query
|
||||
|
||||
private function __construct(
|
||||
private string $authorId
|
||||
)
|
||||
{
|
||||
) {
|
||||
}
|
||||
|
||||
public function authorId(): string
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\W
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
|
||||
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
|
||||
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
|
||||
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
|
||||
|
||||
//snippet count-followers-handler
|
||||
final class CountFollowersQueryHandler
|
||||
|
||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Cheeper\Chapter6\Application\Author\Command\WithDomainEvents;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Follow\FollowDoesAlreadyExistException;
|
||||
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Cheeper\AllChapters\DomainModel\Follow\FollowDoesAlreadyExistException;
|
||||
use Cheeper\Chapter4\Application\EventBus;
|
||||
use Cheeper\Chapter4\DomainModel\Author\Author;
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
|
||||
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
|
||||
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
|
||||
|
||||
//snippet follow-handler-with-event
|
||||
final class FollowCommandHandler
|
||||
|
||||
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace Cheeper\Chapter6\Infrastructure\Application\Author\Projection;
|
||||
|
||||
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
|
||||
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler;
|
||||
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjection;
|
||||
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler;
|
||||
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
|
||||
|
||||
//snippet symfony-author-followed-handler
|
||||
|
||||
@@ -54,7 +54,7 @@ final class FollowCommandHandler
|
||||
private function notifyEvents(FollowCommand $command, array $domainEvents): void
|
||||
{
|
||||
$stamppedEvents = array_map(
|
||||
static fn($event) => $event->stampAsResponseTo($command),
|
||||
static fn ($event) => $event->stampAsResponseTo($command),
|
||||
$domainEvents
|
||||
);
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ namespace Cheeper\Chapter7\Application\Author\Event;
|
||||
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CreateFollowersCounterProjection;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CreateFollowersCounterProjectionHandlerInterface;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CreateTimelineProjection;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CreateTimelineProjectionHandlerInterface;
|
||||
use Cheeper\Chapter7\DomainModel\Author\NewAuthorSigned;
|
||||
|
||||
//snippet new-author-signed-event-handler
|
||||
|
||||
@@ -4,9 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Cheeper\Chapter7\Application\Author\Query;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
|
||||
//snippet timeline-handler
|
||||
final class TimelineQueryHandler
|
||||
{
|
||||
|
||||
@@ -44,8 +44,7 @@ final class CheepPosted implements DomainEvent
|
||||
AuthorId $authorId,
|
||||
CheepMessage $cheepMessage,
|
||||
CheepDate $cheepDate,
|
||||
): self
|
||||
{
|
||||
): self {
|
||||
return new self(
|
||||
$cheepId->toString(),
|
||||
$authorId->toString(),
|
||||
|
||||
@@ -38,7 +38,7 @@ final class TimelineQueryHandler
|
||||
$cheeps[] = [
|
||||
'cheep_id' => $popularCheep->getId()->toString(),
|
||||
'cheep_message' => $popularCheep->getMessage(),
|
||||
'cheep_date' => $popularCheep->getCreatedAt()->format(DateTimeInterface::ATOM)
|
||||
'cheep_date' => $popularCheep->getCreatedAt()->format(DateTimeInterface::ATOM),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ final class TimelineQueryHandler
|
||||
|
||||
usort(
|
||||
$cheeps,
|
||||
function(array $c1, array $c2): int {
|
||||
function (array $c1, array $c2): int {
|
||||
$date1 = DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $c1['cheep_date']);
|
||||
$date2 = DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $c2['cheep_date']);
|
||||
return $date1 <=> $date2;
|
||||
|
||||
@@ -8,8 +8,8 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\Chapter7\Application\Cheep\Projection\AddCheepToTimelineProjection;
|
||||
use Cheeper\Chapter7\Application\ProjectionBus;
|
||||
use Cheeper\Chapter7\DomainModel\Cheep\CheepPosted;
|
||||
use Cheeper\Chapter8\DomainModel\Follow\FollowRepository;
|
||||
use Cheeper\Chapter8\Application\Cheep\Projection\AddCheepToGlobalStoreProjection;
|
||||
use Cheeper\Chapter8\DomainModel\Follow\FollowRepository;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
|
||||
|
||||
@@ -19,4 +19,4 @@ final class AddCheepToGlobalStoreProjection implements Projection
|
||||
) {
|
||||
$this->stampAsNewMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ final class AddCheepToGlobalStoreProjectionHandler
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
)
|
||||
{
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(AddCheepToGlobalStoreProjection $projection): void
|
||||
@@ -29,4 +28,4 @@ final class AddCheepToGlobalStoreProjectionHandler
|
||||
$this->entityManager->persist($popularCheep);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user