1 | <?php |
||
22 | class JsonDumpFactory { |
||
23 | |||
24 | /** |
||
25 | * Creates a DumpReader that can read lines from a bz2 compressed JSON dump. |
||
26 | * @since 1.1.0 |
||
27 | * |
||
28 | * @param string $dumpFilePath |
||
29 | * @param int $initialPosition since 1.3.0 |
||
30 | * |
||
31 | * @return SeekableDumpReader |
||
32 | */ |
||
33 | 3 | public function newGzDumpReader( string $dumpFilePath, int $initialPosition = 0 ): SeekableDumpReader { |
|
36 | |||
37 | /** |
||
38 | * Creates a DumpReader that can read lines from an uncompressed JSON dump. |
||
39 | * @since 1.0.0 |
||
40 | * |
||
41 | * @param string $dumpFilePath |
||
42 | * @param int $initialPosition |
||
43 | * |
||
44 | * @return SeekableDumpReader |
||
45 | */ |
||
46 | 1 | public function newExtractedDumpReader( string $dumpFilePath, int $initialPosition = 0 ): SeekableDumpReader { |
|
49 | |||
50 | /** |
||
51 | * Creates a DumpReader that can read lines from a bz2 compressed JSON dump. |
||
52 | * @since 1.0.0 |
||
53 | * |
||
54 | * @param string $dumpFilePath |
||
55 | * |
||
56 | * @return DumpReader |
||
57 | */ |
||
58 | 2 | public function newBz2DumpReader( string $dumpFilePath ): DumpReader { |
|
61 | |||
62 | /** |
||
63 | * Creates an Iterator over each JSON serialized Entity in the dump. |
||
64 | * @since 1.0.0 |
||
65 | * |
||
66 | * @param DumpReader $dumpReader |
||
67 | * @param callable $onError Gets called with a single string parameter on error |
||
68 | * |
||
69 | * @return Iterator string[] |
||
70 | */ |
||
71 | 16 | public function newStringDumpIterator( DumpReader $dumpReader, callable $onError = null ): Iterator { |
|
97 | |||
98 | /** |
||
99 | * Creates an Iterator over each Entity in the dump as PHP array/object in the JSON format. |
||
100 | * This is essentially a json_decode map of the string dump iterator. |
||
101 | * @since 1.0.0 |
||
102 | * |
||
103 | * @param DumpReader $dumpReader |
||
104 | * @param callable $onError Gets called with a single string parameter on error |
||
105 | * |
||
106 | * @return Iterator array[] |
||
107 | */ |
||
108 | 14 | public function newObjectDumpIterator( DumpReader $dumpReader, callable $onError = null ): Iterator { |
|
117 | |||
118 | /** |
||
119 | * Creates an Iterator over each Entity in the dump, fully deserialized as EntityDocument. |
||
120 | * @since 1.0.0 |
||
121 | * |
||
122 | * @param DumpReader $dumpReader |
||
123 | * @param Deserializer $entityDeserializer |
||
124 | * @param callable $onError Gets called with a single string parameter on error |
||
125 | * |
||
126 | * @return Iterator EntityDocument[] |
||
127 | */ |
||
128 | 8 | public function newEntityDumpIterator( DumpReader $dumpReader, Deserializer $entityDeserializer, |
|
140 | |||
141 | } |