<?php

namespace MGModule\DNSManager2\mgLibs\custom\dns\record\type;

class CNAME extends RecordTypeAbstract {
    /**
     * A <domain-name> which specifies the canonical or primary name for the owner. The owner name is an alias.
     */
    public $cname;

    /**
     * @param string $cname Valid ip or domain
     * @return bool
     */
    public function cnameValidate($cname){
        return (filter_var($cname,FILTER_VALIDATE_DOMAIN,FILTER_FLAG_HOSTNAME) || filter_var($cname,FILTER_VALIDATE_IP));
    }

    public function unify()
    {
        $this->cname = rtrim($this->cname, '.') . '.';
    }
}