data[] = new MapItem($key, $value); } public function count(): int { return \count($this->data); } public function getIterator(): \Iterator { return new \ArrayIterator($this->data); } public function getNormalizedData(bool $ignoreTags = false): array { $result = []; foreach ($this->data as $object) { $result[$object->getKey()->getNormalizedData($ignoreTags)] = $object->getValue()->getNormalizedData($ignoreTags); } return $result; } public function __toString(): string { $result = parent::__toString(); foreach ($this->data as $object) { $result .= (string) $object->getKey(); $result .= (string) $object->getValue(); } $bin = hex2bin('FF'); if (false === $bin) { throw new InvalidArgumentException('Unable to convert the data'); } $result .= $bin; return $result; } }