-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShell.php
More file actions
70 lines (58 loc) · 1.5 KB
/
Copy pathShell.php
File metadata and controls
70 lines (58 loc) · 1.5 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
70
<?php
declare(strict_types=1);
namespace PHPCensor\Plugins\Common;
use PHPCensor\Common\Build\BuildInterface;
use PHPCensor\Common\Plugin\Plugin;
/**
* Shell Plugin allows execute shell commands.
*
* @package PHP Censor
* @subpackage Plugins
*
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
* @author Kinn Coelho Julião <kinncj@gmail.com>
*/
class Shell extends Plugin
{
/**
* @var string[] $commands The commands to be executed
*/
private array $commands = [];
private bool $executeAll = false;
/**
* {@inheritDoc}
*/
public static function getName(): string
{
return 'shell';
}
/**
* {@inheritDoc}
*/
public function execute(): bool
{
$result = true;
foreach ($this->commands as $command) {
$command = $this->variableInterpolator->interpolate($command);
if (!$this->commandExecutor->executeCommand($command)) {
$result = false;
if (!$this->executeAll) {
return $result;
}
}
}
return $result;
}
protected function initPluginSettings(): void
{
$this->executeAll = (bool)$this->options->get('execute_all', $this->executeAll);
$this->commands = (array)$this->options->get('commands', $this->commands);
}
/**
* {@inheritDoc}
*/
public static function canExecute(string $stage, BuildInterface $build): bool
{
return true;
}
}