Passed
Branch master (7bf96f)
by smiley
04:02
created
examples/custom.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
 /**
12 12
  * Class MyCustomOutput
13 13
  */
14
-class MyCustomOutput extends QROutputBase implements QROutputInterface{
14
+class MyCustomOutput extends QROutputBase implements QROutputInterface {
15 15
 
16 16
 	/**
17 17
 	 * @return mixed
18 18
 	 * @throws \chillerlan\QRCode\Output\QRCodeOutputException
19 19
 	 */
20
-	public function dump(){
20
+	public function dump() {
21 21
 
22 22
 		$output = '';
23 23
 
24
-		for($row = 0; $row < $this->pixelCount; $row++){
25
-			for($col = 0; $col < $this->pixelCount; $col++){
24
+		for ($row = 0; $row < $this->pixelCount; $row++) {
25
+			for ($col = 0; $col < $this->pixelCount; $col++) {
26 26
 				$output .= (string)(int)$this->matrix[$row][$col];
27 27
 			}
28 28
 		}
@@ -36,4 +36,4 @@  discard block
 block discarded – undo
36 36
 
37 37
 echo (new QRCode('otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net', new MyCustomOutput))->output();
38 38
 
39
-echo PHP_EOL.'QRCode: '.round((microtime(true)-$starttime), 5);
39
+echo PHP_EOL.'QRCode: '.round((microtime(true) - $starttime), 5);
Please login to merge, or discard this patch.
src/BitBuffer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  *
17 17
  */
18
-class BitBuffer{
18
+class BitBuffer {
19 19
 
20 20
 	/**
21 21
 	 * @var array
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 *
32 32
 	 */
33
-	public function clear(){
33
+	public function clear() {
34 34
 		$this->buffer = [];
35 35
 		$this->length = 0;
36 36
 	}
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return $this
43 43
 	 */
44
-	public function put($num, $length){
44
+	public function put($num, $length) {
45 45
 
46
-		for($i = 0; $i < $length; $i++){
46
+		for ($i = 0; $i < $length; $i++) {
47 47
 			$this->putBit(($num >> ($length - $i - 1))&1 === 1);
48 48
 		}
49 49
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return $this
56 56
 	 */
57
-	public function putBit($bit){
57
+	public function putBit($bit) {
58 58
 		$bufIndex = floor($this->length / 8);
59 59
 
60
-		if(count($this->buffer) <= $bufIndex){
60
+		if (count($this->buffer) <= $bufIndex) {
61 61
 			$this->buffer[] = 0;
62 62
 		}
63 63
 
64
-		if($bit){
64
+		if ($bit) {
65 65
 			$this->buffer[(int)$bufIndex] |= (0x80 >> ($this->length % 8));
66 66
 		}
67 67
 
Please login to merge, or discard this patch.
src/Data/AlphaNum.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  *
20 20
  */
21
-class AlphaNum extends QRDataBase implements QRDataInterface{
21
+class AlphaNum extends QRDataBase implements QRDataInterface {
22 22
 
23 23
 	const CHAR_MAP = [
24 24
 		36 => ' ',
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @param \chillerlan\QRCode\BitBuffer $buffer
47 47
 	 */
48
-	public function write(BitBuffer &$buffer){
48
+	public function write(BitBuffer&$buffer) {
49 49
 		$i = 0;
50 50
 
51
-		while($i + 1 < $this->dataLength){
51
+		while ($i + 1 < $this->dataLength) {
52 52
 			$buffer->put($this->getCharCode($this->data[$i]) * 45 + $this->getCharCode($this->data[$i + 1]), 11);
53 53
 			$i += 2;
54 54
 		}
55 55
 
56
-		if($i < $this->dataLength){
56
+		if ($i < $this->dataLength) {
57 57
 			$buffer->put($this->getCharCode($this->data[$i]), 6);
58 58
 		}
59 59
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
 	 * @return int
66 66
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
67 67
 	 */
68
-	private static function getCharCode($c){
68
+	private static function getCharCode($c) {
69 69
 		$c = ord($c);
70 70
 
71
-		switch(true){
71
+		switch (true) {
72 72
 			case ord('0') <= $c && $c <= ord('9'): return $c - ord('0');
73 73
 			case ord('A') <= $c && $c <= ord('Z'): return $c - ord('A') + 10;
74 74
 			default:
75
-				foreach(self::CHAR_MAP as $i => $char){
76
-					if(ord($char) === $c){
75
+				foreach (self::CHAR_MAP as $i => $char) {
76
+					if (ord($char) === $c) {
77 77
 						return $i;
78 78
 					}
79 79
 				}
Please login to merge, or discard this patch.
src/Data/Byte.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  *
20 20
  */
21
-class Byte extends QRDataBase implements QRDataInterface{
21
+class Byte extends QRDataBase implements QRDataInterface {
22 22
 
23 23
 	/**
24 24
 	 * @var int
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @param \chillerlan\QRCode\BitBuffer $buffer
35 35
 	 */
36
-	public function write(BitBuffer &$buffer){
37
-		for($i = 0; $i < $this->dataLength; $i++){
36
+	public function write(BitBuffer&$buffer) {
37
+		for ($i = 0; $i < $this->dataLength; $i++) {
38 38
 			$buffer->put(ord($this->data[$i]), 8);
39 39
 		}
40 40
 	}
Please login to merge, or discard this patch.
src/Data/Kanji.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  *
20 20
  */
21
-class Kanji extends QRDataBase implements QRDataInterface{
21
+class Kanji extends QRDataBase implements QRDataInterface {
22 22
 
23 23
 	/**
24 24
 	 * @var int
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
37 37
 	 */
38
-	public function write(BitBuffer &$buffer){
38
+	public function write(BitBuffer&$buffer) {
39 39
 
40 40
 		$i = 0;
41
-		while($i + 1 < $this->dataLength){
41
+		while ($i + 1 < $this->dataLength) {
42 42
 			$c = ((0xff&ord($this->data[$i])) << 8)|(0xff&ord($this->data[$i + 1]));
43 43
 
44
-			if(0x8140 <= $c && $c <= 0x9FFC){
44
+			if (0x8140 <= $c && $c <= 0x9FFC) {
45 45
 				$c -= 0x8140;
46 46
 			}
47
-			else if(0xE040 <= $c && $c <= 0xEBBF){
47
+			else if (0xE040 <= $c && $c <= 0xEBBF) {
48 48
 				$c -= 0xC140;
49 49
 			}
50
-			else{
50
+			else {
51 51
 				throw new QRCodeDataException('illegal char at '.($i + 1).' ('.$c.')');
52 52
 			}
53 53
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			$i += 2;
56 56
 		}
57 57
 
58
-		if($i < $this->dataLength){
58
+		if ($i < $this->dataLength) {
59 59
 			throw new QRCodeDataException('illegal char at '.($i + 1));
60 60
 		}
61 61
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,11 +43,9 @@
 block discarded – undo
43 43
 
44 44
 			if(0x8140 <= $c && $c <= 0x9FFC){
45 45
 				$c -= 0x8140;
46
-			}
47
-			else if(0xE040 <= $c && $c <= 0xEBBF){
46
+			} else if(0xE040 <= $c && $c <= 0xEBBF){
48 47
 				$c -= 0xC140;
49
-			}
50
-			else{
48
+			} else{
51 49
 				throw new QRCodeDataException('illegal char at '.($i + 1).' ('.$c.')');
52 50
 			}
53 51
 
Please login to merge, or discard this patch.
src/Data/Number.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  *
20 20
  */
21
-class Number extends QRDataBase implements QRDataInterface{
21
+class Number extends QRDataBase implements QRDataInterface {
22 22
 
23 23
 	/**
24 24
 	 * @var int
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @param \chillerlan\QRCode\BitBuffer $buffer
35 35
 	 */
36
-	public function write(BitBuffer &$buffer){
36
+	public function write(BitBuffer&$buffer) {
37 37
 		$i = 0;
38 38
 
39
-		while($i + 2 < $this->dataLength){
39
+		while ($i + 2 < $this->dataLength) {
40 40
 			$buffer->put($this->parseInt(substr($this->data, $i, 3)), 10);
41 41
 			$i += 3;
42 42
 		}
43 43
 
44
-		if($i < $this->dataLength){
44
+		if ($i < $this->dataLength) {
45 45
 
46
-			if($this->dataLength - $i === 1){
46
+			if ($this->dataLength - $i === 1) {
47 47
 				$buffer->put($this->parseInt(substr($this->data, $i, $i + 1)), 4);
48 48
 			}
49
-			elseif($this->dataLength - $i === 2){
49
+			elseif ($this->dataLength - $i === 2) {
50 50
 				$buffer->put($this->parseInt(substr($this->data, $i, $i + 2)), 7);
51 51
 			}
52 52
 
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 	 * @return int
61 61
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
62 62
 	 */
63
-	private static function parseInt($string){
63
+	private static function parseInt($string) {
64 64
 		$num = 0;
65 65
 
66 66
 		$len = strlen($string);
67
-		for($i = 0; $i < $len; $i++){
67
+		for ($i = 0; $i < $len; $i++) {
68 68
 			$c = ord($string[$i]);
69 69
 			$ord0 = ord('0');
70 70
 
71
-			if($ord0 <= $c && $c <= ord('9')){
71
+			if ($ord0 <= $c && $c <= ord('9')) {
72 72
 				$c = $c - $ord0;
73 73
 			}
74
-			else{
74
+			else {
75 75
 				throw new QRCodeDataException('illegal char: '.$c);
76 76
 			}
77 77
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 			if($this->dataLength - $i === 1){
47 47
 				$buffer->put($this->parseInt(substr($this->data, $i, $i + 1)), 4);
48
-			}
49
-			elseif($this->dataLength - $i === 2){
48
+			} elseif($this->dataLength - $i === 2){
50 49
 				$buffer->put($this->parseInt(substr($this->data, $i, $i + 2)), 7);
51 50
 			}
52 51
 
@@ -70,8 +69,7 @@  discard block
 block discarded – undo
70 69
 
71 70
 			if($ord0 <= $c && $c <= ord('9')){
72 71
 				$c = $c - $ord0;
73
-			}
74
-			else{
72
+			} else{
75 73
 				throw new QRCodeDataException('illegal char: '.$c);
76 74
 			}
77 75
 
Please login to merge, or discard this patch.
src/Data/QRCodeDataException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,6 +17,6 @@
 block discarded – undo
17 17
 /**
18 18
  * Placeholder
19 19
  */
20
-class QRCodeDataException extends Exception{
20
+class QRCodeDataException extends Exception {
21 21
 
22 22
 }
Please login to merge, or discard this patch.
src/Data/QRDataBase.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  *
17 17
  */
18
-class QRDataBase{
18
+class QRDataBase {
19 19
 
20 20
 	/**
21 21
 	 * @var string
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $data
39 39
 	 */
40
-	public function __construct($data){
40
+	public function __construct($data) {
41 41
 		$this->data = $data;
42 42
 		$this->dataLength = strlen($data);
43 43
 	}
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
50 50
 	 * @codeCoverageIgnore not used in the code but may be useful to others
51 51
 	 */
52
-	public function getLengthInBits($type){
52
+	public function getLengthInBits($type) {
53 53
 
54
-		switch(true){
55
-			case $type >=  1 && $type <= 9: return $this->lengthBits[0]; //  1 -  9
54
+		switch (true) {
55
+			case $type >= 1 && $type <= 9: return $this->lengthBits[0]; //  1 -  9
56 56
 			case $type <= 26              : return $this->lengthBits[1]; // 10 - 26
57 57
 			case $type <= 40              : return $this->lengthBits[2]; // 27 - 40
58 58
 			default:
Please login to merge, or discard this patch.
src/Data/QRDataInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
 /**
18 18
  *
19 19
  */
20
-interface QRDataInterface{
20
+interface QRDataInterface {
21 21
 
22 22
 	/**
23 23
 	 * @param \chillerlan\QRCode\BitBuffer $buffer
24 24
 	 */
25
-	public function write(BitBuffer &$buffer);
25
+	public function write(BitBuffer&$buffer);
26 26
 
27 27
 	/**
28 28
 	 * @param $type
Please login to merge, or discard this patch.