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

Prova::pröva_tipsrad()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
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\Egenskaper\Tick;
13
14
/**
15
 * Klass Andel.
16
 */
17
class Prova extends Preferenser {
18
	use Tick;
19
20
	/**
21
	 * Pröva tipsrad.
22
	 */
23
	public function pröva_tipsrad(string $tipsrad_012): bool {
24
		return $this->pröva_andelar($this->teckenfördelning($tipsrad_012)) || $this->tick();
25
	}
26
27
	/**
28
	 * Pröva andelar.
29
	 * @param int[] $vektor
30
	 */
31
	protected function pröva_andelar(array $vektor): bool {
32
		return in($vektor[0], $this->andel_1_min, $this->andel_1_max) &&
33
			in($vektor[1], $this->andel_x_min, $this->andel_x_max) &&
34
			in($vektor[2], $this->andel_2_min, $this->andel_2_max);
35
	}
36
37
	/**
38
	 * Teckenfördelning.
39
	 * @return int[]
40
	 */
41
	protected function teckenfördelning(string $tipsrad_012): array {
42
		return [substr_count($tipsrad_012, '0'), substr_count($tipsrad_012, '1'), substr_count($tipsrad_012, '2')];
43
	}
44
45
	/**
46
	 * Annonsera modul.
47
	 */
48
	public function annonsera(): string {
49
		return "1: {$this->andel_1_min}–{$this->andel_1_max}, X: {$this->andel_x_min}–{$this->andel_x_max}, 2: {$this->andel_2_min}–{$this->andel_2_max} " .
50
			$this->attraktionsfaktor($this->attraktionsfaktor, 'andel_attraktionsfaktor');
51
	}
52
}
53