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

Rita::rita()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass Rita.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\Vinstgraf;
11
12
use Tips\Klasser\Graf;
13
use Tips\Klasser\DBPreferenser;
14
use Tips\Klasser\Utdelning;
15
use Tips\Klasser\Prediktioner;
16
use Tips\Klasser\Matcher;
17
18
/**
19
 * Klass Rita.
20
 */
21
class Rita {
22
	use Konstanter;
23
24
	protected Graf $graf;
25
	protected DBPreferenser $db_preferenser;
26
	public int $utdelning_13_min = self::UTDELNING_13_MIN_STD;
27
	public int $utdelning_13_max = self::UTDELNING_13_MAX_STD;
28
29 1
	public function __construct(
30
		protected Utdelning $utdelning,
31
		protected Prediktioner $odds,
32
		protected Prediktioner $streck,
33
		protected Matcher $matcher
34
	) {
35 1
		$this->db_preferenser = new DBPreferenser($this->utdelning->spel->db);
36 1
		$this->graf = new Graf();
37 1
		$this->utdelning_13_min = (int) $this->db_preferenser->hämta_preferens('vinstgraf.utdelning_13_min');
38 1
		$this->utdelning_13_max = (int) $this->db_preferenser->hämta_preferens('vinstgraf.utdelning_13_max');
39
	}
40
41
	/**
42
	 * Rita punkt för vinstrad i projicerat koordinatsystem.
43
	 * Högvinst i rött eler blått, övriga i gul nyans.
44
	 */
45
	protected function rita(string $tipsrad_012, int $utdelning): void {
46
		[$x, $y] = $this->graf->tipsgrafskoordinater($tipsrad_012);
47
		$färg = match (true) {
48
			$utdelning >= self::UTDELNING_13_MIN_MAX => $this->graf->blå,
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Vinstgraf\Rita::UTDELNING_13_MIN_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
49
			$utdelning >= $this->utdelning_13_max => $this->graf->röd,
50
			default => $this->graf->gul
51
		};
52
		$this->graf->sätt_pixel($x, $y, $färg);
53
	}
54
}
55