public function exportStubs($type, $destination, $namespace = null)
    {
        // If we have no stubs for this type, cancel
        $source = __DIR__.'/../../../stubs/'.$type;
        if (!$this->files->has($source)) {
            return;
        }

        $this->files->createDir($destination);
        $files = $this->files->listFiles($source, true);
        foreach ($files as $file) {
            $contents = $this->files->read($file['path']);
            $basename = $file['basename'];
            $fileDestination = $destination.DS.$basename;

            if ($namespace) {
                $namespace = preg_replace("/[^\w]/", '', $namespace); // only words allowed
                $contents = str_replace('namespace App', 'namespace '.$namespace, $contents);
                $contents = str_replace('AppServiceProvider', $namespace.'ServiceProvider', $contents);
                $fileDestination = mb_strpos($basename, 'ServiceProvider') === false
                    ? $destination.DS.basename(dirname($file['path'])).DS.$basename
                    : $destination.DS.$namespace.'ServiceProvider.php';
            }

            $this->files->put($fileDestination, $contents);
        }
    }