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

Spara   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 12.5%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 30
ccs 2
cts 16
cp 0.125
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A spara_distribution() 0 17 1
A __construct() 0 2 1
1
<?php
2
3
/**
4
 * Klass Spara.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\DistributionGenerera;
11
12
use PDO;
13
use Tips\Klasser\Tips;
14
use Tips\Moduler\Distribution;
15
16
/**
17
 * Klass Spara.
18
 */
19
class Spara {
20
	/**
21
	 * @var bool[] $andel_vid
22
	 */
23
	protected array $andel_vid;
24
25 1
	public function __construct(protected Tips $tips, protected Distribution $dist) {
26 1
		$this->andel_vid = array_fill_keys(['10', '5', '3', '2', '1', '0.5'], false);
27
	}
28
29
	/**
30
	 * Spara distribution.
31
	 */
32
	protected function spara_distribution(): void {
33
		$sats = $this->tips->odds->spel->db->instans->prepare("REPLACE INTO `distribution`
34
			(`omgång`, `speltyp`, `sekvens`, `minsumma`, `maxsumma`, `minprocent`, `maxprocent`,
35
			`oddssumma`, `procentandel`, `andelssumma`) VALUES
36
			(:omgang, :speltyp, :sekvens, :minsumma, :maxsumma, :minprocent, :maxprocent,
37
			:oddssumma, :procentandel, :andelssumma)");
38
		$sats->bindValue(':omgang', $this->tips->odds->spel->omgång, PDO::PARAM_INT);
39
		$sats->bindValue(':speltyp', $this->tips->odds->spel->speltyp->value, PDO::PARAM_INT);
40
		$sats->bindValue(':sekvens', $this->tips->odds->spel->sekvens, PDO::PARAM_INT);
41
		$sats->bindValue(':minsumma', $this->dist->minsumma, PDO::PARAM_STR);
42
		$sats->bindValue(':maxsumma', $this->dist->maxsumma, PDO::PARAM_STR);
43
		$sats->bindValue(':minprocent', $this->dist->minprocent, PDO::PARAM_STR);
44
		$sats->bindValue(':maxprocent', $this->dist->maxprocent, PDO::PARAM_STR);
45
		$sats->bindValue(':oddssumma', $this->dist->oddssumma, PDO::PARAM_STR);
46
		$sats->bindValue(':procentandel', $this->dist->procentandel, PDO::PARAM_STR);
47
		$sats->bindValue(':andelssumma', $this->dist->andelssumma, PDO::PARAM_INT);
48
		$sats->execute();
49
	}
50
}
51