![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/amasty/base/Utils/Http/Response/Entity/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Magento 2 Base Package */ namespace Amasty\Base\Utils\Http\Response\Entity; use Amasty\Base\Utils\Http\Url\UrlComparator; use Magento\Framework\Exception\NotFoundException; class ConfigPool { /** * @var Config[] */ private $configs; /** * @var UrlComparator */ private $urlComparator; public function __construct( UrlComparator $urlComparator, array $configs ) { $this->checkConfigInstance($configs); $this->urlComparator = $urlComparator; $this->configs = $configs; } /** * @param string $path * @return Config * @throws NotFoundException */ public function get(string $path): Config { $result = false; foreach ($this->configs as $configPath => $config) { if ($this->urlComparator->isEqual($path, $configPath)) { $result = $config; break; } } if (!$result) { throw new NotFoundException(__('Entity config not found for given path %1.', $path)); } return $result; } /** * @param array $configs * @throws \InvalidArgumentException * @return void */ private function checkConfigInstance(array $configs): void { foreach ($configs as $configPath => $config) { if (!$config instanceof Config) { throw new \InvalidArgumentException( 'The config instance "' . $configPath . '" must be ' . Config::class ); } } } }