Passed
Push — main ( a92fbe...d29be2 )
by N.
05:41 queued 01:24
created

Prova   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 38.1%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 53
ccs 8
cts 21
cp 0.381
rs 10
c 0
b 0
f 0
wmc 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A pröva_teckenintervall() 0 7 3
A pröva_täckningskod() 0 2 1
A pröva_oddsintervall() 0 2 1
A __construct() 0 1 1
A pröva_spikar() 0 9 3
A pröva_reduktion() 0 2 1
1
<?php
2
3
/**
4
 * Klass Prova.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\TT\TTGridGenerera;
11
12
use Tips\Moduler\TT;
13
use Tips\Moduler\TT\TTReduceradKod;
14
15
/**
16
 * Klass Prova.
17
 */
18
class Prova {
19
	/** @var string[] $täckningskod */ public array $täckningskod;
20
	protected TTReduceradKod $tt_reducerad_kod;
21
22
	public function __construct(protected TT $tt) {
23
	}
24
25
	/**
26
	 * Pröva reduktion.
27
	 */
28 1
	protected function pröva_reduktion(string $tipsrad_012): bool {
29 1
		return isset($this->tt_reducerad_kod->reducerad_kod[$this->tt_reducerad_kod->reducera_kodord($tipsrad_012)]);
30
	}
31
32
	/**
33
	 * Pröva täckningsgrad.
34
	 */
35
	protected function pröva_täckningskod(string $tipsrad_012): bool {
36
		return in_array($tipsrad_012, $this->täckningskod, true);
37
	}
38
39
	/**
40
	 * Pröva spikar.
41
	 */
42
	/** @param array<int, array<int, string|null>> $spikar */
43 1
	protected function pröva_spikar(array $spikar, int $andel_spikar, string $tipsrad_012): bool {
44 1
		$andel_spikade = 0;
45 1
		foreach ($spikar as $i => $s) {
46 1
			if ($s[(int) $tipsrad_012[$i]] > '') {
47 1
				$andel_spikade++;
48
			}
49
		}
50
51 1
		return $andel_spikade >= $andel_spikar;
52
	}
53
54
	/**
55
	 * Pröva teckenintervall.
56
	 */
57
	protected function pröva_teckenintervall(string $tipsrad_012): bool {
58
		$antal_1 = substr_count($tipsrad_012, '0');
59
		$antal_X = substr_count($tipsrad_012, '1');
60
		$antal_2 = substr_count($tipsrad_012, '2');
61
		return in($antal_1, $this->tt->antal_1_min, $this->tt->antal_1_max) &&
62
			in($antal_X, $this->tt->antal_X_min, $this->tt->antal_X_max) &&
63
			in($antal_2, $this->tt->antal_2_min, $this->tt->antal_2_max);
64
	}
65
66
	/**
67
	 * Pröva oddsintervall.
68
	 */
69
	protected function pröva_oddsintervall(string $tipsrad_012): bool {
70
		return in(antal_rätt($tipsrad_012, $this->tt->enkelrad_012), $this->tt->odds_rätt_min, $this->tt->odds_rätt_max);
71
	}
72
}
73