|
9 | 9 | use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface;
|
10 | 10 | use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
|
11 | 11 | use PhpSchool\PhpWorkshop\ExerciseCheck\ComposerExerciseCheck;
|
| 12 | +use PhpSchool\PhpWorkshop\ExerciseRunner\Context\ExecutionContext; |
| 13 | +use PhpSchool\PhpWorkshop\ExerciseRunner\Environment; |
12 | 14 | use PhpSchool\PhpWorkshop\Input\Input;
|
13 | 15 | use PhpSchool\PhpWorkshop\Result\ComposerFailure;
|
14 | 16 | use PhpSchool\PhpWorkshop\Result\Failure;
|
@@ -39,26 +41,26 @@ public function getName(): string
|
39 | 41 | * @return ResultInterface The result of the check.
|
40 | 42 | * @noinspection SpellCheckingInspection
|
41 | 43 | */
|
42 |
| - public function check(ExerciseInterface $exercise, Input $input): ResultInterface |
| 44 | + public function check(ExecutionContext $context): ResultInterface |
43 | 45 | {
|
44 |
| - if (!$exercise instanceof ComposerExerciseCheck) { |
| 46 | + if (!$context->exercise instanceof ComposerExerciseCheck) { |
45 | 47 | throw new InvalidArgumentException();
|
46 | 48 | }
|
47 | 49 |
|
48 |
| - if (!file_exists(sprintf('%s/composer.json', dirname($input->getRequiredArgument('program'))))) { |
| 50 | + if (!file_exists(sprintf('%s/composer.json', dirname($context->input->getRequiredArgument('program'))))) { |
49 | 51 | return ComposerFailure::fromCheckAndMissingFileOrFolder($this, 'composer.json');
|
50 | 52 | }
|
51 | 53 |
|
52 |
| - if (!file_exists(sprintf('%s/composer.lock', dirname($input->getRequiredArgument('program'))))) { |
| 54 | + if (!file_exists(sprintf('%s/composer.lock', dirname($context->input->getRequiredArgument('program'))))) { |
53 | 55 | return ComposerFailure::fromCheckAndMissingFileOrFolder($this, 'composer.lock');
|
54 | 56 | }
|
55 | 57 |
|
56 |
| - if (!file_exists(sprintf('%s/vendor', dirname($input->getRequiredArgument('program'))))) { |
| 58 | + if (!file_exists(sprintf('%s/vendor', dirname($context->input->getRequiredArgument('program'))))) { |
57 | 59 | return ComposerFailure::fromCheckAndMissingFileOrFolder($this, 'vendor');
|
58 | 60 | }
|
59 | 61 |
|
60 |
| - $lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($input->getRequiredArgument('program')))); |
61 |
| - $missingPackages = array_filter($exercise->getRequiredPackages(), function ($package) use ($lockFile) { |
| 62 | + $lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($context->input->getRequiredArgument('program')))); |
| 63 | + $missingPackages = array_filter($context->exercise->getRequiredPackages(), function ($package) use ($lockFile) { |
62 | 64 | return !$lockFile->hasInstalledPackage($package);
|
63 | 65 | });
|
64 | 66 |
|
|
0 commit comments