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