|
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
|
|
|
|