Formatters

Formatters are used to make a generated solution visible to the user.

interface Formatter
Fully qualified name
\EliasHaeussler\Typo3Solver\Formatter\Formatter

Interface for formatters that convert a given problem and its solution into a readable format.

format ( $problem, $solution)

Format given problem and solution to string.

param EliasHaeussler\Typo3Solver\ProblemSolving\Problem\Problem $problem

The problem to be formatted

param EliasHaeussler\Typo3Solver\ProblemSolving\Solution\Solution $solution

The solution to be formatted

returntype

string

Default formatters

Since exceptions are handled in various places, the extension already ships with some default formatters:

class CliFormatter
Fully qualified name
\EliasHaeussler\Typo3Solver\Formatter\CliFormatter

Formatter used on the command line. It displays all provided solutions. On verbose output, the original prompt is also displayed. In addition, if a solution comes from the solutions cache, the original date and cache identifier are displayed as well.

class JsonFormatter
Fully qualified name
\EliasHaeussler\Typo3Solver\Formatter\JsonFormatter

This formatter is used within the solver:solve command if the solver:solve option is given. It displays the solution as JSON string, allowing further processing, especially in CI.

class WebFormatter
Fully qualified name
\EliasHaeussler\Typo3Solver\Formatter\WebFormatter

This formatter is used for the modified debug exception handler. It adds an additional section to the error page which displays all solutions. In addition, the used model, generated prompt and cache metadata are shown.

class WebStreamFormatter
Fully qualified name
\EliasHaeussler\Typo3Solver\Formatter\WebStreamFormatter

On solution streaming, this formatter is used to only print the list of solutions, streaming it to the error page where it replaces the current solution list.