66use PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
77use PhpSchool \PhpWorkshop \Exercise \ExerciseType ;
88use PhpSchool \PhpWorkshop \ExerciseCheck \ComposerExerciseCheck ;
9+ use PhpSchool \PhpWorkshop \Input \Input ;
910use PhpSchool \PhpWorkshop \Result \Failure ;
1011use PhpSchool \PhpWorkshop \Result \ResultInterface ;
1112use PhpSchool \PhpWorkshop \Result \Success ;
@@ -35,24 +36,24 @@ public function getName()
3536 * a success is returned.
3637 *
3738 * @param ExerciseInterface $exercise The exercise to check against.
38- * @param string $fileName The absolute path to the student's solution .
39+ * @param Input $input The command line arguments passed to the command .
3940 * @return ResultInterface The result of the check.
4041 */
41- public function check (ExerciseInterface $ exercise , $ fileName )
42+ public function check (ExerciseInterface $ exercise , Input $ input )
4243 {
4344 if (!$ exercise instanceof ComposerExerciseCheck) {
4445 throw new \InvalidArgumentException ;
4546 }
4647
47- if (!file_exists (sprintf ('%s/composer.json ' , dirname ($ fileName )))) {
48+ if (!file_exists (sprintf ('%s/composer.json ' , dirname ($ input -> getArgument ( ' program ' ) )))) {
4849 return new Failure ($ this ->getName (), 'No composer.json file found ' );
4950 }
5051
51- if (!file_exists (sprintf ('%s/composer.lock ' , dirname ($ fileName )))) {
52+ if (!file_exists (sprintf ('%s/composer.lock ' , dirname ($ input -> getArgument ( ' program ' ) )))) {
5253 return new Failure ($ this ->getName (), 'No composer.lock file found ' );
5354 }
5455
55- $ lockFile = new LockFileParser (sprintf ('%s/composer.lock ' , dirname ($ fileName )));
56+ $ lockFile = new LockFileParser (sprintf ('%s/composer.lock ' , dirname ($ input -> getArgument ( ' program ' ) )));
5657 $ missingPackages = array_filter ($ exercise ->getRequiredPackages (), function ($ package ) use ($ lockFile ) {
5758 return !$ lockFile ->hasInstalledPackage ($ package );
5859 });
@@ -78,7 +79,7 @@ public function check(ExerciseInterface $exercise, $fileName)
7879 */
7980 public function canRun (ExerciseType $ exerciseType )
8081 {
81- return true ;
82+ return in_array ( $ exerciseType -> getValue (), [ExerciseType:: CGI , ExerciseType:: CLI ]) ;
8283 }
8384
8485 /**
0 commit comments