-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCliExecuteEvent.php
More file actions
68 lines (60 loc) · 1.7 KB
/
CliExecuteEvent.php
File metadata and controls
68 lines (60 loc) · 1.7 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
<?php
declare(strict_types=1);
namespace PhpSchool\PhpWorkshop\Event;
use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface;
use PhpSchool\PhpWorkshop\Input\Input;
use PhpSchool\PhpWorkshop\Utils\ArrayObject;
/**
* An event to represent events which occur throughout the verification and running process in
* `\PhpSchool\PhpWorkshop\ExerciseRunner\CliRunner`.
*/
class CliExecuteEvent extends CliExerciseRunnerEvent
{
/**
* @var ArrayObject<int, string>
*/
private ArrayObject $args;
/**
* @param string $name The event name.
* @param ArrayObject<int, string> $args The arguments that should be/have been passed to the program.
* @param array<mixed> $parameters The event parameters.
*/
public function __construct(
string $name,
ExerciseInterface $exercise,
Input $input,
ArrayObject $args,
array $parameters = []
) {
$parameters['args'] = $args;
parent::__construct($name, $exercise, $input, $parameters);
$this->args = $args;
}
/**
* Prepend an argument to the list of arguments to be passed to the program.
*
* @param string $arg
*/
public function prependArg(string $arg): void
{
$this->args = $this->args->prepend($arg);
}
/**
* Append an argument to the list of arguments to be passed to the program.
*
* @param string $arg
*/
public function appendArg(string $arg): void
{
$this->args = $this->args->append($arg);
}
/**
* Get the arguments to be passed to the program.
*
* @return ArrayObject<int, string>
*/
public function getArgs(): ArrayObject
{
return $this->args;
}
}