Completed
Push — master ( 102ef4...1ff5c6 )
by smiley
02:47
created

QRString::toHTML()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.5125
c 0
b 0
f 0
cc 5
eloc 13
nc 7
nop 0
1
<?php
2
/**
3
 * Class QRString
4
 *
5
 * @filesource   QRString.php
6
 * @created      05.12.2015
7
 * @package      chillerlan\QRCode\Output
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2015 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\QRCode\Output;
14
15
use chillerlan\QRCode\QRCode;
16
17
/**
18
 *
19
 */
20
class QRString extends QROutputAbstract{
21
22
	protected $optionsInterface = QRStringOptions::class;
23
24
	protected $types = [
25
		QRCode::OUTPUT_STRING_TEXT,
26
		QRCode::OUTPUT_STRING_JSON,
27
	];
28
29
	/**
30
	 * @return string
31
	 */
32
	public function dump(){
33
34
		switch($this->options->type){
35
			case QRCode::OUTPUT_STRING_TEXT: return $this->toString();
2 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
36
			case QRCode::OUTPUT_STRING_JSON:
37
			default:
38
				return json_encode($this->matrix);
39
		}
40
41
	}
42
43
	/**
44
	 * @return string
45
	 */
46
	protected function toString(){
47
		$str = '';
48
49
		foreach($this->matrix as $row){
50
			foreach($row as $col){
51
				$str .= $col
52
					? $this->options->textDark
53
					: $this->options->textLight;
54
			}
55
56
			$str .= $this->options->eol;
57
		}
58
59
		return $str;
60
	}
61
62
}
63