1 | <?php |
||
20 | class JsonFormatter implements FormatterInterface |
||
21 | { |
||
22 | const JSON_ARRAY_START = '['; |
||
23 | const JSON_ARRAY_END = ']' . PHP_EOL; |
||
24 | const JSON_ARRAY_SEPARATOR = ',' . PHP_EOL; |
||
25 | |||
26 | use RowProcessor; |
||
27 | use InvokeFormatter; |
||
28 | |||
29 | /** |
||
30 | * @var JsonFormatInterface |
||
31 | */ |
||
32 | private $format; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | private $linePostfix; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | private $encodeOptions; |
||
43 | |||
44 | /** |
||
45 | * JsonFormatter constructor. |
||
46 | * |
||
47 | * @param JsonFormatInterface $format |
||
48 | */ |
||
49 | 5 | public function __construct(JsonFormatInterface $format) |
|
61 | |||
62 | /** |
||
63 | * @param array $row |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | 4 | public function format(array $row) |
|
73 | |||
74 | /** |
||
75 | * Return an initial block if required |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 4 | public function getInitialBlock() |
|
87 | |||
88 | /** |
||
89 | * Return a closing block if required |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 4 | public function getClosingBlock() |
|
101 | |||
102 | /** |
||
103 | * Get a separator between each row |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 4 | public function getRowSeparator() |
|
111 | } |
||
112 |