HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/magento/module-ui/Config/Converter/Composite.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Ui\Config\Converter;

use Magento\Ui\Config\ConverterInterface;

/**
 * Composite converter
 *
 * Identify required converter
 */
class Composite implements ConverterInterface
{
    /**
     * Format: array('<name>' => <instance>, ...)
     *
     * @var ConverterInterface[]
     */
    private $converters;

    /**
     * Data key that holds name of an converter to be used for that data
     *
     * @var string
     */
    private $discriminator;

    /**
     * @param ConverterInterface[] $converters
     * @param string $discriminator
     * @throws \InvalidArgumentException
     */
    public function __construct(array $converters, $discriminator)
    {
        foreach ($converters as $converterName => $converterInstance) {
            if (!$converterInstance instanceof ConverterInterface) {
                throw new \InvalidArgumentException(
                    "Converter named '{$converterName}' is expected to be an argument converter instance."
                );
            }
        }
        $this->converters = $converters;
        $this->discriminator = $discriminator;
    }

    /**
     * @inheritdoc
     * @throws \InvalidArgumentException
     */
    public function convert(\DOMNode $node, array $data)
    {
        if (!isset($data[$this->discriminator])) {
            throw new \InvalidArgumentException(
                sprintf('Value for key "%s" is missing in the argument data.', $this->discriminator)
            );
        }
        $converterName = $data[$this->discriminator];
        unset($data[$this->discriminator]);
        $converter = $this->getConverter($converterName);
        return $converter->convert($node, $data);
    }

    /**
     * Register parser instance under a given unique name
     *
     * @param string $name
     * @param ConverterInterface $instance
     * @return void
     * @throws \InvalidArgumentException
     */
    public function addConverter($name, ConverterInterface $instance)
    {
        if (isset($this->converters[$name])) {
            throw new \InvalidArgumentException("Argument converter named '{$name}' has already been defined.");
        }
        $this->converters[$name] = $instance;
    }

    /**
     * Retrieve parser instance by its unique name
     *
     * @param string $name
     * @return ConverterInterface
     * @throws \InvalidArgumentException
     */
    private function getConverter($name)
    {
        if (!isset($this->converters[$name])) {
            throw new \InvalidArgumentException("Argument converter named '{$name}' has not been defined.");
        }
        return $this->converters[$name];
    }
}