public function getDriver(array $mappingSource): DriverInterface
    {
        if (\array_key_exists('driver', $mappingSource)) {
            $driver = $mappingSource['driver'];

            if (!$driver instanceof DriverInterface) {
                throw new DriverException(\sprintf(
                    'Metadata mapping driver should be of the type %s, %s given',
                    DriverInterface::class,
                    \is_object($driver) ? \get_class($driver) : \gettype($driver)
                ));
            }

            return $driver;
        }

        $supportedKeys = ['type', 'path'];
        if (\count(\array_intersect($supportedKeys, \array_keys($mappingSource))) === \count($supportedKeys)) {
            return $this->getDriverImplementation($mappingSource['type'], (array) $mappingSource['path']);
        }

        throw new DriverException(
            'Mapping must be array with "driver" key or "type" and "path" keys'
        );
    }