private function assertArrayOrScalar(&$partialMetadata, $partialKey)
    {
        if (is_scalar($partialMetadata)) return;

        if (! is_array($partialMetadata)) {
            throw new \InvalidArgumentException(sprintf(
                'The metadata key %s contains an invalid data type. Allowed types are all scalar types and arrays. Got %s',
                $partialKey,
                (is_object($partialMetadata)? get_class($partialMetadata) : gettype($partialMetadata))
            ));
        }

        foreach ($partialMetadata as $subKey => &$subPartial) {
            $this->assertArrayOrScalar($subPartial, $subKey);
        }
    }