Passed
Push — main ( e5ef3a...f1ef56 )
by N.
04:15
created

Visa::visa_genererade_rader()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 30
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 6
nop 0
dl 0
loc 30
ccs 12
cts 12
cp 1
crap 4
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass Visa.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Klasser\Spelade;
11
12
/**
13
 * Klass Visa.
14
 */
15
class Visa extends Mall {
16
	public bool $spelad = false;
17
18
	/**
19
	 * Visa genererade rader.
20
	 */
21 1
	public function visa_genererade_rader(): void {
22 1
		if (file_exists(GRAF . $this->bildfil)) {
23 1
			$this->tipsgraf = $this->graf->rendera_tipsgraf($this->bildfil);
24
		}
25
26 1
		$radknapp = '';
27 1
		$kombinationsgraf = '';
28
29
		/**
30
		 * Spel finns för omgången.
31
		 */
32 1
		if ($this->spelad) {
33
			/**
34
			 * Lägg rader som sträng i request.
35
			 */
36 1
			$kod = base64_encode("{$this->mappnamn}/{$this->utdelning->spel->filnamn}.txt");
37
38 1
			$radknapp = t(7, "<p><a id=\"radknapp\" target=\"_blank\" href=\"/ajax/RaderAjax.php?fil=$kod\">{$this->antal_utvalda_rader} r ↗️</a></p>");
39
40
			/**
41
			 * Återskapa tipsrader i filsystemet.
42
			 */
43 1
			if (!file_exists($this->textfil)) {
44 1
				$this->spara_genererade_tipsrader_fil();
45
			}
46
47 1
			$kombinationsgraf = $this->kombinationsgraf('/kombinationsgraf.png', $this->bildfil);
48
		}
49
50 1
		$this->markup($radknapp, $kombinationsgraf);
51
	}
52
}
53