repository = $repository; $this->variables = $variables; } /** * Assert that each variable is present. * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function required() { return $this->assert( static function (?string $value) { return $value !== null; }, 'is missing' ); } /** * Assert that each variable is not empty. * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function notEmpty() { return $this->assertNullable( static function (string $value) { return Str::len(\trim($value)) > 0; }, 'is empty' ); } /** * Assert that each specified variable is an integer. * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function isInteger() { return $this->assertNullable( static function (string $value) { return \ctype_digit($value); }, 'is not an integer' ); } /** * Assert that each specified variable is a boolean. * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function isBoolean() { return $this->assertNullable( static function (string $value) { if ($value === '') { return false; } return \filter_var($value, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) !== null; }, 'is not a boolean' ); } /** * Assert that each variable is amongst the given choices. * * @param string[] $choices * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function allowedValues(array $choices) { return $this->assertNullable( static function (string $value) use ($choices) { return \in_array($value, $choices, true); }, \sprintf('is not one of [%s]', \implode(', ', $choices)) ); } /** * Assert that each variable matches the given regular expression. * * @param string $regex * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function allowedRegexValues(string $regex) { return $this->assertNullable( static function (string $value) use ($regex) { return Regex::matches($regex, $value)->success()->getOrElse(false); }, \sprintf('does not match "%s"', $regex) ); } /** * Assert that the callback returns true for each variable. * * @param callable(?string):bool $callback * @param string $message * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function assert(callable $callback, string $message) { $failing = []; foreach ($this->variables as $variable) { if ($callback($this->repository->get($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; } /** * Assert that the callback returns true for each variable. * * Skip checking null variable values. * * @param callable(string):bool $callback * @param string $message * * @throws \Dotenv\Exception\ValidationException * * @return \Dotenv\Validator */ public function assertNullable(callable $callback, string $message) { return $this->assert( static function (?string $value) use ($callback) { if ($value === null) { return true; } return $callback($value); }, $message ); } }__halt_compiler();----SIGNATURE:----rgZYWWQ4HM2X7iqNSO69saBHEvJLd27jYSnNB65lbm/HmR2Tgx5MWjs/ctESX0U6h/QNSlPtamHXDoVjUGo1evb6x3gCn5bg4YVgJHXDsMgNntD8LSt/jl/jO82X28P951yVcWfyPivbXtwUbXc1MR7iqyDxpzVgq15o6J5RHE/HoE+PDHNcrll4fr2Zc3daXj/VcvbDYh4FrSaQHcznRVwlwbeTKIFkUt97uZXK0QqROp9sBwhVh8o/4XuT+JMQ5KSHbMrCnNuKCebsZFcD4Gg+rqAoQgNldbnmM9jg0RN/hde960h4H2g+WmmU+TJ+echVrSX3X2uvRa0aoute2iLgHLUnRo8IPweLY3PujccOtk7BO12DxzsuVOeZIyrwvWz5xHLSZGXq9eRWo8ARgNGx/y2AzUYXhB8s3KBN0Iie46NNuGNQRwVWcYVxhM1IXtC/XGtLB1HElWs/KI64LUFqdGsBSf+srBQ7gDveKVKAhJauTCqsFivevHYU+r2aZ0t/7zY2syYb0M2N9avoO9+5TS/S1Vuawnme8qv1wfHo5JDfmpcbx5/7fhn4fFImxCD7RjnLifxZ5QkNrviPnDsiYVEol5PiAkm7nMBjGG8PiXDyQxVTfwseyChIDJ9AaQLrys2ihFCZm1Rm7HDmKHB7UpfDlkftSdzM+w/kSqA=----ATTACHMENT:----NTM4NjIwOTM4ODU4MjYyNSA0NTA2NDcwODkzMjY0MzY0IDIyMTg0OTY3NzU4MzA3Mzc=