/**
  * Return's the answer to the passed question to resolve a DNS request.
  *
  * @param array $question The question
  *
  * @return array The answer
  */
 public function getAnswer(array $question)
 {
     // initialize the variables
     $answer = array();
     $domain = trim($question[0]['qname'], '.');
     $type = RecordTypeEnum::getName($question[0]['qtype']);
     // load the matching DNS records
     $records = $this->getRecordsRecursivly($domain, $type);
     // prepare the answer for each record we found
     foreach ($records as $record) {
         $answer[] = array('name' => $question[0]['qname'], 'class' => $question[0]['qclass'], 'ttl' => $record['ttl'], 'data' => array('type' => $question[0]['qtype'], 'value' => $record['answer']));
     }
     // return the answer
     return $answer;
 }
 /**
  * Return's the answer to the passed question to resolve a DNS request.
  *
  * @param array $question The question
  *
  * @return array The answer
  */
 public function getAnswer(array $question)
 {
     // initialize the variables
     $answer = array();
     $domain = trim($question[0]['qname'], '.');
     $type = RecordTypeEnum::getName($question[0]['qtype']);
     // query whether the requested domain and type are set in our domain records
     if (isset($this->dnsRecords[$domain]) && isset($this->dnsRecords[$domain][$type])) {
         // query whether or not the type is an array and NOT 'SOA'
         if (is_array($this->dnsRecords[$domain][$type]) && $type != 'SOA') {
             // iterate over the domain's types and load the IP
             foreach ($this->dnsRecords[$domain][$type] as $ip) {
                 $answer[] = array('name' => $question[0]['qname'], 'class' => $question[0]['qclass'], 'ttl' => $this->dsTtl, 'data' => array('type' => $question[0]['qtype'], 'value' => $ip));
             }
         } else {
             $answer[] = array('name' => $question[0]['qname'], 'class' => $question[0]['qclass'], 'ttl' => $this->dsTtl, 'data' => array('type' => $question[0]['qtype'], 'value' => $this->dnsRecords[$domain][$type]));
         }
     }
     // return the answer
     return $answer;
 }