protected function encodeAnswer(array $answer): string
    {
        $encoded = $this->encodeLabel($answer['host']);
        
        switch ($answer['type']) {
            case self::TYPE_A:
            case self::TYPE_AAAA:
                $data = \inet_pton($answer['data']);
                break;
            case self::TYPE_CNAME:
                $data = $this->encodeLabel($answer['data']);
                break;
            default:
                $data = $answer['data'];
        }
        
        $encoded .= \pack('nnNn', $answer['type'], self::CLASS_IN, $answer['ttl'], \strlen($data));
        $encoded .= $data;
        
        return $encoded;
    }
protected function encodeAnswer(array $answer): string
    {
        $encoded = $this->encodeLabel($answer['host']);
        
        switch ($answer['type']) {
            case self::TYPE_A:
            case self::TYPE_AAAA:
                $data = \inet_pton($answer['data']);
                break;
            case self::TYPE_CNAME:
                $data = $this->encodeLabel($answer['data']);
                break;
            default:
                $data = $answer['data'];
        }
        
        $encoded .= \pack('nnNn', $answer['type'], self::CLASS_IN, $answer['ttl'], \strlen($data));
        $encoded .= $data;
        
        return $encoded;
    }
protected function encodeAnswer ( array $ answer ) : string { $ encoded = $ this -> encodeLabel ( $ answer [ 'host' ] ) ; switch ( $ answer [ 'type' ] ) { case self :: TYPE_A : case self :: TYPE_AAAA : $ data = \ inet_pton ( $ answer [ 'data' ] ) ; break ; case self :: TYPE_CNAME : $ data = $ this -> encodeLabel ( $ answer [ 'data' ] ) ; break ; default : $ data = $ answer [ 'data' ] ; } $ encoded .= \ pack ( 'nnNn' , $ answer [ 'type' ] , self :: CLASS_IN , $ answer [ 'ttl' ] , \ strlen ( $ data ) ) ; $ encoded .= $ data ; return $ encoded ; }
Encode an answer record.
Encode an answer record .