CluPilotCloud/app/Services/Dns/FakeHostDnsDirectory.php

38 lines
853 B
PHP

<?php
namespace App\Services\Dns;
use RuntimeException;
class FakeHostDnsDirectory implements HostDnsDirectory
{
/** @var array<string, string> name => ip */
public array $ips = [];
/** @var array<string, string> name => fqdn */
public array $fqdns = [];
public bool $failWrite = false;
public bool $failRemove = false;
public function write(string $name, string $fqdn, string $ip): void
{
if ($this->failWrite) {
throw new RuntimeException('dns-hosts volume unavailable');
}
$this->ips[$name] = $ip;
$this->fqdns[$name] = $fqdn;
}
public function remove(string $name): void
{
if ($this->failRemove) {
throw new RuntimeException('dns-hosts volume unavailable');
}
unset($this->ips[$name], $this->fqdns[$name]);
}
}