public function onPreAutoloadDump(Event $event)
    {
        $basePath = $this->getBasePath($event);
        $lockPath = "{$basePath}/pre.lock";

        $shouldOptimize = $this->shouldOptimize($event);

        if ($shouldOptimize) {
            file_put_contents($lockPath, time());

            if (!file_exists("{$basePath}/vendor/autoload.php")) {
                return;
            }

            require_once "{$basePath}/vendor/autoload.php";

            $directory = new RecursiveDirectoryIterator($basePath);

            $files = new RecursiveIteratorIterator(
                $directory, RecursiveIteratorIterator::SELF_FIRST
            );

            foreach ($files as $file) {
                if (stripos($file, "{$basePath}/vendor") === 0) {
                    continue;
                }

                if ($file->getExtension() !== "pre") {
                    continue;
                }

                $pre = $file->getPathname();
                $php = preg_replace("/pre$/", "php", $pre);

                compile(
                    $pre, $php, $format = true, $comment = false
                );
            }
        } else {
            if (file_exists($lockPath)) {
                unlink($basePath . "/pre.lock");
            }
        }
    }