Test Setup Failed
Branch master (1dbe7c)
by Filipe
02:28
created
src/Btrieve.php 2 patches
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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -627,7 +627,9 @@
 block discarded – undo
627 627
 		$objects = []
628 628
 		while($this->hasNext()) {
629 629
 			$next = $this->next();
630
-			if($next == FALSE) break;
630
+			if($next == FALSE) {
631
+				break;
632
+			}
631 633
 			$objects->push($next);
632 634
 		}
633 635
 
Please login to merge, or discard this patch.
src/Hex.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 block discarded – undo
5 5
 {
6 6
 	public static function toStr($hex)
7 7
 	{
8
-        $str = '';
9
-        for($i=0; $i < strlen($hex); $i+=2) {
10
-        	$str .= chr(hexdec(substr($hex,$i,2)));
11
-        }
12
-        return $str;
8
+		$str = '';
9
+		for($i=0; $i < strlen($hex); $i+=2) {
10
+			$str .= chr(hexdec(substr($hex,$i,2)));
11
+		}
12
+		return $str;
13 13
 	}
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 	public static function toStr($hex)
7 7
 	{
8 8
         $str = '';
9
-        for($i=0; $i < strlen($hex); $i+=2) {
10
-        	$str .= chr(hexdec(substr($hex,$i,2)));
9
+        for ($i = 0; $i < strlen($hex); $i += 2) {
10
+        	$str .= chr(hexdec(substr($hex, $i, 2)));
11 11
         }
12 12
         return $str;
13 13
 	}
Please login to merge, or discard this patch.
src/Str.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
 {
6 6
 	public static function toUtf8($str)
7 7
 	{
8
-        return utf8_encode($str);
8
+		return utf8_encode($str);
9 9
 	}
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
src/Bin.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	 */
11 11
 	public static function toHex($bin)
12 12
 	{
13
-        return bin2hex($bin);
13
+		return bin2hex($bin);
14 14
 	}
15 15
 
16 16
 	/**
Please login to merge, or discard this patch.
src/Persistence/ActiveRecord.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct($columns = [], $data = [])
28 28
 	{
29
-		if(count($columns) !== count($data)) {
29
+		if (count($columns) !== count($data)) {
30 30
 			throw new InvalidArgumentException('Columns are required to have the same # of elements from data.');
31 31
 		}
32 32
 		$this->setColumns($columns);
33 33
 		$this->setData($data);
34
-		if(!empty($columns)) {
34
+		if (!empty($columns)) {
35 35
 			$this->setAttributes(array_combine($this->getColumns(), $this->getData()));
36 36
 		}
37 37
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function has($key)
116 116
 	{
117
-		if(isset($this->attributes[$key])) {
117
+		if (isset($this->attributes[$key])) {
118 118
 			return true;
119 119
 		}
120 120
 		return false;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function attribute($key)
129 129
 	{
130
-		if(! $this->has($key)) {
130
+		if (!$this->has($key)) {
131 131
 			throw new InvalidArgumentException('Attribute \''.$key.'\' doesnt exists.');
132 132
 		}
133 133
 		return $this->attributes[$key];
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function update($key, $value)
152 152
 	{
153
-		if(! $this->has($key)) {
153
+		if (!$this->has($key)) {
154 154
 			throw new InvalidArgumentException('Attribute \''.$key.'\' doesnt exists.');
155 155
 		}
156 156
 		$this->attributes[$key] = $value;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function set($key, $value)
167 167
 	{
168
-		if($this->has($key)) {
168
+		if ($this->has($key)) {
169 169
 			return $this->update($key, $value);
170 170
 		}
171 171
 		$this->attributes[$key] = $value;
Please login to merge, or discard this patch.
src/Persistence/Pool.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function has($index)
48 48
 	{
49
-		if(isset($this->dataset[$index])) {
49
+		if (isset($this->dataset[$index])) {
50 50
 			return true;
51 51
 		}
52 52
 		return false;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function elem($index)
71 71
 	{
72
-		if($this->has($index)) {
72
+		if ($this->has($index)) {
73 73
 			return $this->dataset[$index];
74 74
 		}
75 75
 		throw new Exception('Element doesnt exist in this dataset.');
Please login to merge, or discard this patch.
src/Column/DateColumn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 	public static function cast($content)
20 20
 	{
21
-		if(self::validate($content)) {
21
+		if (self::validate($content)) {
22 22
 			return null;
23 23
 		}
24 24
 		
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	public static function validate($content)
38 38
 	{
39
-		if(intval($content) == 0 OR strlen($content)<8 OR $content == "2020202020202020") {
39
+		if (intval($content) == 0 OR strlen($content) < 8 OR $content == "2020202020202020") {
40 40
 			return false;
41 41
 		}
42 42
 		return true;
Please login to merge, or discard this patch.
src/Column/IdColumn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
 
17 17
 	public static function cast($content)
18 18
 	{
19
-		$content = str_split(Bin::toHex($content),2);
19
+		$content = str_split(Bin::toHex($content), 2);
20 20
 
21 21
 		$id = 0;
22 22
 		foreach ($content as $power => $value) {
23
-			$id += hexdec($value) * pow(256,$power);
23
+			$id += hexdec($value) * pow(256, $power);
24 24
 		}
25 25
 		
26 26
 		return intval($id);
Please login to merge, or discard this patch.
src/Column/ColumnRule.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 class ColumnRule extends Rule implements RuleInterface
8 8
 {
9 9
 	const TYPE_DATE 	= 0;
10
-	const TYPE_FLOAT 	= 1;
11
-	const TYPE_ID 		= 2;
10
+	const TYPE_FLOAT = 1;
11
+	const TYPE_ID = 2;
12 12
 	const TYPE_INT 		= 3;
13
-	const TYPE_STRING 	= 4;
13
+	const TYPE_STRING = 4;
14 14
 
15 15
 	protected $title;
16 16
 	protected $type;
Please login to merge, or discard this patch.