Passed
Push — main ( 2777a0...306935 )
by smiley
01:56
created

QRMarkupHTML::getCssClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class QRMarkupHTML
4
 *
5
 * @created      06.06.2022
6
 * @author       smiley <[email protected]>
7
 * @copyright    2022 smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\QRCode\Output;
12
13
use function sprintf;
14
15
/**
16
 * HTML output
17
 */
18
class QRMarkupHTML extends QRMarkup{
19
20
	/**
21
	 * @inheritDoc
22
	 */
23
	protected function createMarkup(bool $saveToFile):string{
24
		$html = empty($this->options->cssClass)
25
			? '<div>'
26
			: sprintf('<div class="%s">', $this->getCssClass());
0 ignored issues
show
Bug introduced by
The call to chillerlan\QRCode\Output...rkupHTML::getCssClass() has too few arguments starting with M_TYPE. ( Ignorable by Annotation )

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

26
			: sprintf('<div class="%s">', $this->/** @scrutinizer ignore-call */ getCssClass());

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
27
28
		$html .= $this->options->eol;
29
30
		foreach($this->matrix->matrix() as $row){
31
			$html .= '<div>';
32
33
			foreach($row as $M_TYPE){
34
				$html .= sprintf('<span style="background: %s;"></span>', $this->moduleValues[$M_TYPE]);
35
			}
36
37
			$html .= '</div>'.$this->options->eol;
38
		}
39
40
		$html .= '</div>'.$this->options->eol;
41
42
		// wrap the snippet into a body when saving to file
43
		if($saveToFile){
44
			$html = sprintf(
45
				'<!DOCTYPE html><head><meta charset="UTF-8"><title>QR Code</title></head><body>%s</body>',
46
				$this->options->eol.$html
47
			);
48
		}
49
50
		return $html;
51
	}
52
53
	/**
54
	 * @inheritDoc
55
	 */
56
	protected function getCssClass(int $M_TYPE):string{
57
		return $this->options->cssClass;
58
	}
59
60
}
61