| 
4 | 4 | 
 
  | 
5 | 5 | use Colors\Color;  | 
6 | 6 | use PhpSchool\CliMenu\Terminal\TerminalInterface;  | 
 | 7 | +use PhpSchool\PhpWorkshop\Exercise\ProvidesSolution;  | 
7 | 8 | use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory;  | 
8 | 9 | use PhpSchool\PhpWorkshop\Output\OutputInterface;  | 
9 | 10 | use PhpSchool\PhpWorkshop\Result\SuccessInterface;  | 
@@ -153,23 +154,25 @@ private function renderSuccessInformation(  | 
153 | 154 |         $output->writeLine($this->style(" PASS!", ['green', 'bg_default', 'bold']));  | 
154 | 155 |         $output->emptyLine();  | 
155 | 156 | 
 
  | 
156 |  | -        $output->writeLine("Here's the official solution in case you want to compare notes:");  | 
157 |  | -        $output->writeLine($this->lineBreak());  | 
 | 157 | +        if ($exercise instanceof ProvidesSolution) {  | 
 | 158 | +            $output->writeLine("Here's the official solution in case you want to compare notes:");  | 
 | 159 | +            $output->writeLine($this->lineBreak());  | 
158 | 160 | 
 
  | 
159 |  | -        foreach ($exercise->getSolution()->getFiles() as $file) {  | 
160 |  | -            $output->writeLine($this->style($file->getRelativePath(), ['bold', 'cyan', 'underline']));  | 
161 |  | -            $output->emptyLine();  | 
 | 161 | +            foreach ($exercise->getSolution()->getFiles() as $file) {  | 
 | 162 | +                $output->writeLine($this->style($file->getRelativePath(), ['bold', 'cyan', 'underline']));  | 
 | 163 | +                $output->emptyLine();  | 
162 | 164 | 
 
  | 
163 |  | -            $code = $file->getContents();  | 
164 |  | -            if (pathinfo($file->getRelativePath(), PATHINFO_EXTENSION) === 'php') {  | 
165 |  | -                $code = $this->syntaxHighlighter->highlight($code);  | 
166 |  | -            }  | 
 | 165 | +                $code = $file->getContents();  | 
 | 166 | +                if (pathinfo($file->getRelativePath(), PATHINFO_EXTENSION) === 'php') {  | 
 | 167 | +                    $code = $this->syntaxHighlighter->highlight($code);  | 
 | 168 | +                }  | 
167 | 169 | 
 
  | 
168 |  | -            //make sure there is a new line at the end  | 
169 |  | -            $code = preg_replace('/\n$/', '', $code) . "\n";  | 
 | 170 | +                //make sure there is a new line at the end  | 
 | 171 | +                $code = preg_replace('/\n$/', '', $code) . "\n";  | 
170 | 172 | 
 
  | 
171 |  | -            $output->write($code);  | 
172 |  | -            $output->writeLine($this->lineBreak());  | 
 | 173 | +                $output->write($code);  | 
 | 174 | +                $output->writeLine($this->lineBreak());  | 
 | 175 | +            }  | 
173 | 176 |         }  | 
174 | 177 | 
 
  | 
175 | 178 |         $completedCount = count($userState->getCompletedExercises());  | 
 | 
0 commit comments