1 | <?php |
||
9 | class FormatterManager |
||
10 | { |
||
11 | protected $formatters = []; |
||
12 | |||
13 | public function __construct() |
||
25 | |||
26 | /** |
||
27 | * Format and write output |
||
28 | * |
||
29 | * @param OutputInterface $output Output stream to write to |
||
30 | * @param string $format Data format to output in |
||
31 | * @param mixed $structuredOutput Data to output |
||
32 | * @param array $annotationData Configuration information for formatter |
||
33 | * @param array $options User options |
||
34 | */ |
||
35 | public function write(OutputInterface $output, $format, $structuredOutput, $annotationData = [], $options = []) |
||
47 | |||
48 | /** |
||
49 | * Fetch the requested formatter. |
||
50 | * |
||
51 | * @param string $format Identifier for requested formatter |
||
52 | * @param array $configurationData Configuration data for formatter |
||
53 | * @return FormatterInterface |
||
54 | */ |
||
55 | public function getFormatter($format, $configurationData = []) |
||
65 | |||
66 | /** |
||
67 | * Determine if the provided data is compatible with the formatter being used. |
||
68 | * |
||
69 | * @param FormatterInterface $formatter Formatter being used |
||
70 | * @param mixed $structuredOutput Data to validate |
||
71 | * @return mixed |
||
72 | */ |
||
73 | public function validateData(FormatterInterface $formatter, $structuredOutput) |
||
89 | |||
90 | /** |
||
91 | * Restructure the data as necessary (e.g. to select or reorder fields). |
||
92 | * |
||
93 | * @param mixed $structuredOutput |
||
94 | * @param array $configurationData |
||
95 | * @param array $options |
||
96 | * @return mixed |
||
97 | */ |
||
98 | public function restructureData($structuredOutput, $configurationData, $options) |
||
105 | } |
||
106 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: