WorkerMetadata.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\Messenger;
  11. /**
  12. * @author Oleg Krasavin <okwinza@gmail.com>
  13. */
  14. final class WorkerMetadata
  15. {
  16. private $metadata;
  17. public function __construct(array $metadata)
  18. {
  19. $this->metadata = $metadata;
  20. }
  21. public function set(array $newMetadata): void
  22. {
  23. $this->metadata = array_merge($this->metadata, $newMetadata);
  24. }
  25. /**
  26. * Returns the queue names the worker consumes from, if "--queues" option was used.
  27. * Returns null otherwise.
  28. */
  29. public function getQueueNames(): ?array
  30. {
  31. return $this->metadata['queueNames'] ?? null;
  32. }
  33. /**
  34. * Returns an array of unique identifiers for transport receivers the worker consumes from.
  35. */
  36. public function getTransportNames(): array
  37. {
  38. return $this->metadata['transportNames'] ?? [];
  39. }
  40. }