19declare(strict_types=1);
48 protected ?
Password $password =
null,
49 protected bool $create_database =
true,
51 protected ?
int $port =
null,
55 throw new \InvalidArgumentException(
56 "Unknown database type: $type"
60 throw new \InvalidArgumentException(
61 "Unknown collation: $collation"
64 $this->type = trim(
$type);
65 $this->host = trim(
$host);
94 return $this->create_database;
109 return $this->password;
122 return new class ($this) extends \
ilIniFile {
130 public function readVariable(
string $a_group,
string $a_var_name):
string
132 if ($a_group !==
"db") {
133 throw new \LogicException(
134 "Can only access db-config via this mock."
137 switch ($a_var_name) {
139 return $this->config->getUser();
141 return $this->config->getHost();
143 return (
string) $this->config->getPort();
145 $pw = $this->config->getPassword();
146 return $pw !==
null ? $pw->toString() :
"";
148 return $this->config->getDatabase();
150 return $this->config->getType();
152 throw new \LogicException(
153 "Cannot provide variable '$a_var_name'"
161 public function read():
bool
163 throw new \LogicException(
"Just a mock here...");
165 public function parse():
bool
167 throw new \LogicException(
"Just a mock here...");
169 public function fixIniFile(): never
171 throw new \LogicException(
"Just a mock here...");
173 public function write():
bool
175 throw new \LogicException(
"Just a mock here...");
177 public function show():
string
179 throw new \LogicException(
"Just a mock here...");
183 throw new \LogicException(
"Just a mock here...");
187 throw new \LogicException(
"Just a mock here...");
189 public function groupExists(
string $a_group_name):
bool
191 throw new \LogicException(
"Just a mock here...");
193 public function readGroup(
string $a_group_name): array
195 throw new \LogicException(
"Just a mock here...");
197 public function addGroup(
string $a_group_name):
bool
199 throw new \LogicException(
"Just a mock here...");
201 public function removeGroup(
string $a_group_name):
bool
203 throw new \LogicException(
"Just a mock here...");
205 public function variableExists(
string $a_group,
string $a_var_name):
bool
207 throw new \LogicException(
"Just a mock here...");
209 public function setVariable(
string $a_group_name,
string $a_var_name,
string $a_var_value):
bool
211 throw new \LogicException(
"Just a mock here...");
213 public function error(
string $a_errmsg):
bool
215 throw new \LogicException(
"Just a mock here...");
219 throw new \LogicException(
"Just a mock here...");
A password is used as part of credentials for authentication.
variableExists(string $a_group, string $a_var_name)
returns if a variable exists or not
show()
returns the content of IniFile
readGroups()
returns an array with the names of all the groups
getGroupCount()
returns number of groups
removeGroup(string $a_group_name)
removes a group
readGroup(string $a_group_name)
returns an associative array of the variables in one group
setVariable(string $a_group_name, string $a_var_name, string $a_var_value)
sets a variable in a group
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
groupExists(string $a_group_name)
checks if a group exists
addGroup(string $a_group_name)
adds a new group
static getAvailableCollations()
static getInstallableTypes()
toMockIniFile()
Adapter to current database-handling via a mock of \ilIniFile.
const DEFAULT_PATH_TO_DB_DUMP
ilDatabaseSetupConfig $config
__construct(string $type, string $host, string $database, string $user, protected ?Password $password=null, protected bool $create_database=true, ?string $collation=null, protected ?int $port=null, ?string $path_to_db_dump=null)
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
A configuration for the setup.