clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace DrupalCodeGenerator\Validator;
/**
* Validates only non-empty values.
*/
final class Optional {
private readonly \Closure $validator;
/**
* @psalm-param callable(mixed): mixed $validator
*/
public function __construct(callable $validator) {
// Convert into closure as typed properties cannot be callable.
$this->validator = $validator(...);
}
/**
* @throws \UnexpectedValueException
*/
public function __invoke(mixed $value): mixed {
return $value === NULL || $value === '' || $value === [] ? $value : ($this->validator)($value);
}
}