/**
  * Print a list of the missing, required functions & print a list of used but banned functions.
  *
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     $output = '';
     if (count($bannedFunctions = $this->result->getBannedFunctions())) {
         $output .= sprintf("  %s\n%s\n", $renderer->style("Some functions were used which should not be used in this exercise", ['bold', 'underline', 'yellow']), implode("\n", array_map(function (array $call) {
             return sprintf('    %s on line %s', $call['function'], $call['line']);
         }, $bannedFunctions)));
     }
     if (count($missingFunctions = $this->result->getMissingFunctions())) {
         $output .= sprintf("  %s\n%s\n", $renderer->style("Some function requirements were missing. You should use the functions", ['bold', 'underline', 'yellow']), implode("\n", array_map(function ($function) {
             return sprintf('    %s', $function);
         }, $missingFunctions)));
     }
     return $output;
 }
 /**
  * Render the details of each failed request including the mismatching headers and body.
  *
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
         return $result instanceof FailureInterface;
     });
     $output = '';
     if (count($results)) {
         $output .= $renderer->center("Some requests to your solution produced incorrect output!\n");
     }
     foreach ($results as $key => $request) {
         $output .= $renderer->lineBreak();
         $output .= "\n";
         $output .= $renderer->style(sprintf('Request %d', $key + 1), ['bold', 'underline', 'blue']);
         $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";
         $output .= "Request Details:\n\n";
         $output .= $this->requestRenderer->renderRequest($request->getRequest()) . "\n";
         $output .= $renderer->renderResult($request) . "\n";
     }
     return $output;
 }
 /**
  * Render the details of each failed request including the mismatching headers and body.
  *
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
         return $result instanceof FailureInterface;
     });
     $output = '';
     if (count($results)) {
         $output .= $renderer->center("Some executions of your solution produced incorrect output!\n");
     }
     /** @var FailureInterface $request **/
     foreach ($results as $key => $request) {
         $output .= $renderer->lineBreak();
         $output .= "\n";
         $output .= $renderer->style(sprintf('Execution %d', $key + 1), ['bold', 'underline', 'blue']);
         $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";
         $output .= $request->getArgs()->isEmpty() ? "Arguments: None\n" : sprintf("Arguments: \"%s\"\n", $request->getArgs()->implode('", "'));
         $output .= "\n" . $renderer->renderResult($request) . "\n";
     }
     return $output;
 }
 /**
  * @param array $headers
  * @param ResultsRenderer $renderer
  * @param bool $actual
  * @return string
  */
 private function headers(array $headers, ResultsRenderer $renderer, $actual = true)
 {
     $indent = false;
     $output = '';
     foreach ($headers as $name => $value) {
         if ($indent) {
             $output .= str_repeat(' ', 21);
         }
         $output .= $renderer->style(sprintf("%s: %s", $name, $value), $actual ? 'red' : 'default') . "\n";
         $indent = true;
     }
     return $output;
 }
 /**
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     return sprintf("  %s\n%s\n\n  %s\n%s\n", $renderer->style("ACTUAL", ['bold', 'underline', 'yellow']), $this->indent($renderer->style(sprintf('"%s"', $this->result->getActualOutput()), 'red')), $renderer->style("EXPECTED", ['yellow', 'bold', 'underline']), $this->indent($renderer->style(sprintf('"%s"', $this->result->getExpectedOutput()), 'red')));
 }
 /**
  * Print the actual and expected output.
  *
  * @param ResultsRenderer $renderer
  * @return string
  */
 public function render(ResultsRenderer $renderer)
 {
     return sprintf("  %s\n%s\n\n  %s\n%s\n", $renderer->style('YOUR OUTPUT:', ['bold', 'yellow']), $this->indent($renderer->style(sprintf('"%s"', $this->result->getActualValue()), 'red')), $renderer->style('EXPECTED OUTPUT:', ['bold', 'yellow']), $this->indent($renderer->style(sprintf('"%s"', $this->result->getExpectedValue()), 'green')));
 }