vendor/symfony/config/Definition/Builder/BooleanNodeDefinition.php line 24

  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\Config\Definition\Builder;
  11. use Symfony\Component\Config\Definition\BooleanNode;
  12. use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
  13. /**
  14.  * This class provides a fluent interface for defining a node.
  15.  *
  16.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  17.  */
  18. class BooleanNodeDefinition extends ScalarNodeDefinition
  19. {
  20.     public function __construct(?string $nameNodeParentInterface $parent null)
  21.     {
  22.         parent::__construct($name$parent);
  23.         $this->nullEquivalent true;
  24.     }
  25.     /**
  26.      * Instantiate a Node.
  27.      */
  28.     protected function instantiateNode(): BooleanNode
  29.     {
  30.         return new BooleanNode($this->name$this->parent$this->pathSeparator);
  31.     }
  32.     /**
  33.      * @throws InvalidDefinitionException
  34.      */
  35.     public function cannotBeEmpty(): static
  36.     {
  37.         throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
  38.     }
  39. }