custom/plugins/GbmedEnev/src/Framework/Eprel/EprelGroups.php line 47

Open in your IDE?
  1. <?php
  2. /**
  3.  * gb media
  4.  * All Rights Reserved.
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited.
  7.  * The content of this file is proprietary and confidential.
  8.  *
  9.  * @category       Shopware
  10.  * @package        Shopware_Plugins
  11.  * @subpackage     GbmedEnev
  12.  * @copyright      Copyright (c) 2019, gb media
  13.  * @license        proprietary
  14.  * @author         Giuseppe Bottino
  15.  * @link           http://www.gb-media.biz
  16.  */
  17. declare(strict_types=1);
  18. namespace Gbmed\Enev\Framework\Eprel;
  19. class EprelGroups
  20. {
  21.     /**
  22.      * @var iterable
  23.      */
  24.     private $handlers;
  25.     /**
  26.      * CaptchaRouteListener constructor.
  27.      * @param iterable $handlers
  28.      */
  29.     public function __construct(iterable $handlers = [])
  30.     {
  31.         $this->handlers $handlers;
  32.     }
  33.     /**
  34.      * find supported group
  35.      *
  36.      * @param string $group
  37.      * @return EprelGroupsInterface|null
  38.      */
  39.     public function getGroup(string $group): ?EprelGroupsInterface
  40.     {
  41.         /** @var EprelGroupsInterface $handler */
  42.         foreach ($this->handlers as $handler) {
  43.             if ($handler->support($group)) {
  44.                 return $handler;
  45.             }
  46.         }
  47.         throw new \RuntimeException('Eprel groups "' $group '" not found!');
  48.     }
  49. }