all-in-one/php/src/Data/Setup.php

28 lines
630 B
PHP
Raw Normal View History

2021-11-30 11:20:42 +01:00
<?php
namespace AIO\Data;
use AIO\Auth\PasswordGenerator;
readonly class Setup {
2021-11-30 11:20:42 +01:00
public function __construct(
private PasswordGenerator $passwordGenerator,
private ConfigurationManager $configurationManager,
) {
2021-11-30 11:20:42 +01:00
}
public function Setup() : string {
if(!$this->CanBeInstalled()) {
return '';
}
$password = $this->passwordGenerator->GeneratePassword(8);
2021-11-30 11:20:42 +01:00
$this->configurationManager->SetPassword($password);
return $password;
}
public function CanBeInstalled() : bool {
return !file_exists(DataConst::GetConfigFile());
}
}