1 | <?php |
||
23 | class ResponseFormatter |
||
24 | { |
||
25 | /** |
||
26 | * @var FormatterInterface[] |
||
27 | */ |
||
28 | protected $formatterClasses = []; |
||
29 | |||
30 | /** |
||
31 | * @var ContainerInterface |
||
32 | */ |
||
33 | protected $dependencyContainer; |
||
34 | |||
35 | /** |
||
36 | * ResponseFormatter constructor. |
||
37 | * |
||
38 | * @param string[] $formatters List of class names or DIC instance names |
||
39 | * @param ContainerInterface $dependencyContainer |
||
40 | */ |
||
41 | 6 | public function __construct($formatters, $dependencyContainer) |
|
56 | |||
57 | /** |
||
58 | * @return FormatterInterface[] |
||
59 | */ |
||
60 | 1 | public function getFormatters() |
|
64 | |||
65 | /** |
||
66 | * @param mixed $data Result returned by the controller. |
||
67 | * |
||
68 | * @return FormatterInterface |
||
69 | */ |
||
70 | 4 | public function getFormatter($data) |
|
80 | |||
81 | /** |
||
82 | * Attempts to run a registered formatter on the given data. |
||
83 | * |
||
84 | * @param mixed $data |
||
85 | */ |
||
86 | 2 | public function format($data) |
|
96 | } |
||
97 |