Exemplo n.º 1
0
 /**
  * @param CliMenu $menu
  */
 public function __invoke(CliMenu $menu)
 {
     $menu->close();
     $item = $menu->getSelectedItem();
     $exercise = $this->exerciseRepository->findByName($item->getText());
     $exercises = $this->exerciseRepository->findAll();
     $this->userState->setCurrentExercise($item->getText());
     $this->userStateSerializer->serialize($this->userState);
     $numExercises = count($exercises);
     $exerciseIndex = array_search($exercise, $exercises) + 1;
     $output = "\n";
     $output .= $this->color->__invoke(' LEARN YOU THE PHP FOR MUCH WIN! ')->magenta()->bold() . "\n";
     $output .= $this->color->__invoke('*********************************')->magenta()->bold() . "\n";
     $output .= "\n";
     $output .= $this->color->__invoke(" " . $exercise->getName())->yellow()->bold() . "\n";
     $output .= $this->color->__invoke(sprintf(" Exercise %d of %d\n\n", $exerciseIndex, $numExercises))->yellow();
     $content = file_get_contents($exercise->getProblem());
     $doc = $this->markdownRenderer->render($content);
     $doc = str_replace('{appname}', $this->appName, $doc);
     $output .= $doc;
     $output .= "\n";
     $output .= $this->helpLine('To print these instructions again, run', 'print');
     $output .= $this->helpLine('To execute your program in a test environment, run', 'run program.php');
     $output .= $this->helpLine('To verify your program, run', 'verify program.php');
     $output .= $this->helpLine('For help run', 'help');
     $output .= "\n\n";
     $this->output->write($output);
 }
Exemplo n.º 2
0
 /**
  * @return int|void
  */
 public function __invoke()
 {
     $currentExercise = $this->userState->getCurrentExercise();
     $exercise = $this->exerciseRepository->findByName($currentExercise);
     $markDown = file_get_contents($exercise->getProblem());
     $doc = $this->markdownRenderer->render($markDown);
     $doc = str_replace('{appname}', $this->appName, $doc);
     $this->output->write($doc);
 }
Exemplo n.º 3
0
 public function testRender()
 {
     $docParser = new DocParser(Environment::createCommonMarkEnvironment());
     $cliRenderer = (new CliRendererFactory())->__invoke();
     $renderer = new MarkdownRenderer($docParser, $cliRenderer);
     $markdown = "### HONEY BADGER DON'T CARE";
     $expected = "\n### HONEY BADGER DON'T CARE\n\n";
     $this->assertSame($expected, $renderer->render($markdown));
 }
 /**
  * @return int|void
  */
 public function __invoke()
 {
     if (!$this->userState->isAssignedExercise()) {
         $this->output->printError("No active exercises. Select one from the menu");
         return 1;
     }
     $currentExercise = $this->userState->getCurrentExercise();
     $exercise = $this->exerciseRepository->findByName($currentExercise);
     $markDown = file_get_contents($exercise->getProblem());
     $doc = $this->markdownRenderer->render($markDown);
     $doc = str_replace('{appname}', $this->appName, $doc);
     $this->output->write($doc);
 }