data as $object) { $result .= (string) $object; } $bin = hex2bin('FF'); if (false === $bin) { throw new InvalidArgumentException('Unable to convert the data'); } $result .= $bin; return $result; } public function add(TextStringObject $chunk): void { $this->data[] = $chunk; } public function append(string $chunk): void { $this->add(new TextStringObject($chunk)); } public function getValue(): string { $result = ''; foreach ($this->data as $object) { $result .= $object->getValue(); } return $result; } public function getLength(): int { $length = 0; foreach ($this->data as $object) { $length += $object->getLength(); } return $length; } public function getNormalizedData(bool $ignoreTags = false): string { $result = ''; foreach ($this->data as $object) { $result .= $object->getNormalizedData($ignoreTags); } return $result; } }