<?php

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

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

class URIAdapter extends AbstractRCodeZeroAdapter
{
    /**
     * @param string $content
     */
    public function createRdata( $content )
    {
        $contentArray = explode(' ', $content);
        $this->rdata = new URI();
        $this->rdata->priority = $contentArray[0];
        $this->rdata->weight = $contentArray[1];
        $this->rdata->target = $this->contentToRelative($contentArray[2]);
    }

    /**
     * @param URI $rdata
     * @return string
     */
    public function parseContentToApiFormat( $rdata )
    {
        $content = [
            $rdata->priority,
            $rdata->weight,
            $rdata->target
        ];

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