Validator::assertCallback( callable $callback, string $message = 'failed callback assertion' )
Assert that the callback returns true for each variable.
Parameters
- $callback
-
(callable) (Required)
- $message
-
(string) (Optional)
Default value: 'failed callback assertion'
Return
(DotenvValidator)
Source
File: vendor/vlucas/phpdotenv/src/Validator.php
protected function assertCallback(callable $callback, $message = 'failed callback assertion')
{
$failing = [];
foreach ($this->variables as $variable) {
if ($callback($this->loader->getEnvironmentVariable($variable)) === false) {
$failing[] = sprintf('%s %s', $variable, $message);
}
}
if (count($failing) > 0) {
throw new ValidationException(sprintf(
'One or more environment variables failed assertions: %s.',
implode(', ', $failing)
));
}
return $this;
}