Passed
Push — master ( bdfaf8...931c46 )
by smiley
01:33
created
src/ReaderAbstract.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @throws \codemasher\WildstarDB\WSDBException
77 77
 	 */
78
-	public function __construct(LoggerInterface $logger = null){
78
+	public function __construct(LoggerInterface $logger = null) {
79 79
 
80
-		if(\PHP_INT_SIZE < 8){
80
+		if (\PHP_INT_SIZE < 8) {
81 81
 			throw new WSDBException('64-bit PHP required');
82 82
 		}
83 83
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	/**
88 88
 	 * @return void
89 89
 	 */
90
-	public function __destruct(){
91
-		$this->logger->info('memory usage: '.(\memory_get_usage(true)/1048576).'MB');
92
-		$this->logger->info('peak memory usage: '.(\memory_get_peak_usage(true)/1048576).'MB');
90
+	public function __destruct() {
91
+		$this->logger->info('memory usage: '.(\memory_get_usage(true) / 1048576).'MB');
92
+		$this->logger->info('peak memory usage: '.(\memory_get_peak_usage(true) / 1048576).'MB');
93 93
 
94 94
 		$this->close();
95 95
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function close():ReaderInterface{
101 101
 
102
-		if(\is_resource($this->fh)){
102
+		if (\is_resource($this->fh)) {
103 103
 			\fclose($this->fh);
104 104
 
105 105
 			$this->fh = null;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return mixed|null
121 121
 	 */
122
-	public function __get(string $name){
122
+	public function __get(string $name) {
123 123
 		return \property_exists($this, $name) && $name !== 'fh' ? $this->{$name} : null;
124 124
 	}
125 125
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		$this->close();
134 134
 		$filename = \realpath($filename);
135 135
 
136
-		if(!$filename || !\is_file($filename) || !\is_readable($filename)){
136
+		if (!$filename || !\is_file($filename) || !\is_readable($filename)) {
137 137
 			throw new WSDBException('input file not readable');
138 138
 		}
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 		$this->logger->info('loading: '.$this->file);
145 145
 
146
-		if(\strlen($header) !== $this->headerSize){
146
+		if (\strlen($header) !== $this->headerSize) {
147 147
 			throw new WSDBException('cannot read header');
148 148
 		}
149 149
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	protected function checkData():void{
167 167
 
168
-		if(empty($this->data)){
168
+		if (empty($this->data)) {
169 169
 			throw new WSDBException('empty data, run ReaderInterface::read() first');
170 170
 		}
171 171
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	protected function saveToFile(string $data, string $file):bool{
182 182
 
183
-		if(!\is_writable(\dirname($file))){
183
+		if (!\is_writable(\dirname($file))) {
184 184
 			throw new WSDBException('cannot write data to file: '.$file.', target directory is not writable');
185 185
 		}
186 186
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 
201 201
 		$json = \json_encode($this->data, $jsonOptions);
202 202
 
203
-		if($file !== null){
203
+		if ($file !== null) {
204 204
 			$this->saveToFile($json, $file);
205 205
 		}
206 206
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
 		\fputcsv($mh, \array_column($this->cols, 'name'), $delimiter, $enclosure, $escapeChar);
224 224
 
225
-		foreach($this->data as $row){
225
+		foreach ($this->data as $row) {
226 226
 			\fputcsv($mh, \array_values($row), $delimiter, $enclosure, $escapeChar);
227 227
 		}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 		\fclose($mh);
234 234
 
235
-		if($file !== null){
235
+		if ($file !== null) {
236 236
 			$this->saveToFile($csv, $file);
237 237
 		}
238 238
 
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 		$sxe   = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>', \LIBXML_BIGLINES);
253 253
 		$types = [3 => 'uint32', 4 => 'float', 11 => 'bool', 20 => 'uint64', 130 => 'string'];
254 254
 
255
-		foreach($this->data as $row){
255
+		foreach ($this->data as $row) {
256 256
 			$item = $sxe->addChild('item');
257 257
 
258
-			foreach(\array_values($row) as $i => $value){
258
+			foreach (\array_values($row) as $i => $value) {
259 259
 				$item
260 260
 					->addChild($this->cols[$i]['name'], $value)
261 261
 					->addAttribute('dataType', $types[$this->cols[$i]['header']['DataType']]);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$xml = $sxe->asXML();
267 267
 
268
-		if($file !== null){
268
+		if ($file !== null) {
269 269
 			$this->saveToFile($xml, $file);
270 270
 		}
271 271
 
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 			->ifNotExists()
286 286
 		;
287 287
 
288
-		foreach($this->cols as $i => $col){
288
+		foreach ($this->cols as $i => $col) {
289 289
 
290
-			switch($col['header']['DataType']){
290
+			switch ($col['header']['DataType']) {
291 291
 				case 3:   $createTable->int($col['name'], 10, null, null, 'UNSIGNED'); break;
292 292
 				case 4:   $createTable->decimal($col['name'], '7,3', 0); break;
293 293
 				case 11:  $createTable->field($col['name'], 'BOOLEAN'); break;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 		$createTable->query();
303 303
 
304
-		if(\count($this->data) < 1){
304
+		if (\count($this->data) < 1) {
305 305
 			$this->logger->notice('no records available for table '.$this->name);
306 306
 			return $this;
307 307
 		}
Please login to merge, or discard this patch.
src/LTEXReader.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @property string $prettyname
19 19
  */
20
-class LTEXReader extends ReaderAbstract{
20
+class LTEXReader extends ReaderAbstract {
21 21
 
22 22
 	// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c
23 23
 	protected const LCID = [
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	public function read(string $filename):ReaderInterface{
44 44
 		$this->loadFile($filename);
45 45
 
46
-		if($this->header['Signature'] !== "\x58\x45\x54\x4c"){ // XETL
46
+		if ($this->header['Signature'] !== "\x58\x45\x54\x4c") { // XETL
47 47
 			throw new WSDBException('invalid LTEX');
48 48
 		}
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$this->prettyname = $this->decodeString(\fread($this->fh, $this->header['LongNameStringLength'] * 2));
53 53
 		$this->name       = 'LocalizedText_'.$this::LCID[$this->header['LCID']];
54 54
 		$this->cols       = [
55
-			['name' => 'ID',            'header' => ['DataType' =>   3]],
55
+			['name' => 'ID', 'header' => ['DataType' =>   3]],
56 56
 			['name' => 'LocalizedText', 'header' => ['DataType' => 130]],
57 57
 		];
58 58
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 		$this->data = array_fill(0, $this->header['EntryCount'], null);
73 73
 
74
-		foreach($this->data as $i => $_){
74
+		foreach ($this->data as $i => $_) {
75 75
 			// get the id and offset for the data block
76 76
 			$c = \unpack('Lid/Loffset', \fread($this->fh, 8));
77 77
 			// save the current position
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
 			$v = '';
84 84
 			// read until we hit a double nul or the void
85
-			do{
85
+			do {
86 86
 				$s = \fread($this->fh, 2);
87 87
 				$v .= $s;
88 88
 			}
89
-			while($s !== "\x00\x00" && $s !== '');
89
+			while ($s !== "\x00\x00" && $s !== '');
90 90
 
91 91
 			$this->data[$i] = ['ID' => $c['id'], 'LocalizedText' => $this->decodeString($v)];
92 92
 
Please login to merge, or discard this patch.
src/ArchiveFile.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 ArchiveFile extends ArchiveItemAbstract{
15
+class ArchiveFile extends ArchiveItemAbstract {
16 16
 
17 17
 	public $Flags;
18 18
 	public $Filetime;
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	public $SizeCompressed;
22 22
 	public $Hash;
23 23
 
24
-	public function __construct(array $data, string $parent){
24
+	public function __construct(array $data, string $parent) {
25 25
 		parent::__construct($data, $parent);
26 26
 
27 27
 		$this->Hash      = \bin2hex($this->Hash);
28
-		$this->FileUtime = (int)($this->Filetime/100000000);
28
+		$this->FileUtime = (int)($this->Filetime / 100000000);
29 29
 #		$dt = (new \DateTime)->createFromFormat('U.u', $this->FileUtime) ?: (new \DateTime)->createFromFormat('U', $this->FileUtime);
30 30
 #		$this->FileTimeStr = $dt->format(\DateTimeInterface::RFC3339_EXTENDED);
31 31
 	}
Please login to merge, or discard this patch.