Passed
Branch master (ea2931)
by smiley
02:35
created
src/Archive/ItemAbstract.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\Archive;
14 14
 
15
-abstract class ItemAbstract{
15
+abstract class ItemAbstract {
16 16
 
17 17
 	/** @var string */
18 18
 	public $Parent;
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * @param array  $data
28 28
 	 * @param string $parent
29 29
 	 */
30
-	public function __construct(array $data, string $parent){
30
+	public function __construct(array $data, string $parent) {
31 31
 
32
-		foreach($data as $property => $value){
32
+		foreach ($data as $property => $value) {
33 33
 			$this->{$property} = $value;
34 34
 		}
35 35
 
Please login to merge, or discard this patch.
src/Archive/DTBLReader.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * @internal
28 28
 	 */
29 29
 	protected $FORMAT_HEADER = 'a4Signature/LVersion/QTableNameLength/x8/QRecordSize/QFieldCount/QDescriptionOffset'.
30
-	                           '/QRecordCount/QFullRecordSize/QEntryOffset/QNextId/QIDLookupOffset/x8';
30
+							   '/QRecordCount/QFullRecordSize/QEntryOffset/QNextId/QIDLookupOffset/x8';
31 31
 
32 32
 	/**
33 33
 	 * @var bool
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 use function array_fill, count, fread, fseek, ftell, round, substr, unpack;
21 21
 use function codemasher\WildstarDB\{float, uint32, uint64};
22 22
 
23
-final class DTBLReader extends ReaderAbstract{
23
+final class DTBLReader extends ReaderAbstract {
24 24
 
25 25
 	/**
26 26
 	 * @var string
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	public function read(string $filename):ReaderInterface{
57 57
 		$this->loadFile($filename);
58 58
 
59
-		if($this->header['Signature'] !== "\x4c\x42\x54\x44"){ // LBTD
59
+		if ($this->header['Signature'] !== "\x4c\x42\x54\x44") { // LBTD
60 60
 			throw new WSDBException('invalid DTBL');
61 61
 		}
62 62
 
63 63
 		$this->readColumnHeaders();
64 64
 		$this->readData();
65 65
 
66
-		if(count($this->data) !== $this->header['RecordCount']){
66
+		if (count($this->data) !== $this->header['RecordCount']) {
67 67
 			throw new WSDBException('invalid row count');
68 68
 		}
69 69
 
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
 		fseek($this->fh, $this->header['DescriptionOffset'] + $this->headerSize);
83 83
 
84 84
 		// read the column headers (4+4+8+2+2+4 = 24 bytes)
85
-		for($i = 0; $i < $this->header['FieldCount']; $i++){
85
+		for ($i = 0; $i < $this->header['FieldCount']; $i++) {
86 86
 			$this->cols[$i]['header'] = unpack('LNameLength/x4/QNameOffset/SDataType/x2/x4', fread($this->fh, 24));
87 87
 		}
88 88
 
89 89
 		$offset = $this->header['FieldCount'] * 24 + $this->header['DescriptionOffset'] + $this->headerSize;
90 90
 
91
-		if($this->header['FieldCount'] % 2){
91
+		if ($this->header['FieldCount'] % 2) {
92 92
 			$offset += 8;
93 93
 		}
94 94
 
95 95
 		// read the column names
96
-		foreach($this->cols as $i => $col){
96
+		foreach ($this->cols as $i => $col) {
97 97
 			fseek($this->fh, $offset + $col['header']['NameOffset']);
98 98
 
99 99
 			// column name (UTF-16LE: length *2)
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 		$this->data = array_fill(0, $this->header['RecordCount'], null);
114 114
 
115 115
 		// read a row
116
-		foreach($this->data as $i => $_){
116
+		foreach ($this->data as $i => $_) {
117 117
 			$this->rowdata = fread($this->fh, $this->header['RecordSize']);
118 118
 			$this->pos     = 0;
119 119
 			$this->skip    = false;
120 120
 
121 121
 			// loop through the columns
122
-			foreach($this->cols as $c => $col){
122
+			foreach ($this->cols as $c => $col) {
123 123
 
124 124
 				// skip 4 bytes if the string offset is 0 (determined by $skip), the current type is string and the next isn't
125
-				if($this->skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130){
125
+				if ($this->skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130) {
126 126
 					$this->pos += 4;
127 127
 				}
128 128
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			}
131 131
 
132 132
 			// if we run into this, a horrible thing happened
133
-			if(count($this->data[$i]) !== $this->header['FieldCount']){
133
+			if (count($this->data[$i]) !== $this->header['FieldCount']) {
134 134
 				throw new WSDBException('invalid field count');
135 135
 			}
136 136
 
@@ -143,24 +143,24 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return int|float|string|null
145 145
 	 */
146
-	private function getValue(int $datatype){
146
+	private function getValue(int $datatype) {
147 147
 
148
-		switch($datatype){
148
+		switch ($datatype) {
149 149
 			case 3:  // uint32
150 150
 			case 11: // booleans (stored as uint32 0/1)
151
-				$v         = uint32(substr($this->rowdata, $this->pos, 4));
151
+				$v = uint32(substr($this->rowdata, $this->pos, 4));
152 152
 				$this->pos += 4;
153 153
 				break;
154 154
 			case 4:  // float
155
-				$v         = round(float(substr($this->rowdata, $this->pos, 4)), 3); // @todo: determine round precision
155
+				$v = round(float(substr($this->rowdata, $this->pos, 4)), 3); // @todo: determine round precision
156 156
 				$this->pos += 4;
157 157
 				break;
158 158
 			case 20: // uint64
159
-				$v         = uint64(substr($this->rowdata, $this->pos, 8));
159
+				$v = uint64(substr($this->rowdata, $this->pos, 8));
160 160
 				$this->pos += 8;
161 161
 				break;
162 162
 			case 130: // string (UTF-16LE)
163
-				$v         = $this->readString();
163
+				$v = $this->readString();
164 164
 				$this->pos += 8;
165 165
 				break;
166 166
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$v = '';
185 185
 		// loop through the string until we hit 2 nul bytes or the void
186
-		do{
186
+		do {
187 187
 			$s = fread($this->fh, 2);
188 188
 			$v .= $s;
189 189
 		}
190
-		while($s !== "\x00\x00" && $s !== '');
190
+		while ($s !== "\x00\x00" && $s !== '');
191 191
 
192 192
 		fseek($this->fh, $p);
193 193
 
Please login to merge, or discard this patch.
src/Archive/AIDXReader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * @property array $dirs
23 23
  */
24
-final class AIDXReader extends PACKReaderAbstract{
24
+final class AIDXReader extends PACKReaderAbstract {
25 25
 
26 26
 	private const AIDX_ROOT = 'a4ArchiveType/LVersion/LBuildnumber/LIndex';
27 27
 	private const AIDX_DATA = 'LNameOffset/LFlags/QFiletime/QSizeUncompressed/QSizeCompressed/a20Hash/x4';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		// get the root info block of the AIDX file (4+4+4+4 = 16 bytes)
38 38
 		$rootInfo = unpack($this::AIDX_ROOT, fread($this->fh, 16));
39 39
 
40
-		if($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41"){ // XDIA
40
+		if ($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41") { // XDIA
41 41
 			throw new WSDBException('invalid AIDX');
42 42
 		}
43 43
 
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 		$files = array_fill(0, $n['files'], null);
67 67
 
68 68
 		// create a directory object for each dir (4+4 = 8 bytes)
69
-		foreach($dirs as $i => $_){
69
+		foreach ($dirs as $i => $_) {
70 70
 			$dirs[$i] = new Directory(unpack('LNameOffset/LBlockIndex', fread($this->fh, 8)), $parent);
71 71
 		}
72 72
 
73 73
 		// create a file object for each file (4+4+8+8+8+20+4 = 56 bytes)
74
-		foreach($files as $i => $_){
74
+		foreach ($files as $i => $_) {
75 75
 			$files[$i] = new File(unpack($this::AIDX_DATA, fread($this->fh, 56)), $parent);
76 76
 		}
77 77
 
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 		};
84 84
 
85 85
 		// apply the names to each object in the block
86
-		foreach($dirs as $i => $e){
86
+		foreach ($dirs as $i => $e) {
87 87
 			$dirs[$i]->Name = $getname($e);
88 88
 		}
89 89
 
90
-		foreach($files as $i => $e){
90
+		foreach ($files as $i => $e) {
91 91
 			$files[$i]->Name = $getname($e);
92 92
 		}
93 93
 
94 94
 		// loop through the directory stucture recursively and add the block data
95
-		foreach($dirs as $i => $info){
96
-			if(isset($this->blocktable[$info->BlockIndex])){
95
+		foreach ($dirs as $i => $info) {
96
+			if (isset($this->blocktable[$info->BlockIndex])) {
97 97
 				$dirs[$i]->Content = $this->getBlock($this->blocktable[$info->BlockIndex], $parent.$info->Name);
98 98
 			}
99 99
 		}
Please login to merge, or discard this patch.
src/Archive/Directory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace codemasher\WildstarDB\Archive;
14 14
 
15
-final class Directory extends ItemAbstract{
15
+final class Directory extends ItemAbstract {
16 16
 
17 17
 	/** @var int */
18 18
 	public $BlockIndex;
Please login to merge, or discard this patch.
src/Archive/File.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use function bin2hex;
16 16
 
17
-final class File extends ItemAbstract{
17
+final class File extends ItemAbstract {
18 18
 
19 19
 	/** @var int */
20 20
 	public $Flags;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param array  $data
36 36
 	 * @param string $parent
37 37
 	 */
38
-	public function __construct(array $data, string $parent){
38
+	public function __construct(array $data, string $parent) {
39 39
 		parent::__construct($data, $parent);
40 40
 
41 41
 		$this->Hash      = bin2hex($this->Hash);
Please login to merge, or discard this patch.
src/Archive/PACKReaderAbstract.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * @property array $blocktable
22 22
  */
23
-abstract class PACKReaderAbstract extends ReaderAbstract{
23
+abstract class PACKReaderAbstract extends ReaderAbstract {
24 24
 
25 25
 	/**
26 26
 	 * 4+4+512+8+8+8+4+4+4+8 = 564 bytes
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 		$this->loadFile($filename);
58 58
 		$this->blocktable = [];
59 59
 
60
-		if($this->header['Signature'] !== "\x4b\x43\x41\x50"){ // KCAP
60
+		if ($this->header['Signature'] !== "\x4b\x43\x41\x50") { // KCAP
61 61
 			throw new WSDBException('invalid PACK');
62 62
 		}
63 63
 
64 64
 		// read the block info table
65 65
 		fseek($this->fh, $this->header['BlockTableOffset']);
66 66
 
67
-		for($i = 0; $i < $this->header['BlockCount']; $i++){
67
+		for ($i = 0; $i < $this->header['BlockCount']; $i++) {
68 68
 			$this->blocktable[$i] = unpack('QOffset/QSize', fread($this->fh, 16));
69 69
 		}
70 70
 
Please login to merge, or discard this patch.
src/Archive/AARCReader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 use function bin2hex, fread, fseek, unpack;
18 18
 
19
-final class AARCReader extends PACKReaderAbstract{
19
+final class AARCReader extends PACKReaderAbstract {
20 20
 
21 21
 	private const AARC_ROOT = 'a4ArchiveType/LVersion/LBlockcount/LIndex';
22 22
 	private const AARC_DATA = 'LIndex/a20Hash/QSizeCompressed';
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		// get the root info block of the AARC file (4+4+4+4 = 16 bytes)
30 30
 		$rootInfo = unpack($this::AARC_ROOT, fread($this->fh, 16));
31 31
 
32
-		if($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41"){ // CRAA
32
+		if ($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41") { // CRAA
33 33
 			throw new WSDBException('invalid AARC');
34 34
 		}
35 35
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		fseek($this->fh, $blockInfo['Offset']);
40 40
 
41 41
 		// read the data block info (4+20+8 = 32 bytes)
42
-		for($i = 0; $i < $rootInfo['Blockcount']; $i++){
42
+		for ($i = 0; $i < $rootInfo['Blockcount']; $i++) {
43 43
 			$data = unpack($this::AARC_DATA, fread($this->fh, 32));
44 44
 			$hash = bin2hex($data['Hash']);
45 45
 			unset($data['Hash']);
Please login to merge, or discard this patch.