<?php

namespace MGModule\DNSManager2\mgLibs\custom\dns\submodules\PowerDNSv4\Adapters;

use MGModule\DNSManager2\mgLibs\custom\dns\record\type\ALIAS;
use MGModule\DNSManager2\mgLibs\custom\helpers\IdnaHelper;

class ALIASAdapter extends AbstractPowerDNSv4Adapter
{
    /**
     * @param string $content
     */
    public function createRdata( $content )
    {
        $this->rdata = new ALIAS();
        $this->rdata->target = $this->contentToRelative(IdnaHelper::idnaDecode($content));
    }

    /**
     * @param ALIAS $rdata
     * @return string
     */
    public function parseContentToApiFormat( $rdata )
    {
        return  $this->contentToAbsolute(IdnaHelper::idnaEncode($rdata->target));
    }
}