Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/notifier/Event/NotificationEvents.php line 57

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Notifier\Event;
  11. use Symfony\Component\Notifier\Message\MessageInterface;
  12. /**
  13.  * @author Fabien Potencier <fabien@symfony.com>
  14.  */
  15. class NotificationEvents
  16. {
  17.     private $events = [];
  18.     private $transports = [];
  19.     public function add(MessageEvent $event): void
  20.     {
  21.         $this->events[] = $event;
  22.         $this->transports[(string) $event->getMessage()->getTransport()] = true;
  23.     }
  24.     public function getTransports(): array
  25.     {
  26.         return array_keys($this->transports);
  27.     }
  28.     /**
  29.      * @return MessageEvent[]
  30.      */
  31.     public function getEvents(string $name null): array
  32.     {
  33.         if (null === $name) {
  34.             return $this->events;
  35.         }
  36.         $events = [];
  37.         foreach ($this->events as $event) {
  38.             if ($name === (string) $event->getMessage()->getTransport()) {
  39.                 $events[] = $event;
  40.             }
  41.         }
  42.         return $events;
  43.     }
  44.     /**
  45.      * @return MessageInterface[]
  46.      */
  47.     public function getMessages(string $name null): array
  48.     {
  49.         $events $this->getEvents($name);
  50.         $messages = [];
  51.         foreach ($events as $event) {
  52.             $messages[] = $event->getMessage();
  53.         }
  54.         return $messages;
  55.     }
  56. }