1 | <?php |
||
27 | class JsonConverter implements ConverterInterface |
||
28 | { |
||
29 | use ConverterTrait; |
||
30 | |||
31 | /** |
||
32 | * Tell whether to preserve offset for json |
||
33 | * |
||
34 | * @var bool |
||
35 | */ |
||
36 | protected $preserve_record_offset = false; |
||
37 | |||
38 | /** |
||
39 | * json_encode options |
||
40 | * |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $options = 0; |
||
44 | |||
45 | /** |
||
46 | * json_encode depth |
||
47 | * |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $depth = 512; |
||
51 | |||
52 | /** |
||
53 | * Whether we should preserve the CSV document record offset. |
||
54 | * |
||
55 | * If set to true CSV document record offset will added to |
||
56 | * method output where it makes sense. |
||
57 | * |
||
58 | * @param bool $status |
||
59 | * |
||
60 | * @return static |
||
61 | */ |
||
62 | 2 | public function preserveRecordOffset(bool $status) |
|
69 | |||
70 | /** |
||
71 | * Json encode Options |
||
72 | * |
||
73 | * @param int $options |
||
74 | * @param int $depth |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | 2 | public function options(int $options = 0, int $depth = 512): self |
|
86 | |||
87 | /** |
||
88 | * Convert an Record collection into a Json string |
||
89 | * |
||
90 | * @param array|Traversable $records the CSV records collection |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | 4 | public function convert($records) |
|
110 | } |
||
111 |