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

Prova::pröva_andelar()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 4
ccs 4
cts 4
cp 1
crap 3
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 1
	public function pröva_tipsrad(string $tipsrad_012): bool {
24 1
		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 1
	protected function pröva_andelar(array $vektor): bool {
32 1
		return in($vektor[0], $this->andel_1_min, $this->andel_1_max) &&
33 1
			in($vektor[1], $this->andel_x_min, $this->andel_x_max) &&
34 1
			in($vektor[2], $this->andel_2_min, $this->andel_2_max);
35
	}
36
37
	/**
38
	 * Teckenfördelning.
39
	 * @return int[]
40
	 */
41 1
	protected function teckenfördelning(string $tipsrad_012): array {
42 1
		return [substr_count($tipsrad_012, '0'), substr_count($tipsrad_012, '1'), substr_count($tipsrad_012, '2')];
43
	}
44
45
	/**
46
	 * Annonsera modul.
47
	 */
48 1
	public function annonsera(): string {
49 1
		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 1
			$this->attraktionsfaktor($this->attraktionsfaktor, 'andel_attraktionsfaktor');
51
	}
52
}
53