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

Prova::annonsera()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 6
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass Prova.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\Distribution;
11
12
use Tips\Egenskaper\Tick;
13
14
/**
15
 * Klass Prova.
16
 */
17
class Prova extends Historik {
18
	use Tick;
19
20
	/**
21
	 * Pröva tipsrad.
22
	 */
23 2
	public function pröva_tipsrad(string $tipsrad_012): bool {
24 2
		$this->beräkna_sannolikhetssummor($tipsrad_012);
25 2
		return in($this->oddssumma, $this->minsumma, $this->maxsumma) || $this->tick();
26
	}
27
28
	/**
29
	 * Beräkna sannolikhetssummor.
30
	 */
31 2
	public function beräkna_sannolikhetssummor(string $tipsrad_012): void {
32 2
		$this->oddssumma = ($tipsrad_012 === '') ? 0.00 : array_sum(
33 2
			array_map(
34 2
				fn (array $odds, string $tecken): float => $odds[$tecken],
35 2
				$this->odds->sannolikheter,
36 2
				str_split($tipsrad_012)
0 ignored issues
show
Bug introduced by
It seems like str_split($tipsrad_012) can also be of type true; however, parameter $arrays of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
				/** @scrutinizer ignore-type */ str_split($tipsrad_012)
Loading history...
37 2
			)
38 2
		);
39
	}
40
41
	/**
42
	 * Annonsera modul.
43
	 */
44 2
	public function annonsera(): string {
45 2
		$distval = <<< EOT
46 2
<input class="nummer_litet" type="number" min="0" autocomplete="off" id="distribution_minprocent_ext" value="{$this->minprocent}">–<input class="nummer_litet" type="number" min="0" autocomplete="off" id="distribution_maxprocent_ext" value="{$this->maxprocent}">% <button class="distribution_schema" value="[0.1, 2]">0.1–2</button> <button class="distribution_schema" value="[0.1, 3]">0.1–3</button> <button class="distribution_schema" value="[0.1, 5]">0.1–5</button> <button class="distribution_schema" value="[0.1, 10]">0.1–10</button>
47 2
EOT;
48 2
		return round($this->procentandel, 1) . ' ' .
49 2
			$this->attraktionsfaktor($this->attraktionsfaktor, 'distribution_attraktionsfaktor') . $distval;
50
	}
51
52
	/**
53
	 * Rendera kommentar.
54
	 */
55 1
	public function kommentar(): string {
56 1
		return self::class . " {$this->minprocent}–{$this->maxprocent} | a={$this->attraktionsfaktor}";
57
	}
58
}
59