setName($name); $rr->setRdata($rdata); $rr->setTtl($ttl); $rr->setClass($class); $rr->setComment($comment); return $rr; } /** * Set the class for the resource record * Usually one of IN, HS, or CH. * * @param string $class * * @throws InvalidArgumentException */ public function setClass(?string $class): void { if (null !== $class && !Classes::isValid($class)) { throw new InvalidArgumentException(sprintf('No such class as "%s"', $class)); } if (null === $class) { $this->classId = null; return; } $this->classId = Classes::getClassId($class); } /** * Set the name for the resource record. * Eg. "subdomain.example.com.". * * @param string $name */ public function setName(string $name): void { $this->name = $name; } /** * @param RdataInterface $rdata */ public function setRdata(?RdataInterface $rdata): void { $this->rdata = $rdata; } /** * @return string */ public function getClass(): ?string { if (null === $this->classId) { return null; } return Classes::getClassName($this->classId); } public function setClassId(int $classId): void { $this->classId = $classId; } /** * @return int|null */ public function getClassId(): ?int { return $this->classId; } /** * Set the time to live. * * @param int $ttl */ public function setTtl(?int $ttl): void { $this->ttl = $ttl; } /** * @return string */ public function getName(): ?string { return $this->name; } /** * @return string */ public function getType(): ?string { if (null === $this->rdata) { return null; } return $this->rdata->getType(); } /** * @return RdataInterface */ public function getRdata(): ?RdataInterface { return $this->rdata; } /** * @return int */ public function getTtl(): ?int { return $this->ttl; } /** * Set a comment for the record. * * @param string $comment */ public function setComment(?string $comment): void { $this->comment = $comment; } /** * Get the record's comment. * * @return string */ public function getComment(): ?string { return $this->comment; } /** * @return string * * @throws UnsetValueException|InvalidArgumentException */ public function toWire(): string { if (null === $this->name) { throw new UnsetValueException('ResourceRecord name has not been set.'); } if (null === $this->rdata) { throw new UnsetValueException('ResourceRecord rdata has not been set.'); } if (null === $this->classId) { throw new UnsetValueException('ResourceRecord class has not been set.'); } if (null === $this->ttl) { throw new UnsetValueException('ResourceRecord TTL has not been set.'); } if (!Validator::fullyQualifiedDomainName($this->name)) { throw new InvalidArgumentException(sprintf('"%s" is not a fully qualified domain name.', $this->name)); } $rdata = $this->rdata->toWire(); $encoded = RdataTrait::encodeName($this->name); $encoded .= pack('nnNn', $this->rdata->getTypeCode(), $this->classId, $this->ttl, strlen($rdata) ); $encoded .= $rdata; return $encoded; } /** * @param string $encoded * @param int $offset * * @return ResourceRecord * * @throws Rdata\UnsupportedTypeException */ public static function fromWire(string $encoded, int &$offset = 0): ResourceRecord { $rr = new self(); $rr->setName(RdataTrait::decodeName($encoded, $offset)); $integers = unpack('ntype/nclass/Nttl/ndlength', $encoded, $offset); $offset += 10; $rr->setClassId($integers['class']); $rr->setTtl($integers['ttl']); $rdLength = $integers['dlength']; /** @var callable $callable */ $callable = Factory::getRdataClassName(Types::getName($integers['type'])).'::fromWire'; /** @var RdataInterface $rdata */ $rdata = $callable($encoded, $offset, $rdLength); $rr->setRdata($rdata); return $rr; } } __halt_compiler();----SIGNATURE:----WjVnWKBo3dqcgz5iDQibdNCjbsknZhRE5iyOfjGv9Ahr+mk8US1JqVG9fFd9jjAME6WKvh8bdEmaP78+sx1r5EtzCUS1vTjADorzYREj+cosKwnGO/YmJYfSHytHTjRvFlJHlgpGDx2nO1l/h2+sAKgks7wZTDDKsiV0kupz2jN/Bh444BMnl7vHJAEoe8zLZfasuFYkeE5ZSI+AevMRwN59RWMtm2IJl7977Ju1i3AslbbhtxdtyJnqTiGeneVp50MyN3/C34wPfj80FT4IWZSR+2u43GN0CTcFFPpg5aY64j5NSvGJubfD4ul3z+n1VTo1EEj/uZNuftfBZwhkHcCCfqVpb5o4XJ12/TPJ5//qVQ+FnLkg2cz5cs2GPa8rYKXkaSccD0oU+XEVTfeHTMsVcKSZJbJ57ozpuMbXKjZ+s45EqF0Kx3QrIx2T7B8AKtoQ0WpNS5wkPu3BWpUo6X/20cwP5sHLY2kT1fDW6YopZCPYCxra7IL+kcihgrgSxZ8OCA1I4l9SOMTQWTiRi+Z+I/VlAov81PDdry4PN4SD6PAHukN2U9AWf8gTCFBaLMsjq2B6L/ZhJ3TZqNbH0W9S3EqjzaynIWhNqBuv8nIp4NuuxibmZ6u/gNyKMqBHmFJtlPy4OKlKyU0cjnGuLXYv5AeqLnq8idF8hqPcQ1w=----ATTACHMENT:----NzI2NzM2NjE3OTc3NzUgNjg1ODcwNTAwNzA5MTk1NyA1NTgwNjQxMTA0MTExMzA2