/**
  * @param ExerciseInterface $exercise
  * @param $interface
  * @return static
  */
 public static function missingImplements(ExerciseInterface $exercise, $interface)
 {
     return new static(sprintf('Exercise: "%s" should implement interface: "%s"', $exercise->getName(), $interface));
 }
Example #2
0
 /**
  * @param EventDispatcher $eventDispatcher
  * @param ExerciseInterface $exercise
  */
 private function dispatchExerciseSelectedEvent(EventDispatcher $eventDispatcher, ExerciseInterface $exercise)
 {
     $eventDispatcher->dispatch(new Event(sprintf('exercise.selected.%s', AbstractExercise::normaliseName($exercise->getName()))));
 }
 /**
  * Static constructor to create an instance from the check & exercise.
  *
  * @param CheckInterface $check The check Instance.
  * @param ExerciseInterface $exercise The exercise Instance.
  * @return static
  */
 public static function fromCheckAndExercise(CheckInterface $check, ExerciseInterface $exercise)
 {
     return new static(sprintf('Check: "%s" cannot process exercise: "%s" with type: "%s"', $check->getName(), $exercise->getName(), $exercise->getType()));
 }
Example #4
0
 /**
  * @param array $failures
  * @param int $padLength
  * @param ExerciseInterface $exercise
  * @param OutputInterface $output
  */
 private function renderErrorInformation(array $failures, $padLength, ExerciseInterface $exercise, OutputInterface $output)
 {
     foreach ($failures as $result) {
         list($failure, $message) = $result;
         $output->writeLine(str_pad($this->style($message, ['red', 'bg_black', 'bold']), $padLength));
         $output->write($this->renderResult($failure));
         $output->emptyLine();
     }
     $output->writeLine($this->style(" FAIL!", ['red', 'bg_default', 'bold']));
     $output->emptyLine();
     $output->writeLine(sprintf("Your solution to %s didn't pass. Try again!", $exercise->getName()));
     $output->emptyLine();
     $output->emptyLine();
 }
 /**
  * @param array $failures
  * @param int $padLength
  * @param ExerciseInterface $exercise
  * @param OutputInterface $output
  */
 private function renderErrorInformation(array $failures, $padLength, ExerciseInterface $exercise, OutputInterface $output)
 {
     foreach ($failures as list($failure, $message)) {
         $output->writeLine($this->center($this->style(str_repeat(' ', $padLength), ['bg_red'])));
         $output->writeLine($this->center($this->style(\mb_str_pad($message, $padLength), ['bg_red'])));
         $output->writeLine($this->center($this->style(str_repeat(' ', $padLength), ['bg_red'])));
         $output->emptyLine();
         $output->write($this->renderResult($failure));
     }
     $output->lineBreak();
     $output->emptyLine();
     $output->emptyLine();
     $this->fullWidthBlock($output, 'Your solution was unsuccessful!', ['white', 'bg_red', 'bold']);
     $output->emptyLine();
     $output->writeLine($this->center(sprintf(" Your solution to %s didn't pass. Try again!", $exercise->getName())));
     $output->emptyLine();
     $output->emptyLine();
 }