<?php

namespace MGModule\DNSManager2\mgLibs\custom\dns\submodules\cPanel;

use MGModule\DNSManager2\mgLibs\custom\dns\record\Record;

class DNAMEAdapter extends Record
{
    public function __construct( Record $record)
    {
        $this->line = $record->line;
        $this->name = $record->name;
        $this->type = 'DNAME';
        $this->class = $record->class;
        $this->ttl = $record->ttl;
        $this->rdlength = $record->rdlength;

        $this->rdata = new CpanelRecordAdapterType();

        $this->rdata->dname = $record->rdata->target;
        $this->absoluteName = $record->absoluteName;
        $this->customData = $record->customData;
    }

    public static function toDnsManagerRecord(array $recordArray)
    {
        $recordArray['target'] = $recordArray['dname'];
        unset($recordArray['dname']);

        return Record::tryToCreateFromArray($recordArray);
    }
}