Test Setup Failed
Push — master ( 1dbe7c...ac3ddd )
by Filipe
06:07 queued 02:38
created
src/Btrieve.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 	public $pools;
34 34
 	const POOL_MAIN 	= 0;
35
-	const POOL_DEBUG 	= 1;
35
+	const POOL_DEBUG = 1;
36 36
 	const POOL_ROWS 	= 2;
37 37
 
38 38
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function setInput($file)
71 71
 	{
72
-		if(!file_exists($file)) {
72
+		if (!file_exists($file)) {
73 73
 			throw new InvalidArgumentException('File not found.');
74 74
 		}
75 75
 		$this->input = $file;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function setRules($rules)
94 94
 	{
95
-		if(!is_array($rules)) {
95
+		if (!is_array($rules)) {
96 96
 			$rules = [$rules];
97 97
 		}
98 98
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function addRules($new_rules)
140 140
 	{
141
-		if(!is_array($new_rules)) {
141
+		if (!is_array($new_rules)) {
142 142
 			throw new InvalidArgumentException('Parameter must be an array of Rules');
143 143
 		}
144 144
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function clearRules()
157 157
 	{
158
-		foreach($this->getRules() as $rule) {
158
+		foreach ($this->getRules() as $rule) {
159 159
 			unset($rule);
160 160
 		}
161 161
 		unset($this->rules);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function skip($size = null)
173 173
 	{
174
-		if(is_null($size)) {
174
+		if (is_null($size)) {
175 175
 			$this->addRule(new SkipRule());
176 176
 		} else {
177 177
 			$this->addRule(new SkipRule($size));
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function id($title, $size = null)
200 200
 	{
201
-		if(is_null($size)) {
201
+		if (is_null($size)) {
202 202
 			$this->addColumn(new IdColumn($title));
203 203
 		} else {
204 204
 			$this->addColumn(new IdColumn($title, $size));
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function int($title, $size = null)
216 216
 	{
217
-		if(is_null($size)) {
217
+		if (is_null($size)) {
218 218
 			$this->addColumn(new IntColumn($title));
219 219
 		} else {
220 220
 			$this->addColumn(new IntColumn($title, $size));
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	public function date($title, $size = null)
232 232
 	{
233
-		if(is_null($size)) {
233
+		if (is_null($size)) {
234 234
 			$this->addColumn(new DateColumn($title));
235 235
 		} else {
236 236
 			$this->addColumn(new DateColumn($title, $size));
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function float($title, $size = null)
248 248
 	{
249
-		if(is_null($size)) {
249
+		if (is_null($size)) {
250 250
 			$this->addColumn(new FloatColumn($title));
251 251
 		} else {
252 252
 			$this->addColumn(new FloatColumn($title, $size));
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public function string($title, $size = null)
264 264
 	{
265
-		if(is_null($size)) {
265
+		if (is_null($size)) {
266 266
 			$this->addColumn(new StringColumn($title));
267 267
 		} else {
268 268
 			$this->addColumn(new StringColumn($title, $size));
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	public function setColumns()
297 297
 	{
298 298
 		$columns = array_filter($this->getRules(), function($rule) {
299
-			if($rule instanceof ColumnInterface) {
299
+			if ($rule instanceof ColumnInterface) {
300 300
 				return $rule;
301 301
 			}
302 302
 		});
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function getColumns()
316 316
 	{
317
-		if($this->dirty) {
317
+		if ($this->dirty) {
318 318
 			$this->setColumns();
319 319
 			$this->dirty = false;
320 320
 		}
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public function begin()
339 339
 	{
340
-		$this->pointer = fopen($this->input,'rb');
340
+		$this->pointer = fopen($this->input, 'rb');
341 341
 		$this->input_stats = fstat($this->getPointer());
342 342
 
343
-		if(is_null($this->getPointer())) {
343
+		if (is_null($this->getPointer())) {
344 344
 			throw new Exception('Couldnt create the pointer at input file.');
345 345
 		}
346 346
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	public function hasPool($index)
377 377
 	{
378
-		if(isset($this->pools[$index])) {
378
+		if (isset($this->pools[$index])) {
379 379
 			return true;
380 380
 		}
381 381
 		return false;
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 */
389 389
 	public function getPool($key)
390 390
 	{
391
-		if($this->hasPool($key)) {
391
+		if ($this->hasPool($key)) {
392 392
 			return $this->pools[$key];
393 393
 		}
394 394
 		throw new InvalidArgumentException('Pool with key \''.$key.'\' was not registered.');
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	 */
457 457
 	protected function addElem($element)
458 458
 	{
459
-		foreach($this->getPools() as $pool) {
459
+		foreach ($this->getPools() as $pool) {
460 460
 			$pool->add($element);
461 461
 		}
462 462
 		return $this;
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 */
469 469
 	public function hasNext()
470 470
 	{
471
-		if($this->position() == $this->inputLength() and feof($this->getPointer())) {
471
+		if ($this->position() == $this->inputLength() and feof($this->getPointer())) {
472 472
 			return false;
473 473
 		}
474 474
 		return true;
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
 	 */
490 490
 	public function next()
491 491
 	{
492
-		if(!$this->hasNext()) {
492
+		if (!$this->hasNext()) {
493 493
 			return null;
494 494
 		}
495 495
 		$size = $this->nextRecordLength();
496
-		if($size < 1) {
496
+		if ($size < 1) {
497 497
 			return null;
498 498
 		}
499 499
 		$raw_content = $this->readBits($size);
500
-		if(is_null($raw_content)) {
500
+		if (is_null($raw_content)) {
501 501
 			return null;
502 502
 		}
503 503
 		$index = $this->applyRules($raw_content, $size);
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 */
511 511
 	protected function readBits($n = 1)
512 512
 	{
513
-		if($this->position() + $n >= $this->inputLength() and feof($this->getPointer())) {
513
+		if ($this->position() + $n >= $this->inputLength() and feof($this->getPointer())) {
514 514
 			return null;
515 515
 		}
516 516
 		return fread($this->getPointer(), $n);
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
 
546 546
 		foreach ($this->getRules() as $rule) {
547 547
 			$column_content = substr($raw, $position, $rule->getLength());
548
-			if($rule instanceof ColumnInterface) {
548
+			if ($rule instanceof ColumnInterface) {
549 549
 				$attributes[$rule->getTitle()] = $rule::cast($column_content);
550 550
 			}
551 551
 			$position += $rule->getLength();
552 552
 		}
553 553
 	
554
-		if($position < $size) {
555
-			$column_content = Bin::toHex(substr($raw, $position, ($size-$position)));
554
+		if ($position < $size) {
555
+			$column_content = Bin::toHex(substr($raw, $position, ($size - $position)));
556 556
 			$column_content = preg_split('/(?<=2020)2020(?!2020])/', $column_content);
557 557
 			$column_content = Hex::toStr(end($column_content));
558 558
 			$attributes[$this->getVariableColumnName()] = $column_content;
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	 */
570 570
 	public function exists($index, $target_pool = self::POOL_MAIN)
571 571
 	{
572
-		if($this->haspool($index)) {
572
+		if ($this->haspool($index)) {
573 573
 			return $this->getPool($key)->exists($index);
574 574
 		}
575 575
 		throw new InvalidArgumentException('Invalid pool.');
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 	 */
584 584
 	public function elem($index, $target_pool = self::POOL_MAIN)
585 585
 	{
586
-		if($this->haspool($index)) {
586
+		if ($this->haspool($index)) {
587 587
 			return $this->getPool($target_pool)->elem($index);
588 588
 		} else {
589 589
 			throw new InvalidArgumentException('Invalid pool.');
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 	public function take($number_of_elements = 1)
610 610
 	{
611 611
 		$elements = [];
612
-		while(($number_of_elements > 0) and $this->hasNext())
612
+		while (($number_of_elements > 0) and $this->hasNext())
613 613
 		{
614 614
 			$temp = $this->next();
615 615
 			$objects->push($temp);
@@ -625,9 +625,9 @@  discard block
 block discarded – undo
625 625
 	 */
626 626
 	public function all() {
627 627
 		$objects = []
628
-		while($this->hasNext()) {
628
+		while ($this->hasNext()) {
629 629
 			$next = $this->next();
630
-			if($next == FALSE) break;
630
+			if ($next == FALSE) break;
631 631
 			$objects->push($next);
632 632
 		}
633 633
 
Please login to merge, or discard this patch.