<?php

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

use MGModule\DNSManager2\mgLibs\custom\dns\record\type\RP;

class RPAdapter extends AbstractRCodeZeroAdapter
{
    /**
     * @param string $content
     */
    public function createRdata( $content )
    {
        $contentArray = explode(' ', $content);

        $this->rdata = new RP();
        $this->rdata->mbox = $this->contentToRelative($contentArray[0]);
        $this->rdata->txtdname = $this->contentToRelative($contentArray[1]);
    }

    /**
     * @param RP $rdata
     * @return string
     */
    public function parseContentToApiFormat( $rdata )
    {
        $content = [
            $this->contentToAbsolute($rdata->mbox),
            $this->contentToAbsolute($rdata->txtdname)
        ];

        return implode(' ', $content);
    }
}