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

Visa::visa_investering()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 41
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 3.0059

Importance

Changes 0
Metric Value
cc 3
eloc 20
nc 4
nop 0
dl 0
loc 41
ccs 21
cts 23
cp 0.913
crap 3.0059
rs 9.6
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\Investera;
11
12
use Tips\Klasser\Graf;
13
14
/**
15
 * Klass Visa.
16
 * Visar n senaste lagda spelen.
17
 */
18
class Visa extends Flik {
19
	/**
20
	 * Visa investeringar.
21
	 */
22 1
	public function visa_investering(): void {
23 1
		$this->graf = new Graf();
24 1
		$this->ackumulerad_graf = new Graf();
25 1
		$this->uppdatera_preferenser();
26 1
		$this->hämta_investering();
27 1
		$this->hämta_investeringar();
28
29
		/**
30
		 * Antal genererade rader.
31
		 */
32 1
		$andel = match (true) {
33 1
			$this->antal_genererade > 0 =>
34
				number_format(100 * $this->antal_utvalda_rader / $this->antal_genererade, 2),
35 1
			default => 0
36 1
		};
37
38
		/**
39
		 * Stil för vinstrader.
40
		 */
41 1
		[$s13, $s12, $s11, $s10] = $this->vinststil($this->vinstdata);
42
43 1
		$tabell = match ($this->spelad) {
44
			true => $this->tabell($andel, $s13, $s12, $s11, $s10),
45 1
			false => ''
46 1
		};
47
48 1
		$netto = $this->ackumulerad_vinst - $this->ackumulerad_utgift;
49 1
		$acknetto = $this->ackmax - $this->ackmin;
50
51
		/**
52
		 * Plotta grafer?
53
		 */
54 1
		if (!file_exists(GRAF . $this->fil)) {
55 1
			$this->plotta_investeringar();
56
		}
57
58 1
		if (!file_exists(GRAF . $this->fil_ack)) {
59 1
			$this->plotta_ackumulerad_investering();
60
		}
61
62 1
		$this->flik($tabell, $netto, $acknetto);
63
	}
64
}
65