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

Spara::spara_distribution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 17
ccs 0
cts 14
cp 0
crap 2
rs 9.8666
c 0
b 0
f 0
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