vendor/symfony/config/Definition/Builder/ValidationBuilder.php line 34

Open in your IDE?
  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. /**
  12.  * This class builds validation conditions.
  13.  *
  14.  * @author Christophe Coevoet <stof@notk.org>
  15.  */
  16. class ValidationBuilder
  17. {
  18.     protected $node;
  19.     public $rules = [];
  20.     public function __construct(NodeDefinition $node)
  21.     {
  22.         $this->node $node;
  23.     }
  24.     /**
  25.      * Registers a closure to run as normalization or an expression builder to build it if null is provided.
  26.      *
  27.      * @return ExprBuilder|$this
  28.      */
  29.     public function rule(\Closure $closure null)
  30.     {
  31.         if (null !== $closure) {
  32.             $this->rules[] = $closure;
  33.             return $this;
  34.         }
  35.         return $this->rules[] = new ExprBuilder($this->node);
  36.     }
  37. }