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:----2TkZ4INbtpgZGBEh8A5wCSVCXivWoldRnDO0j4Q/z8Jr2vi78uyy8G5JkVt/B1x+TeUl2xgDYw2eooGIbAl5SdeDhB7w6xGcid3vL8mafODrQ2bBN/2scYW4suF4hoDJKW7NLex9jeQ8MosclImvRJFI3FFma3SfLw1x5mEBS9G8ngEJ3AqgV5Ko+xNsN4eBx7qzBsBaPJ/vMD6F5c+InmKTrgAcnfy+pJJAwgMrjwLfGwvIm+nAltktb2wAkCUzvNyKntTsOhL9AwFEgKg0xki0+gG5MRh5pcLioScVQnRFDO8vgtyiiBVMu6S8tHcaJ+WF1t7QkLr5Oe89mfN5zjWAe0sc2YAxRA/9D6yxmAmIZ9mro20VRs6hGxIenyL+6P434GHdU4LFJH+zvTl1kPb59kpkDDHjN8LkdY1EJDFWlug1DyqWG9PwZAJ5CO4oXDN9TE3oIY3x4mYEbtRMTZa990RfxTTPk4YwNnEnxEZU7KFchPTyW31Kq4mOZ96tTXeRN56XWNj87VohpCC0/whdCmlw8W3xXt9cr+YRlgNnabT/d+YNGgX/zgKuRlQZqkOJHR2mis0ki5VvWRyAt/3Ji+kixmPcfwLDlWuPPHhokamVujW4IzeN29AM8Nh2q4+peRx8ykg1TMiSvYA2EymqhP1ZwJFGc0VzCgDsy9A=----ATTACHMENT:----NDYwNTIxMDY0MzMyMTMyNCA1NzA3NDMxNDUxNTc3MzI5IDUwMTcxMzMxOTE0ODg0NDU=