Issues (18)

src/Commands/PackageRemove.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Blok\LaravelPackageGenerator\Commands;
4
5
use Blok\LaravelPackageGenerator\Commands\Traits\ChangesComposerJson;
6
use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithComposer;
7
use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithUser;
8
use Blok\LaravelPackageGenerator\Commands\Traits\ManipulatesPackageFolder;
9
use Exception;
10
use Illuminate\Console\Command;
11
12
class PackageRemove extends Command
13
{
14
    use ChangesComposerJson;
15
    use ManipulatesPackageFolder;
16
    use InteractsWithUser;
17
    use InteractsWithComposer;
18
19
    /**
20
     * The name and signature of the console command.
21
     *
22
     * @var string
23
     */
24
    protected $signature = 'package:remove
25
                            {vendor : The vendor part of the namespace}
26
                            {package : The name of package for the namespace}
27
                            {--i|interactive : Interactive mode}';
28
29
    /**
30
     * The console command description.
31
     *
32
     * @var string
33
     */
34
    protected $description = 'Remove the existing package.';
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        $vendor = $this->getVendor();
44
        $package = $this->getPackage();
45
46
        $vendorFolderName = $this->getVendorFolderName($vendor);
47
        $packageFolderName = $this->getPackageFolderName($package);
48
49
        $relPackagePath = "workbench/$vendorFolderName/$packageFolderName";
50
        $packagePath = base_path($relPackagePath);
0 ignored issues
show
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        $packagePath = /** @scrutinizer ignore-call */ base_path($relPackagePath);
Loading history...
51
52
        try {
53
            $this->composerRemovePackage($vendorFolderName, $packageFolderName);
54
            $this->removePackageFolder($packagePath);
55
            $this->unregisterPackage($vendor, $package, "workbench/$vendorFolderName/$packageFolderName");
56
            $this->composerDumpAutoload();
57
        } catch (Exception $e) {
58
            $this->error($e->getMessage());
59
60
            return -1;
61
        }
62
    }
63
}
64