protected function getMappingDriver(array $metadataMapping)
    {
        if (array_key_exists('driver', $metadataMapping)) {
            $mappingDriver = $metadataMapping['driver'];

            if (!$mappingDriver instanceof MappingDriver) {
                throw new \UnexpectedValueException(
                    sprintf('Provided driver should be of the type MappingDriver, "%s" given', gettype($mappingDriver))
                );
            }

            return $mappingDriver;
        }

        if (count(array_intersect(['type', 'path'], array_keys($metadataMapping))) === 2) {
            $metadataMapping = array_merge(['extension' => null], $metadataMapping);

            return $this->getMappingDriverImplementation(
                $metadataMapping['type'],
                (array) $metadataMapping['path'],
                $metadataMapping['extension']
            );
        }

        throw new \UnexpectedValueException(
            'metadata_mapping must be array with "driver" key or "type" and "path" keys'
        );
    }