Passed
Push — main ( b436ac...f1b4ad )
by N.
04:39
created

Preferenser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 117
ccs 75
cts 75
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A uppdatera_preferenser() 0 91 1
1
<?php
2
3
/**
4
 * Klass Preferenser.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\Andel;
11
12
use Tips\Klasser\Utdelning;
13
use Tips\Klasser\Prediktioner;
14
use Tips\Klasser\Matcher;
15
use Tips\Klasser\DBPreferenser;
16
use Tips\Egenskaper\Tick;
17
18
/**
19
 * Klass Preferenser.
20
 * Kontrollera inställningar.
21
 */
22
class Preferenser {
23
	use Tick;
24
25
	protected DBPreferenser $db_preferenser;
26
	protected int $andel_1_min = 0;
27
	protected int $andel_1_max = 0;
28
	protected int $andel_x_min = 0;
29
	protected int $andel_x_max = 0;
30
	protected int $andel_2_min = 0;
31
	protected int $andel_2_max = 0;
32
33
	/**
34
	 * Initiera.
35
	 */
36 1
	public function __construct(
37
		protected Utdelning $utdelning,
38
		protected Prediktioner $odds,
39
		protected Prediktioner $streck,
40
		protected Matcher $matcher
41
	) {
42 1
		$this->db_preferenser = new DBPreferenser($this->utdelning->spel->db);
43
	}
44
45
	/**
46
	 * Uppdatera preferenser.
47
	 */
48 1
	protected function uppdatera_preferenser(): void {
49
		/**
50
		 * Attraktionsfaktor mellan 1 och 3^13.
51
		 */
52 1
		$this->db_preferenser->int_preferens_i_intervall(
53 1
			$this->attraktionsfaktor,
54 1
			AF_MIN,
55 1
			AF_MAX,
56 1
			AF_STD,
57 1
			'andel.attraktionsfaktor'
58 1
		);
59
60
		/**
61
		 * Andel tecken mellan 0 och 13.
62
		 */
63 1
		$this->db_preferenser->int_preferens_i_intervall(
64 1
			$this->andel_1_min,
65 1
			0,
66 1
			13,
67 1
			3,
68 1
			'andel.andel_1_min'
69 1
		);
70
71 1
		$this->db_preferenser->int_preferens_i_intervall(
72 1
			$this->andel_1_max,
73 1
			0,
74 1
			13,
75 1
			8,
76 1
			'andel.andel_1_max'
77 1
		);
78
79 1
		$this->db_preferenser->int_preferens_i_intervall(
80 1
			$this->andel_x_min,
81 1
			0,
82 1
			13,
83 1
			1,
84 1
			'andel.andel_x_min'
85 1
		);
86
87 1
		$this->db_preferenser->int_preferens_i_intervall(
88 1
			$this->andel_x_max,
89 1
			0,
90 1
			13,
91 1
			6,
92 1
			'andel.andel_x_max'
93 1
		);
94
95 1
		$this->db_preferenser->int_preferens_i_intervall(
96 1
			$this->andel_2_min,
97 1
			0,
98 1
			13,
99 1
			2,
100 1
			'andel.andel_2_min'
101 1
		);
102
103 1
		$this->db_preferenser->int_preferens_i_intervall(
104 1
			$this->andel_2_max,
105 1
			0,
106 1
			13,
107 1
			7,
108 1
			'andel.andel_2_max'
109 1
		);
110
111
		/**
112
		 * Jämför andelar.
113
		 */
114 1
		$this->db_preferenser->int_komparera_preferenser(
115 1
			$this->andel_1_min,
116 1
			$this->andel_1_max,
117 1
			3,
118 1
			8,
119 1
			'andel.andel_1_min',
120 1
			'andel.andel_1_max'
121 1
		);
122
123 1
		$this->db_preferenser->int_komparera_preferenser(
124 1
			$this->andel_x_min,
125 1
			$this->andel_x_max,
126 1
			1,
127 1
			6,
128 1
			'andel.andel_x_min',
129 1
			'andel.andel_x_max'
130 1
		);
131
132 1
		$this->db_preferenser->int_komparera_preferenser(
133 1
			$this->andel_2_min,
134 1
			$this->andel_2_max,
135 1
			2,
136 1
			7,
137 1
			'andel.andel_2_min',
138 1
			'andel.andel_2_max'
139 1
		);
140
	}
141
}
142