Passed
Push — main ( 709a03...3e1426 )
by smiley
02:31
created

QRString::getDefaultModuleValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class QRString
4
 *
5
 * @created      05.12.2015
6
 * @author       Smiley <[email protected]>
7
 * @copyright    2015 Smiley
8
 * @license      MIT
9
 *
10
 * @noinspection PhpUnusedParameterInspection
11
 * @noinspection PhpComposerExtensionStubsInspection
12
 */
13
14
namespace chillerlan\QRCode\Output;
15
16
use chillerlan\QRCode\QRCode;
17
18
use function implode, is_string, json_encode;
19
20
/**
21
 * Converts the matrix data into string types
22
 */
23
class QRString extends QROutputAbstract{
24
25
	protected string $defaultMode = QRCode::OUTPUT_STRING_TEXT;
26
27
	/**
28
	 * @inheritDoc
29
	 */
30
	protected function moduleValueIsValid($value):bool{
31
		return is_string($value);
32
	}
33
34
	/**
35
	 * @inheritDoc
36
	 */
37
	protected function getModuleValue($value):string{
38
		return $value;
39
	}
40
41
	/**
42
	 * @inheritDoc
43
	 */
44
	protected function getDefaultModuleValue(bool $isDark):string{
45
		return $isDark ? $this->options->textDark : $this->options->textLight;
46
	}
47
48
	/**
49
	 * string output
50
	 */
51
	protected function text(string $file = null):string{
0 ignored issues
show
Unused Code introduced by
The parameter $file is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
	protected function text(/** @scrutinizer ignore-unused */ string $file = null):string{

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
		$str = [];
53
54
		foreach($this->matrix->matrix() as $row){
55
			$r = [];
56
57
			foreach($row as $M_TYPE){
58
				$r[] = $this->moduleValues[$M_TYPE];
59
			}
60
61
			$str[] = implode('', $r);
62
		}
63
64
		return implode($this->options->eol, $str);
0 ignored issues
show
Bug introduced by
It seems like $this->options->eol can also be of type null; however, parameter $glue of implode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

64
		return implode(/** @scrutinizer ignore-type */ $this->options->eol, $str);
Loading history...
65
	}
66
67
	/**
68
	 * JSON output
69
	 */
70
	protected function json(string $file = null):string{
0 ignored issues
show
Unused Code introduced by
The parameter $file is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

70
	protected function json(/** @scrutinizer ignore-unused */ string $file = null):string{

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
		return json_encode($this->matrix->matrix());
72
	}
73
74
}
75