6
6
use PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
7
7
use PhpSchool \PhpWorkshop \Exercise \ExerciseType ;
8
8
use PhpSchool \PhpWorkshop \ExerciseCheck \ComposerExerciseCheck ;
9
+ use PhpSchool \PhpWorkshop \Input \Input ;
9
10
use PhpSchool \PhpWorkshop \Result \Failure ;
10
11
use PhpSchool \PhpWorkshop \Result \ResultInterface ;
11
12
use PhpSchool \PhpWorkshop \Result \Success ;
@@ -35,24 +36,24 @@ public function getName()
35
36
* a success is returned.
36
37
*
37
38
* @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 .
39
40
* @return ResultInterface The result of the check.
40
41
*/
41
- public function check (ExerciseInterface $ exercise , $ fileName )
42
+ public function check (ExerciseInterface $ exercise , Input $ input )
42
43
{
43
44
if (!$ exercise instanceof ComposerExerciseCheck) {
44
45
throw new \InvalidArgumentException ;
45
46
}
46
47
47
- if (!file_exists (sprintf ('%s/composer.json ' , dirname ($ fileName )))) {
48
+ if (!file_exists (sprintf ('%s/composer.json ' , dirname ($ input -> getArgument ( ' program ' ) )))) {
48
49
return new Failure ($ this ->getName (), 'No composer.json file found ' );
49
50
}
50
51
51
- if (!file_exists (sprintf ('%s/composer.lock ' , dirname ($ fileName )))) {
52
+ if (!file_exists (sprintf ('%s/composer.lock ' , dirname ($ input -> getArgument ( ' program ' ) )))) {
52
53
return new Failure ($ this ->getName (), 'No composer.lock file found ' );
53
54
}
54
55
55
- $ lockFile = new LockFileParser (sprintf ('%s/composer.lock ' , dirname ($ fileName )));
56
+ $ lockFile = new LockFileParser (sprintf ('%s/composer.lock ' , dirname ($ input -> getArgument ( ' program ' ) )));
56
57
$ missingPackages = array_filter ($ exercise ->getRequiredPackages (), function ($ package ) use ($ lockFile ) {
57
58
return !$ lockFile ->hasInstalledPackage ($ package );
58
59
});
@@ -78,7 +79,7 @@ public function check(ExerciseInterface $exercise, $fileName)
78
79
*/
79
80
public function canRun (ExerciseType $ exerciseType )
80
81
{
81
- return true ;
82
+ return in_array ( $ exerciseType -> getValue (), [ExerciseType:: CGI , ExerciseType:: CLI ]) ;
82
83
}
83
84
84
85
/**
0 commit comments