Passed
Push — main ( a92fbe...d29be2 )
by N.
05:41 queued 01:24
created

Visa   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 42
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A visa() 0 38 3
1
<?php
2
3
/**
4
 * Klass Visa.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Klasser\Generera;
11
12
/**
13
 * Klass Visa.
14
 */
15
class Visa extends Spara {
16
	/**
17
	 * Visa genererade rader samt graf.
18
	 */
19 1
	protected function visa(string $spelade_rader): void {
20
		/**
21
		 * Rendera tipsgrafer.
22
		 */
23 1
		$tipsgraf = $this->graf->rendera_tipsgraf($this->bildfil);
24 1
		$kombinationsgraf = $this->tips->spelade->kombinationsgraf($this->kombinerad_bildfil, $this->bildfil);
25
26
		/**
27
		 * Procent spelade rader gentemot genererade.
28
		 */
29 1
		$kvot = ($this->antal_genererade > 0) ? number_format(100 * $this->antal_utvalda_rader / $this->antal_genererade, 2) : 0;
30
31
		/**
32
		 * Visa resursförbrukning av tid och minne.
33
		 */
34 1
		$minne = round(memory_get_peak_usage() / 1048576, 2);
35 1
		$tidsdifferens = round((hrtime(true) - $this->tid) / 1000000000, 2);
36 1
		$maxtid = ($tidsdifferens < MAXTID) ? "✅ " : "❌ ";
0 ignored issues
show
Bug introduced by
The constant Tips\Klasser\Generera\MAXTID was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37 1
		$maxtid .= strval(MAXTID) . ' s';
38
39
		/**
40
		 * Eka ut flik med genererat innehåll.
41
		 */
42 1
		echo <<< EOT
43 1
			<div id="flikar-genererat">
44
				<div class="spelade-grid">
45
					<div class="grid-spelade-rader">
46
						<h1>Genererade</h1>
47 1
						<p><strong>Omgång {$this->tips->spel->omgång}</strong></p>
48
						<div class="tipsrader">
49 1
							<p>{$this->tips->spel->speltyp->produktnamn()}, ({$this->antal_utvalda_rader} rader)</p>
50 1
$spelade_rader							…
51
						</div> <!-- tipsrader -->
52
					</div> <!-- grid-spelade-rader -->
53
					<div class="grid-graf">
54 1
						<p>Rader: {$this->antal_utvalda_rader} ({$this->antal_genererade}: $kvot %) ($tidsdifferens s | $maxtid, $minne MB)</p>
55 1
						<p>$tipsgraf</p>
56 1
						<p>$kombinationsgraf</p>
57
						<p><input type="submit" id="spara_generering" value="Spara">
58
							<label>Investera<input type="checkbox" checked id="investera_sparad"></label></p>
59
					</div> <!-- grid-graf -->
60
				</div> <!-- spelade-grid -->
61
			</div> <!-- spelade-genererat -->
62
63 1
EOT;
64
	}
65
}
66