Passed
Push — main ( da7af7...cde2af )
by smiley
02:10
created

QRMarkup::html()   A

Complexity

Conditions 5
Paths 12

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 5
eloc 15
nc 12
nop 1
dl 0
loc 28
rs 9.4555
c 2
b 0
f 1
1
<?php
2
/**
3
 * Class QRMarkup
4
 *
5
 * @created      17.12.2016
6
 * @author       Smiley <[email protected]>
7
 * @copyright    2016 Smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\QRCode\Output;
12
13
use function is_string, strip_tags, trim;
14
15
/**
16
 * Abstract for markup types: HTML, SVG, ... XML anyone?
17
 */
18
abstract class QRMarkup extends QROutputAbstract{
19
20
	/**
21
	 * @inheritDoc
22
	 */
23
	protected function moduleValueIsValid($value):bool{
24
		return is_string($value);
25
	}
26
27
	/**
28
	 * @inheritDoc
29
	 */
30
	protected function getModuleValue($value):string{
31
		return trim(strip_tags($value), " '\"\r\n\t");
32
	}
33
34
	/**
35
	 * @inheritDoc
36
	 */
37
	protected function getDefaultModuleValue(bool $isDark):string{
38
		return $isDark ? $this->options->markupDark : $this->options->markupLight;
39
	}
40
41
	/**
42
	 * @inheritDoc
43
	 */
44
	public function dump(string $file = null):string{
45
		$file       ??= $this->options->cachefile;
46
		$saveToFile   = $file !== null;
47
48
		$data = $this->createMarkup($saveToFile);
49
50
		if($saveToFile){
51
			$this->saveToFile($data, $file);
52
		}
53
54
		return $data;
55
	}
56
57
	/**
58
	 *
59
	 */
60
	abstract protected function createMarkup(bool $saveToFile):string;
61
}
62