annotate vendor/symfony/validator/Constraints/AbstractComparison.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\Validator\Constraints;
Chris@0 13
Chris@14 14 use Symfony\Component\PropertyAccess\PropertyAccess;
Chris@0 15 use Symfony\Component\Validator\Constraint;
Chris@0 16 use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Used for the comparison of values.
Chris@0 20 *
Chris@0 21 * @author Daniel Holmes <daniel@danielholmes.org>
Chris@0 22 * @author Bernhard Schussek <bschussek@gmail.com>
Chris@0 23 */
Chris@0 24 abstract class AbstractComparison extends Constraint
Chris@0 25 {
Chris@0 26 public $message;
Chris@0 27 public $value;
Chris@14 28 public $propertyPath;
Chris@0 29
Chris@0 30 /**
Chris@0 31 * {@inheritdoc}
Chris@0 32 */
Chris@0 33 public function __construct($options = null)
Chris@0 34 {
Chris@12 35 if (null === $options) {
Chris@17 36 $options = [];
Chris@12 37 }
Chris@12 38
Chris@17 39 if (\is_array($options)) {
Chris@14 40 if (!isset($options['value']) && !isset($options['propertyPath'])) {
Chris@17 41 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires either the "value" or "propertyPath" option to be set.', \get_class($this)));
Chris@14 42 }
Chris@14 43
Chris@14 44 if (isset($options['value']) && isset($options['propertyPath'])) {
Chris@17 45 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires only one of the "value" or "propertyPath" options to be set, not both.', \get_class($this)));
Chris@14 46 }
Chris@14 47
Chris@14 48 if (isset($options['propertyPath']) && !class_exists(PropertyAccess::class)) {
Chris@17 49 throw new ConstraintDefinitionException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', \get_class($this)));
Chris@14 50 }
Chris@0 51 }
Chris@0 52
Chris@0 53 parent::__construct($options);
Chris@0 54 }
Chris@0 55
Chris@0 56 /**
Chris@0 57 * {@inheritdoc}
Chris@0 58 */
Chris@0 59 public function getDefaultOption()
Chris@0 60 {
Chris@0 61 return 'value';
Chris@0 62 }
Chris@0 63 }