public function addItem($object, ?string $key = null) : void
    {
        $this->checkCallback();

        if (null !== $key) {
            if (isset($this->members[$key])) {
                throw new CollectionException('Unable to add to collection - key ' . $key . ' already used.');
            } else {
                $this->members[$key] = $object;
            }
        } else {
            $this->members[] = $object;
        }
    }