PHP 8.2.31
Preview: HelperSet.php Size: 2.52 KB
//opt/cpanel/ea-wappspector/vendor/symfony/console/Helper/HelperSet.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console\Helper;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;

/**
 * HelperSet represents a set of helpers to be used with a command.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 *
 * @implements \IteratorAggregate<string, Helper>
 */
class HelperSet implements \IteratorAggregate
{
    /** @var array<string, Helper> */
    private $helpers = [];
    private $command;

    /**
     * @param Helper[] $helpers An array of helper
     */
    public function __construct(array $helpers = [])
    {
        foreach ($helpers as $alias => $helper) {
            $this->set($helper, \is_int($alias) ? null : $alias);
        }
    }

    public function set(HelperInterface $helper, ?string $alias = null)
    {
        $this->helpers[$helper->getName()] = $helper;
        if (null !== $alias) {
            $this->helpers[$alias] = $helper;
        }

        $helper->setHelperSet($this);
    }

    /**
     * Returns true if the helper if defined.
     *
     * @return bool
     */
    public function has(string $name)
    {
        return isset($this->helpers[$name]);
    }

    /**
     * Gets a helper value.
     *
     * @return HelperInterface
     *
     * @throws InvalidArgumentException if the helper is not defined
     */
    public function get(string $name)
    {
        if (!$this->has($name)) {
            throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
        }

        return $this->helpers[$name];
    }

    /**
     * @deprecated since Symfony 5.4
     */
    public function setCommand(?Command $command = null)
    {
        trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);

        $this->command = $command;
    }

    /**
     * Gets the command associated with this helper set.
     *
     * @return Command
     *
     * @deprecated since Symfony 5.4
     */
    public function getCommand()
    {
        trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);

        return $this->command;
    }

    /**
     * @return \Traversable<string, Helper>
     */
    #[\ReturnTypeWillChange]
    public function getIterator()
    {
        return new \ArrayIterator($this->helpers);
    }
}

Directory Contents

Dirs: 0 × Files: 19

Name Size Perms Modified Actions
3.32 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
2.43 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
1.98 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
2.34 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
5.06 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
846 B lrw-r--r-- 2024-11-06 11:30:55
Edit Download
2.52 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
747 B lrw-r--r-- 2024-11-06 11:30:55
Edit Download
4.87 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
18.28 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
7.02 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
19.05 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
3.20 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
29.15 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
1.77 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
2.22 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download
581 B lrw-r--r-- 2024-11-06 11:30:55
Edit Download
531 B lrw-r--r-- 2024-11-06 11:30:55
Edit Download
12.39 KB lrw-r--r-- 2024-11-06 11:30:55
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).