Passed
Push — main ( f1b4ad...6ccac6 )
by N.
04:46
created

Vinstgraf   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 36
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A visa_modul() 0 30 3
1
<?php
2
3
/**
4
 * Klass Vinstgraf.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler;
11
12
use ReflectionClass;
13
use Tips\Moduler\Vinstgraf\Tipsrader;
14
use Tips\Egenskaper\Eka;
15
16
/**
17
 * Klass Vinstgraf.
18
 */
19
final class Vinstgraf extends Tipsrader {
20
	use Eka;
21
22
	/**
23
	 * Visa vinstgraf i modulflik.
24
	 */
25 1
	public function visa_modul(): void {
26 1
		$klass = (new ReflectionClass($this))->getShortName();
27
28 1
		$this->hämta_tipsrader();
29 1
		$this->antal_rader = count($this->tipsrader);
30 1
		$andel = ($this->totalt_antal_rader > 0) ? round(100 * $this->antal_rader / $this->totalt_antal_rader, 1) : 0;
31
32
		/**
33
		 * Rendera vinstgraf.
34
		 */
35 1
		foreach ($this->tipsrader as [$tipsrad_012, $u13]) {
36
			$this->rita($tipsrad_012, intval($u13));
37
		}
38
39 1
		$this->graf->spara_tipsgraf(self::FIL);
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Vinstgraf::FIL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
40
41
		/**
42
		 * Eka ut modul i HTML.
43
		 */
44 1
		echo <<< EOT
45 1
			<div id="modulflikar-$klass">
46 1
				<h1>$klass</h1>
47 1
				<p>{$this->eka($this->graf->rendera_tipsgraf(self::FIL))}</p>
48 1
				<p>{$this->antal_rader} / {$this->totalt_antal_rader} rader ($andel %)</p>
49
				<form>
50 1
					<p>[min, max]: utd 13r: <input type="number" min="100" max="1000000" step="10000" id="utdelning_13_min" size="8" value="{$this->utdelning_13_min}">
51 1
					<input type="number" min="10000" max="20000000" step="10000" id="utdelning_13_max" size="9" value="{$this->utdelning_13_max}">
52
					<input type="submit" value="Uppdatera värden" id="uppdatera_vinstgraf"></p>
53
				</form>
54 1
			</div> <!-- modulflikar-$klass -->
55
56 1
EOT;
57
	}
58
}
59