Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace Adldap\Configuration\Validators; |
| 4 | |
| 5 | /** |
| 6 | * Class Validator. |
| 7 | * |
| 8 | * Validates configuration values. |
| 9 | */ |
| 10 | abstract class Validator |
| 11 | { |
| 12 | /** |
| 13 | * The configuration key under validation. |
| 14 | * |
| 15 | * @var string |
| 16 | */ |
| 17 | protected $key; |
| 18 | |
| 19 | /** |
| 20 | * The configuration value under validation. |
| 21 | * |
| 22 | * @var mixed |
| 23 | */ |
| 24 | protected $value; |
| 25 | |
| 26 | /** |
| 27 | * Constructor. |
| 28 | * |
| 29 | * @param string $key |
| 30 | * @param mixed $value |
| 31 | */ |
| 32 | public function __construct($key, $value) |
| 33 | { |
| 34 | $this->key = $key; |
| 35 | $this->value = $value; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Validates the configuration value. |
| 40 | * |
| 41 | * @throws \Adldap\Configuration\ConfigurationException When the value given fails validation. |
| 42 | * |
| 43 | * @return bool |
| 44 | */ |
| 45 | abstract public function validate(); |
| 46 | } |