src/System/Infrastructure/Implementation/Logger/NetworkLogger.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\System\Infrastructure\Implementation\Logger;
  4. use App\Infrastructure\Interfaces\Logger\MessageDirectorInterface;
  5. use App\Infrastructure\Interfaces\Logger\NetworkLoggerInterface;
  6. use Symfony\Component\HttpKernel\KernelInterface;
  7. use Symfony\Component\Messenger\MessageBusInterface;
  8. class NetworkLogger implements NetworkLoggerInterface
  9. {
  10.     private const TEST_ENV 'test';
  11.     public function __construct(
  12.         private readonly KernelInterface $kernel,
  13.         private readonly MessageBusInterface $bus,
  14.     ) {
  15.     }
  16.     public function publish(MessageDirectorInterface $director): void
  17.     {
  18.         if ($this->kernel->getEnvironment() === self::TEST_ENV) {
  19.             return;
  20.         }
  21.         $message $director->make();
  22.         $this->bus->dispatch($message);
  23.     }
  24. }