Passed
Push — master ( 651cd8...2ef21c )
by smiley
01:27
created
src/AIDXReader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @property array $dirs
19 19
  */
20
-class AIDXReader extends PACKReaderAbstract{
20
+class AIDXReader extends PACKReaderAbstract {
21 21
 
22 22
 	/** @var array */
23 23
 	protected $dirs;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			\fread($this->fh, 16)
34 34
 		);
35 35
 
36
-		if($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41"){ // XDIA
36
+		if ($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41") { // XDIA
37 37
 			throw new WSDBException('invalid AIDX');
38 38
 		}
39 39
 
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
 		$files = \array_fill(0, $n['files'], null);
63 63
 
64 64
 		// create a directory object for each dir (4+4 = 8 bytes)
65
-		foreach($dirs as $i => $_){
65
+		foreach ($dirs as $i => $_) {
66 66
 			$dirs[$i] = new ArchiveDirectory(\unpack('LNameOffset/LBlockIndex', \fread($this->fh, 8)), $parent);
67 67
 		}
68 68
 
69 69
 		// create a file object for each file (4+4+8+8+8+20+4 = 56 bytes)
70
-		foreach($files as $i => $_){
70
+		foreach ($files as $i => $_) {
71 71
 			$files[$i] = new ArchiveFile(
72 72
 				\unpack('LNameOffset/LFlags/QFiletime/QSizeUncompressed/QSizeCompressed/a20Hash/x4', \fread($this->fh, 56)),
73 73
 				$parent
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
 		};
83 83
 
84 84
 		// apply the names to each object in the block
85
-		foreach($dirs as $i => $e){
85
+		foreach ($dirs as $i => $e) {
86 86
 			$dirs[$i]->Name = $getname($e);
87 87
 		}
88 88
 
89
-		foreach($files as $i => $e){
89
+		foreach ($files as $i => $e) {
90 90
 			$files[$i]->Name = $getname($e);
91 91
 		}
92 92
 
93 93
 		// loop through the directory stucture recursively and add the block data
94
-		foreach($dirs as $i => $info){
95
-			if(isset($this->blocktable[$info->BlockIndex])){
94
+		foreach ($dirs as $i => $info) {
95
+			if (isset($this->blocktable[$info->BlockIndex])) {
96 96
 				$dirs[$i]->Content = $this->getBlock($this->blocktable[$info->BlockIndex], $parent.$info->Name);
97 97
 			}
98 98
 		}
Please login to merge, or discard this patch.
src/AARCReader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 namespace codemasher\WildstarDB;
14 14
 
15
-class AARCReader extends PACKReaderAbstract{
15
+class AARCReader extends PACKReaderAbstract {
16 16
 
17 17
 	/**
18 18
 	 * @throws \codemasher\WildstarDB\WSDBException
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 			\fread($this->fh, 16)
26 26
 		);
27 27
 
28
-		if($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41"){ // CRAA
28
+		if ($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41") { // CRAA
29 29
 			throw new WSDBException('invalid AARC');
30 30
 		}
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		\fseek($this->fh, $blockInfo['Offset']);
36 36
 
37 37
 		// read the data block info (4+20+8 = 32 bytes)
38
-		for($i = 0; $i < $rootInfo['Blockcount']; $i++){
38
+		for ($i = 0; $i < $rootInfo['Blockcount']; $i++) {
39 39
 			$data = unpack('LIndex/a20Hash/QSizeCompressed', \fread($this->fh, 32));
40 40
 			$hash = \bin2hex($data['Hash']);
41 41
 			unset($data['Hash']);
Please login to merge, or discard this patch.
src/ReaderAbstract.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @throws \codemasher\WildstarDB\WSDBException
80 80
 	 */
81
-	public function __construct(LoggerInterface $logger = null){
81
+	public function __construct(LoggerInterface $logger = null) {
82 82
 
83
-		if(\PHP_INT_SIZE < 8){
83
+		if (\PHP_INT_SIZE < 8) {
84 84
 			throw new WSDBException('64-bit PHP required');
85 85
 		}
86 86
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	/**
91 91
 	 * @return void
92 92
 	 */
93
-	public function __destruct(){
94
-		$this->logger->info('memory usage: '.round(\memory_get_usage(true)/1048576, 3).'MB');
95
-		$this->logger->info('peak memory usage: '.round(\memory_get_peak_usage(true)/1048576, 3).'MB');
93
+	public function __destruct() {
94
+		$this->logger->info('memory usage: '.round(\memory_get_usage(true) / 1048576, 3).'MB');
95
+		$this->logger->info('peak memory usage: '.round(\memory_get_peak_usage(true) / 1048576, 3).'MB');
96 96
 
97 97
 		$this->close();
98 98
 	}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function close():ReaderInterface{
104 104
 
105
-		if(\is_resource($this->fh)){
105
+		if (\is_resource($this->fh)) {
106 106
 			\fclose($this->fh);
107 107
 
108 108
 			$this->fh = null;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return mixed|null
124 124
 	 */
125
-	public function __get(string $name){
125
+	public function __get(string $name) {
126 126
 		return \property_exists($this, $name) && $name !== 'fh' ? $this->{$name} : null;
127 127
 	}
128 128
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$this->close();
137 137
 		$filename = \realpath($filename);
138 138
 
139
-		if(!$filename || !\is_file($filename) || !\is_readable($filename)){
139
+		if (!$filename || !\is_file($filename) || !\is_readable($filename)) {
140 140
 			throw new WSDBException('input file not readable');
141 141
 		}
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 		$this->logger->info('loading: '.$this->file);
148 148
 
149
-		if(\strlen($header) !== $this->headerSize){
149
+		if (\strlen($header) !== $this->headerSize) {
150 150
 			throw new WSDBException('cannot read header');
151 151
 		}
152 152
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function checkData():void{
170 170
 
171
-		if(empty($this->data)){
171
+		if (empty($this->data)) {
172 172
 			throw new WSDBException('empty data, run ReaderInterface::read() first');
173 173
 		}
174 174
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function saveToFile(string $data, string $file):bool{
185 185
 
186
-		if(!\is_writable(\dirname($file))){
186
+		if (!\is_writable(\dirname($file))) {
187 187
 			throw new WSDBException('cannot write data to file: '.$file.', target directory is not writable');
188 188
 		}
189 189
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 		$json = \json_encode($this->data, $jsonOptions);
205 205
 
206
-		if($file !== null){
206
+		if ($file !== null) {
207 207
 			$this->saveToFile($json, $file);
208 208
 		}
209 209
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 		\fputcsv($mh, \array_column($this->cols, 'name'), $delimiter, $enclosure, $escapeChar);
227 227
 
228
-		foreach($this->data as $row){
228
+		foreach ($this->data as $row) {
229 229
 			\fputcsv($mh, \array_values($row), $delimiter, $enclosure, $escapeChar);
230 230
 		}
231 231
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 		\fclose($mh);
237 237
 
238
-		if($file !== null){
238
+		if ($file !== null) {
239 239
 			$this->saveToFile($csv, $file);
240 240
 		}
241 241
 
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 		$sxe   = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>', \LIBXML_BIGLINES);
256 256
 		$types = [3 => 'uint32', 4 => 'float', 11 => 'bool', 20 => 'uint64', 130 => 'string'];
257 257
 
258
-		foreach($this->data as $row){
258
+		foreach ($this->data as $row) {
259 259
 			$item = $sxe->addChild('item');
260 260
 
261
-			foreach(\array_values($row) as $i => $value){
261
+			foreach (\array_values($row) as $i => $value) {
262 262
 				$item
263 263
 					->addChild($this->cols[$i]['name'], $value)
264 264
 					->addAttribute('dataType', $types[$this->cols[$i]['header']['DataType']]);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 		$xml = $sxe->asXML();
270 270
 
271
-		if($file !== null){
271
+		if ($file !== null) {
272 272
 			$this->saveToFile($xml, $file);
273 273
 		}
274 274
 
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 			->ifNotExists()
289 289
 		;
290 290
 
291
-		foreach($this->cols as $i => $col){
291
+		foreach ($this->cols as $i => $col) {
292 292
 
293
-			switch($col['header']['DataType']){
293
+			switch ($col['header']['DataType']) {
294 294
 				case 3:   $createTable->int($col['name'], 10, null, null, 'UNSIGNED'); break;
295 295
 				case 4:   $createTable->decimal($col['name'], '7,3', 0); break;
296 296
 				case 11:  $createTable->field($col['name'], 'BOOLEAN'); break;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
 		$createTable->query();
306 306
 
307
-		if(\count($this->data) < 1){
307
+		if (\count($this->data) < 1) {
308 308
 			$this->logger->notice('no records available for table '.$this->name);
309 309
 			return $this;
310 310
 		}
Please login to merge, or discard this patch.