public function getMapper()
    {
        $map = $this->getMap();

        return function ($path) use ($map) {
            foreach ($map as $item) {
                foreach ($item as $match => $replace) {
                    if (empty($match)) {
                        return $replace . $path;
                    } elseif (0 === strpos($path, $match)) {
                        return preg_replace(
                            '/^' . preg_quote($match, '/') . '/',
                            $replace,
                            $path
                        );
                    }
                }
            }

            return null;
        };
    }