Skip to content

Commit c019c7f

Browse files
committed
Added PHPDoc annotations for properties
1 parent ffc1a92 commit c019c7f

File tree

1 file changed

+93
-1
lines changed

1 file changed

+93
-1
lines changed

Chunker.php

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,120 @@
55
/**
66
* A lightweight, fast, and optimized XML file splitter with build in tag data validation, written with the XMLParser library. The main goal of this is to split an XML file into multiple small chunks (hence the name), then save it into multiple different little XML files, so that slower servers, plugins etc can process XML files with more than even 10.000+ records. It is built on XMLParser, a powerful php xml processing library.
77
*
8+
* MINIMUM PHP VERSION: 7.4
9+
*
810
* @author Borsodi Gergő
911
* @version 1.0
12+
*
1013
*/
1114
class Chunker{
1215

16+
/**
17+
* The name of the file to be processed.
18+
* @var string
19+
*/
1320
private string $xmlFile;
21+
22+
/**
23+
* The maximum chunksize.
24+
* @var int
25+
*/
1426
private int $chunkSize;
27+
28+
/**
29+
* Counter for the chunks.
30+
* @var int
31+
*/
1532
private int $CHUNKS;
33+
34+
/**
35+
* The data that will be written into a chunk.
36+
* @var string
37+
*/
1638
private string $PAYLOAD = '';
39+
40+
/**
41+
* The data used for one iteration of the main tag.
42+
* @var string
43+
*/
1744
private string $PAYLOAD_TEMP = '';
45+
46+
/**
47+
* A container used to implement validation.
48+
* @var
49+
*/
1850
private string $DATA_BETWEEN = '';
51+
52+
/**
53+
* The root tag of the yet-to-process xml file.
54+
* @var string
55+
*/
1956
private string $rootTag;
57+
58+
/**
59+
* The charset used for the decoding/encoding process.
60+
* @var string
61+
*/
2062
private string $CHARSET;
63+
64+
/**
65+
* The prefix used for the output files.
66+
* @var string
67+
*/
2168
private string $outputFilePrefix;
69+
70+
/**
71+
* Counter for the items put into one chunk.
72+
* @var int
73+
*/
2274
private int $ITEMCOUNT = 0;
75+
76+
/**
77+
* The main tag, of which defines one item in the chunking.
78+
* @var string
79+
*/
2380
private string $CHUNKON;
81+
82+
/**
83+
* A variable used for logging.
84+
* @var string
85+
*/
2486
private string $log = "";
87+
88+
/**
89+
* The total number of processed main tags.
90+
* @var int
91+
*/
2592
private int $totalItems = 0;
93+
94+
/**
95+
* A variable that indicates if a maintag that doesn't satisfy the validation has been found.
96+
* @var bool
97+
*/
2698
private bool $excludedItemFound = false;
99+
100+
/**
101+
* A variable to indicate that the next data that will be read, has to be validated since its opening tag is present in $checkingTags.
102+
* @var bool
103+
*/
27104
private bool $checkNextData = false;
105+
106+
/**
107+
* A variable that carries the tagname of the data that is about to be validated.
108+
* @var string
109+
*/
28110
private string $checkNextDataTag = '';
111+
112+
/**
113+
* An array of tags, where their data has to be validated runtime.
114+
* @var array
115+
*/
29116
private array $checkingTags = array();
117+
118+
/**
119+
* A callback function, that processes the validation. Has to be a callable.
120+
* @var callable
121+
*/
30122
private $passesValidation;
31123

32124
/**
@@ -199,7 +291,7 @@ private function createXMLParser($CHARSET = "UTF-8", $bareXML = false) {
199291
* A funcion to start the chunking process. It will initiate the parsint instance, and start the XML parsing, along with the chunking of the data in every specified $chunkSize intervals.
200292
* @param string $mainTag The tag of which will be used to count the number of main elements in a chunk. Usually the second-level XML tag in a document.
201293
* @param string $rootTag The root tag of which every other $mainTag is the children of. There is only one of this in an XML document (not the XML header, which is in the first row).
202-
* @param string $charset The character set used by the parser. **Default: UTF-8**
294+
* @param string $charset The character set used by the parser. **Default: UTF-8** Possible values: "UTF-8", "ISO-8859-1"
203295
*
204296
* @return string The main log that was created during the chunking
205297
*/

0 commit comments

Comments
 (0)