blob: 717c95237d03b9cb8f83999de7ebc23cea6d2316 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Adldap\Configuration\Validators;
4
5use Adldap\Configuration\ConfigurationException;
6
7/**
8 * Class StringOrNullValidator.
9 *
10 * Validates that the configuration value is a string or null.
11 */
12class StringOrNullValidator extends Validator
13{
14 /**
15 * {@inheritdoc}
16 */
17 public function validate()
18 {
19 if (is_string($this->value) || is_null($this->value)) {
20 return true;
21 }
22
23 throw new ConfigurationException("Option {$this->key} must be a string or null.");
24 }
25}