public function check(ExerciseInterface $exercise, Input $input)
    {
        if (!$exercise instanceof ComposerExerciseCheck) {
            throw new \InvalidArgumentException;
        }
        
        if (!file_exists(sprintf('%s/composer.json', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No composer.json file found');
        }

        if (!file_exists(sprintf('%s/composer.lock', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No composer.lock file found');
        }

        if (!file_exists(sprintf('%s/vendor', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No vendor folder found');
        }
        
        $lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($input->getArgument('program'))));
        $missingPackages = array_filter($exercise->getRequiredPackages(), function ($package) use ($lockFile) {
            return !$lockFile->hasInstalledPackage($package);
        });
        
        if (count($missingPackages) > 0) {
            return new Failure(
                $this->getName(),
                sprintf(
                    'Lockfile doesn\'t include the following packages at any version: "%s"',
                    implode('", "', $missingPackages)
                )
            );
        }

        return new Success($this->getName());
    }
public function check(ExerciseInterface $exercise, Input $input)
    {
        if (!$exercise instanceof ComposerExerciseCheck) {
            throw new \InvalidArgumentException;
        }
        
        if (!file_exists(sprintf('%s/composer.json', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No composer.json file found');
        }

        if (!file_exists(sprintf('%s/composer.lock', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No composer.lock file found');
        }

        if (!file_exists(sprintf('%s/vendor', dirname($input->getArgument('program'))))) {
            return new Failure($this->getName(), 'No vendor folder found');
        }
        
        $lockFile = new LockFileParser(sprintf('%s/composer.lock', dirname($input->getArgument('program'))));
        $missingPackages = array_filter($exercise->getRequiredPackages(), function ($package) use ($lockFile) {
            return !$lockFile->hasInstalledPackage($package);
        });
        
        if (count($missingPackages) > 0) {
            return new Failure(
                $this->getName(),
                sprintf(
                    'Lockfile doesn\'t include the following packages at any version: "%s"',
                    implode('", "', $missingPackages)
                )
            );
        }

        return new Success($this->getName());
    }
public function check ( ExerciseInterface $ exercise , Input $ input ) { if ( ! $ exercise instanceof ComposerExerciseCheck ) { throw new \ InvalidArgumentException ; } if ( ! file_exists ( sprintf ( '%s/composer.json' , dirname ( $ input -> getArgument ( 'program' ) ) ) ) ) { return new Failure ( $ this -> getName ( ) , 'No composer.json file found' ) ; } if ( ! file_exists ( sprintf ( '%s/composer.lock' , dirname ( $ input -> getArgument ( 'program' ) ) ) ) ) { return new Failure ( $ this -> getName ( ) , 'No composer.lock file found' ) ; } if ( ! file_exists ( sprintf ( '%s/vendor' , dirname ( $ input -> getArgument ( 'program' ) ) ) ) ) { return new Failure ( $ this -> getName ( ) , 'No vendor folder found' ) ; } $ lockFile = new LockFileParser ( sprintf ( '%s/composer.lock' , dirname ( $ input -> getArgument ( 'program' ) ) ) ) ; $ missingPackages = array_filter ( $ exercise -> getRequiredPackages ( ) , function ( $ package ) use ( $ lockFile ) { return ! $ lockFile -> hasInstalledPackage ( $ package ) ; } ) ; if ( count ( $ missingPackages ) > 0 ) { return new Failure ( $ this -> getName ( ) , sprintf ( 'Lockfile doesn\'t include the following packages at any version: "%s"' , implode ( '", "' , $ missingPackages ) ) ) ; } return new Success ( $ this -> getName ( ) ) ; }
This check parses the `composer.lock` file and checks that the student
installed a set of required packages. If they did not a failure is returned, otherwise,
a success is returned.

@param ExerciseInterface $exercise The exercise to check against.
@param Input $input The command line arguments passed to the command.
@return ResultInterface The result of the check.
This check parses the composer . lock file and checks that the student installed a set of required packages . If they did not a failure is returned otherwise a success is returned .