You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace jrosset\CliProgram\Validation\Validators;
|
|
|
|
/**
|
|
* An argument/option value validator based on another, internal, validator
|
|
*
|
|
* @template TValue of mixed The type of the returned value
|
|
* @template TValidator of IValidator The type of the internal validator
|
|
*
|
|
* @extends IValidator<TValue>
|
|
*/
|
|
abstract class BasedValidator implements IValidator {
|
|
/**
|
|
* @var TValidator The internal validator
|
|
*/
|
|
private IValidator $internalValidator;
|
|
|
|
/**
|
|
* Create a validator
|
|
*
|
|
* @param TValidator $internalValidator The internal validator
|
|
*/
|
|
public function __construct (IValidator $internalValidator) {
|
|
$this->internalValidator = $internalValidator;
|
|
}
|
|
/**
|
|
* The internal validator
|
|
*
|
|
* @return TValidator The internal validator
|
|
*/
|
|
protected function getInternalValidator (): IValidator {
|
|
return $this->internalValidator;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function validate (mixed $value): bool {
|
|
return $this->internalValidator->validate($value);
|
|
}
|
|
} |