-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRemove.php
More file actions
69 lines (56 loc) · 1.27 KB
/
Remove.php
File metadata and controls
69 lines (56 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Winter\Packager\Commands;
use Winter\Packager\Composer;
use Winter\Packager\Exceptions\CommandException;
class Remove extends BaseCommand
{
/**
* Command constructor.
*/
final public function __construct(
protected Composer $composer,
protected string $package,
protected bool $dryRun = false,
protected bool $dev = false
) {
parent::__construct($composer);
}
/**
* @inheritDoc
*/
public function arguments(): array
{
$arguments = [];
if ($this->dryRun) {
$arguments['--dry-run'] = true;
}
if ($this->dev) {
$arguments['--dev'] = true;
}
$arguments['packages'] = [$this->package];
return $arguments;
}
public function execute()
{
$output = $this->runComposerCommand();
$message = implode(PHP_EOL, $output['output']);
if ($output['code'] !== 0) {
throw new CommandException($message);
}
return $message;
}
/**
* @inheritDoc
*/
protected function requiresWorkDir(): bool
{
return true;
}
/**
* @inheritDoc
*/
public function getCommandName(): string
{
return 'remove';
}
}