99use  PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
1010use  PhpSchool \PhpWorkshop \Exercise \ExerciseType ;
1111use  PhpSchool \PhpWorkshop \ExerciseCheck \ComposerExerciseCheck ;
12+ use  PhpSchool \PhpWorkshop \ExerciseRunner \Context \ExecutionContext ;
1213use  PhpSchool \PhpWorkshop \Input \Input ;
1314use  PhpSchool \PhpWorkshop \Result \ComposerFailure ;
1415use  PhpSchool \PhpWorkshop \Result \Failure ;
@@ -34,30 +35,29 @@ public function getName(): string
3435 * installed a set of required packages. If they did not a failure is returned, otherwise, 
3536 * a success is returned. 
3637 * 
37-  * @param ExerciseInterface $exercise The exercise to check against. 
38-  * @param Input $input The command line arguments passed to the command. 
38+  * @param ExecutionContext $context The current execution context, containing the exercise, input and working directories. 
3939 * @return ResultInterface The result of the check. 
40-  * @noinspection SpellCheckingInspection 
4140 */ 
42-  public  function  check (ExerciseInterface $ exercise ,  Input $ input ResultInterface 
41+  public  function  check (ExecutionContext $ context ResultInterface 
4342 {
43+  $ exercise$ contextgetExercise ();
4444 if  (!$ exerciseinstanceof  ComposerExerciseCheck) {
4545 throw  new  InvalidArgumentException ();
4646 }
4747
48-  if  (!file_exists (sprintf ('%s/composer.json ' , dirname ( $ input -> getRequiredArgument ( ' program ' ) )))) {
48+  if  (!file_exists (sprintf ('%s/composer.json ' , $ context -> getStudentExecutionDirectory ( )))) {
4949 return  ComposerFailure::fromCheckAndMissingFileOrFolder ($ this 'composer.json ' );
5050 }
5151
52-  if  (!file_exists (sprintf ('%s/composer.lock ' , dirname ( $ input -> getRequiredArgument ( ' program ' ) )))) {
52+  if  (!file_exists (sprintf ('%s/composer.lock ' , $ context -> getStudentExecutionDirectory ( )))) {
5353 return  ComposerFailure::fromCheckAndMissingFileOrFolder ($ this 'composer.lock ' );
5454 }
5555
56-  if  (!file_exists (sprintf ('%s/vendor ' , dirname ( $ input -> getRequiredArgument ( ' program ' ) )))) {
56+  if  (!file_exists (sprintf ('%s/vendor ' , $ context -> getStudentExecutionDirectory ( )))) {
5757 return  ComposerFailure::fromCheckAndMissingFileOrFolder ($ this 'vendor ' );
5858 }
5959
60-  $ lockFilenew  LockFileParser (sprintf ('%s/composer.lock ' , dirname ( $ input -> getRequiredArgument ( ' program ' ) )));
60+  $ lockFilenew  LockFileParser (sprintf ('%s/composer.lock ' , $ context -> getStudentExecutionDirectory ( )));
6161 $ missingPackagesarray_filter ($ exercisegetRequiredPackages (), function  ($ packageuse  ($ lockFile
6262 return  !$ lockFilehasInstalledPackage ($ package
6363 });
0 commit comments