|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass Autospik. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Moduler; |
|
11
|
|
|
|
|
12
|
|
|
use ReflectionClass; |
|
13
|
|
|
use Tips\Klasser\Tips; |
|
14
|
|
|
use Tips\Klasser\Utdelning; |
|
15
|
|
|
use Tips\Klasser\Prediktioner; |
|
16
|
|
|
use Tips\Klasser\Matcher; |
|
17
|
|
|
use Tips\Egenskaper\Eka; |
|
18
|
|
|
use Tips\Moduler\Autospik\Prova; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Klass Autospik. |
|
22
|
|
|
*/ |
|
23
|
|
|
final class Autospik extends Prova { |
|
24
|
|
|
use Eka; |
|
25
|
|
|
|
|
26
|
|
|
public string $tipsrader = ''; |
|
27
|
|
|
public int $spikar_rätt = 0; |
|
28
|
|
|
/** |
|
29
|
|
|
* @var string[] $tipsvektor |
|
30
|
|
|
*/ |
|
31
|
|
|
public array $tipsvektor = []; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct( |
|
34
|
|
|
protected Utdelning $utdelning, |
|
35
|
|
|
protected Prediktioner $odds, |
|
36
|
|
|
protected Prediktioner $streck, |
|
37
|
|
|
protected Matcher $matcher |
|
38
|
|
|
) { |
|
39
|
|
|
parent::__construct($utdelning, $odds, $streck, $matcher); |
|
40
|
|
|
$this->uppdatera_preferenser(); |
|
41
|
|
|
$this->beräkna_spikar(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Visa modul. |
|
46
|
|
|
*/ |
|
47
|
|
|
public function visa_modul(): void { |
|
48
|
|
|
$klass = (new ReflectionClass($this))->getShortName(); |
|
49
|
|
|
|
|
50
|
|
|
echo <<< EOT |
|
51
|
|
|
<div id="modulflikar-$klass"> |
|
52
|
|
|
<div class="autospik-grid"> |
|
53
|
|
|
<div class="autospik-grid-garderingar"> |
|
54
|
|
|
<h1>{$this->eka($this->utdelning->har_tipsrad && $this->pröva_tipsrad($this->utdelning->tipsrad_012) ? '✅' : '❌')} $klass</h1> |
|
55
|
|
|
{$this->grid_garderingar()} |
|
56
|
|
|
</div> <!-- autospik-grid-garderingar --> |
|
57
|
|
|
<div class="autospik-grid-historik"> |
|
58
|
|
|
$this->historik </div> <!-- autospik-grid-historik --> |
|
59
|
|
|
</div> <!-- autospik-grid --> |
|
60
|
|
|
</div> <!-- modulflikar-$klass --> |
|
61
|
|
|
|
|
62
|
|
|
EOT; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Spara omgång. |
|
67
|
|
|
* @SuppressWarnings("PHPMD.UnusedFormalParameter") |
|
68
|
|
|
*/ |
|
69
|
|
|
public function spara_omgång(Tips $tips): void { |
|
|
|
|
|
|
70
|
|
|
$this->autospik_historik(); |
|
71
|
|
|
$this->odds->spel->db->logg->logga(self::class . ': ✅ Sparade historik.'); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.