private function prepareRequest(Query $query) { $request = new Message(); $request->header->set('id', $this->generateId()); $request->header->set('rd', 1); $request->questions[] = $query; $request->prepare(); return $request; }
private function buildResponse(Query $query, array $cachedRecords) : Message { $response = new Message(); $response->header->set('id', $this->generateId()); $response->header->set('qr', 1); $response->header->set('opcode', Message::OPCODE_QUERY); $response->header->set('rd', 1); $response->header->set('rcode', Message::RCODE_OK); $response->questions[] = new Record($query->getName(), $query->getType(), $query->getClass()); foreach ($cachedRecords as $record) { $response->answers[] = $record; } $response->prepare(); return $response; }