38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Integrations\Domain\Transformers;
|
|
|
|
use App\Integrations\Domain\DTOs\DnsDomainData;
|
|
use App\Integrations\Domain\Support\DnsServerIdResolver;
|
|
|
|
class DnsDomainTransformer
|
|
{
|
|
public function __construct(private DnsServerIdResolver $servers)
|
|
{
|
|
}
|
|
|
|
public function transform(array|object $row): DnsDomainData
|
|
{
|
|
$row = (array) $row;
|
|
|
|
return new DnsDomainData(
|
|
legacyId: (int) $row['id'],
|
|
domainName: $row['domain_name'] ?: null,
|
|
dnsManagerServerId: $this->servers->resolve((int) $row['dns_manager_server_id']),
|
|
isCreated: (int) $row['is_created'],
|
|
pleskId: $row['plesk_id'] !== null ? (int) $row['plesk_id'] : null,
|
|
createdAt: $this->nullableDate($row['created_at'] ?? null),
|
|
updatedAt: $this->nullableDate($row['updated_at'] ?? null),
|
|
);
|
|
}
|
|
|
|
private function nullableDate(?string $value): ?string
|
|
{
|
|
if (! $value || (int) substr($value, 0, 4) < 1970) {
|
|
return null;
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
}
|