Passed
Push — master ( 8ff2ce...afa880 )
by smiley
01:20
created
src/LTEXReader.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 namespace codemasher\WildstarDB;
16 16
 
17
-class LTEXReader extends ReaderAbstract{
17
+class LTEXReader extends ReaderAbstract {
18 18
 
19 19
 	protected $FORMAT_HEADER = 'a4Signature/LVersion/LLanguage/LLCID/QTagNameStringLength/QTagNameStringPtr/QShortNameStringLength/QShortNameStringPtr/QLongNameStringLength/QLongNameStringPtr/QEntryCount/QEntryIndexPtr/QNameStoreLength/QNameStorePtr';
20 20
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	protected function init():void{
26 26
 
27
-		if($this->header['Signature'] !== "\x58\x45\x54\x4c"){ // XETL
27
+		if ($this->header['Signature'] !== "\x58\x45\x54\x4c") { // XETL
28 28
 			throw new WSDBException('invalid LTEX');
29 29
 		}
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 		$this->name = $this->decodeString(fread($this->fh, $this->header['LongNameStringLength'] * 2));
34 34
 		$this->cols = [
35
-			['name' => 'ID',            'header' => ['DataType' =>   3]],
35
+			['name' => 'ID', 'header' => ['DataType' =>   3]],
36 36
 			['name' => 'LocalizedText', 'header' => ['DataType' => 130]],
37 37
 		];
38 38
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 		fseek($this->fh, 0x60 + $this->header['EntryIndexPtr']);
52 52
 
53
-		for($i = 0; $i < $this->header['EntryCount']; $i++){
53
+		for ($i = 0; $i < $this->header['EntryCount']; $i++) {
54 54
 			$id  = uint32(fread($this->fh, 4));
55 55
 			$pos = uint32(fread($this->fh, 4));
56 56
 			$p   = ftell($this->fh);
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 
59 59
 			fseek($this->fh, 0x60 + $this->header['NameStorePtr'] + ($pos * 2));
60 60
 
61
-			do{
61
+			do {
62 62
 				$s = fread($this->fh, 2);
63 63
 				$v .= $s;
64 64
 			}
65
-			while($s !== "\x00\x00" && $s !== '');
65
+			while ($s !== "\x00\x00" && $s !== '');
66 66
 
67 67
 			$this->data[$i] = ['ID' => $id, 'LocalizedText' => $this->decodeString($v)];
68 68
 			fseek($this->fh, $p);
Please login to merge, or discard this patch.
src/DTBLReader.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 namespace codemasher\WildstarDB;
17 17
 
18
-class DTBLReader extends ReaderAbstract{
18
+class DTBLReader extends ReaderAbstract {
19 19
 
20 20
 	protected $FORMAT_HEADER = 'a4Signature/LVersion/QTableNameLength/QUnknown1/QRecordSize/QFieldCount/QDescriptionOffset/QRecordCount/QFullRecordSize/QEntryOffset/QNextId/QIDLookupOffset/QUnknown2';
21 21
 	protected $FORMAT_COLUMN = 'LNameLength/LUnknown1/QNameOffset/SDataType/SUnknown2/LUnknown3';
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	protected function init():void{
28 28
 
29
-		if($this->header['Signature'] !== "\x4c\x42\x54\x44"){ // LBTD
29
+		if ($this->header['Signature'] !== "\x4c\x42\x54\x44") { // LBTD
30 30
 			throw new WSDBException('invalid DTBL');
31 31
 		}
32 32
 
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
 
37 37
 		fseek($this->fh, $this->header['DescriptionOffset'] + 0x60);
38 38
 
39
-		for($i = 0; $i < $this->header['FieldCount']; $i++){
39
+		for ($i = 0; $i < $this->header['FieldCount']; $i++) {
40 40
 			$this->cols[$i]['header'] = unpack($this->FORMAT_COLUMN, fread($this->fh, 0x18));
41 41
 		}
42 42
 
43 43
 		$offset = $this->header['FieldCount'] * 0x18 + $this->header['DescriptionOffset'] + 0x60;
44 44
 
45
-		if($this->header['FieldCount'] % 2){
45
+		if ($this->header['FieldCount'] % 2) {
46 46
 			$offset += 8;
47 47
 		}
48 48
 
49
-		foreach($this->cols as $i => $col){
49
+		foreach ($this->cols as $i => $col) {
50 50
 			fseek($this->fh, $offset + $col['header']['NameOffset']);
51 51
 
52 52
 			$this->cols[$i]['name'] = $this->decodeString(fread($this->fh, $col['header']['NameLength'] * 2));
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 
67 67
 		fseek($this->fh, $this->header['EntryOffset'] + 0x60);
68 68
 
69
-		for($i = 0; $i < $this->header['RecordCount']; $i++){
69
+		for ($i = 0; $i < $this->header['RecordCount']; $i++) {
70 70
 			$data = fread($this->fh, $this->header['RecordSize']);
71 71
 			$row  = [];
72 72
 			$j    = 0;
73 73
 			$skip = false;
74 74
 
75
-			foreach($this->cols as $c => $col){
75
+			foreach ($this->cols as $c => $col) {
76 76
 
77
-				if($skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130){
77
+				if ($skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130) {
78 78
 					$j += 4;
79 79
 				}
80 80
 
81
-				switch($col['header']['DataType']){
81
+				switch ($col['header']['DataType']) {
82 82
 					case 3:  // uint32
83 83
 					case 11: // booleans (stored as uint32 0/1)
84 84
 						$v = uint32(substr($data, $j, 4)); $j += 4; break;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 				$row[$col['name']] = $v;
96 96
 			}
97 97
 
98
-			if(count($row) !== $this->header['FieldCount']){
98
+			if (count($row) !== $this->header['FieldCount']) {
99 99
 				throw new WSDBException('invalid field count');
100 100
 			}
101 101
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 		fclose($this->fh);
106 106
 
107
-		if(count($this->data) !== $this->header['RecordCount']){
107
+		if (count($this->data) !== $this->header['RecordCount']) {
108 108
 			throw new WSDBException('invalid row count');
109 109
 		}
110 110
 
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$v = '';
129 129
 
130
-		do{
130
+		do {
131 131
 			$s = fread($this->fh, 2);
132 132
 			$v .= $s;
133 133
 		}
134
-		while($s !== "\x00\x00" && $s !== '');
134
+		while ($s !== "\x00\x00" && $s !== '');
135 135
 
136 136
 		fseek($this->fh, $p);
137 137
 
Please login to merge, or discard this patch.
src/includes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,6 +9,6 @@
 block discarded – undo
9 9
 
10 10
 namespace codemasher\WildstarDB;
11 11
 
12
-if(!defined('WSDB_FUNCTIONS')){
12
+if (!defined('WSDB_FUNCTIONS')) {
13 13
 	require_once __DIR__.'/functions.php';
14 14
 }
Please login to merge, or discard this patch.
src/functions.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
 // http://php.net/manual/en/function.pack.php#119402
15 15
 
16
-function uint32($i, bool $endianness = null){
16
+function uint32($i, bool $endianness = null) {
17 17
 
18
-	if($endianness === true){ // big-endian
18
+	if ($endianness === true) { // big-endian
19 19
 		$f = 'N';
20 20
 	}
21
-	elseif($endianness === false){ // little-endian
21
+	elseif ($endianness === false) { // little-endian
22 22
 		$f = 'V';
23 23
 	}
24
-	else{ // machine byte order
24
+	else { // machine byte order
25 25
 		$f = 'L';
26 26
 	}
27 27
 
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 	return is_array($i) ? $i[1] : $i;
31 31
 }
32 32
 
33
-function uint64($i, bool $endianness = null){
33
+function uint64($i, bool $endianness = null) {
34 34
 
35
-	if($endianness === true){ // big-endian
35
+	if ($endianness === true) { // big-endian
36 36
 		$f = 'J';
37 37
 	}
38
-	elseif($endianness === false){ // little-endian
38
+	elseif ($endianness === false) { // little-endian
39 39
 		$f = 'P';
40 40
 	}
41
-	else{ // machine byte order
41
+	else { // machine byte order
42 42
 		$f = 'Q';
43 43
 	}
44 44
 
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	return is_array($i) ? $i[1] : $i;
48 48
 }
49 49
 
50
-function float($i, bool $endianness = null){
50
+function float($i, bool $endianness = null) {
51 51
 
52
-	if($endianness === true){ // big-endian
52
+	if ($endianness === true) { // big-endian
53 53
 		$f = 'G';
54 54
 	}
55
-	elseif($endianness === false){ // little-endian
55
+	elseif ($endianness === false) { // little-endian
56 56
 		$f = 'g';
57 57
 	}
58
-	else{ // machine byte order
58
+	else { // machine byte order
59 59
 		$f = 'f';
60 60
 	}
61 61
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,11 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 	if($endianness === true){ // big-endian
19 19
 		$f = 'N';
20
-	}
21
-	elseif($endianness === false){ // little-endian
20
+	} elseif($endianness === false){ // little-endian
22 21
 		$f = 'V';
23
-	}
24
-	else{ // machine byte order
22
+	} else{ // machine byte order
25 23
 		$f = 'L';
26 24
 	}
27 25
 
@@ -34,11 +32,9 @@  discard block
 block discarded – undo
34 32
 
35 33
 	if($endianness === true){ // big-endian
36 34
 		$f = 'J';
37
-	}
38
-	elseif($endianness === false){ // little-endian
35
+	} elseif($endianness === false){ // little-endian
39 36
 		$f = 'P';
40
-	}
41
-	else{ // machine byte order
37
+	} else{ // machine byte order
42 38
 		$f = 'Q';
43 39
 	}
44 40
 
@@ -51,11 +47,9 @@  discard block
 block discarded – undo
51 47
 
52 48
 	if($endianness === true){ // big-endian
53 49
 		$f = 'G';
54
-	}
55
-	elseif($endianness === false){ // little-endian
50
+	} elseif($endianness === false){ // little-endian
56 51
 		$f = 'g';
57
-	}
58
-	else{ // machine byte order
52
+	} else{ // machine byte order
59 53
 		$f = 'f';
60 54
 	}
61 55
 
Please login to merge, or discard this patch.