31 lines
785 B
PHP
31 lines
785 B
PHP
<?php
|
|
|
|
namespace App\User;
|
|
|
|
use RuntimeException;
|
|
|
|
class EnvironmentInitialAdminCredentialsProvider implements
|
|
InitialAdminCredentialsProvider
|
|
{
|
|
public function getCredentials(): InitialAdminCredentials
|
|
{
|
|
return new InitialAdminCredentials(
|
|
email: $this->requiredEnvironmentValue(
|
|
'RABBI_GERZI_INITIAL_ADMIN_EMAIL',
|
|
),
|
|
password: $this->requiredEnvironmentValue(
|
|
'RABBI_GERZI_INITIAL_ADMIN_PASSWORD',
|
|
),
|
|
);
|
|
}
|
|
|
|
private function requiredEnvironmentValue(string $key): string
|
|
{
|
|
$value = getenv($key);
|
|
if (! is_string($value) || trim($value) === '') {
|
|
throw new RuntimeException("$key is required");
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
}
|