GridResultatVinstrader::vinstrader()   A
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 37
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 6.0038

Importance

Changes 0
Metric Value
cc 6
eloc 19
nc 8
nop 0
dl 0
loc 37
ccs 20
cts 21
cp 0.9524
crap 6.0038
rs 9.0111
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass GridResultatVinstrader.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Klasser\Omgang;
11
12
/**
13
 * Klass GridResultatVinstrader.
14
 */
15
class GridResultatVinstrader extends GridResultatModuler {
16
	/**
17
	 * Visa eventuella vinstrader.
18
	 */
19 1
	protected function vinstrader(): string {
20 1
		if (!$this->spelad) {
21
			return '';
22
		}
23
24 1
		$vinstrader = t(7, "<code><strong>{$this->tips->utdelning->tipsrad}</strong></code><br>");
25
26
		/**
27
		 * Iterera över spelade tipsrader.
28
		 */
29 1
		foreach ($this->tips->spelade->tipsvektor as $index => $tipsvektor) {
30 1
			$rad = '';
31 1
			foreach (str_split(siffror_till_symboler($tipsvektor)) as $k => $rad_1x2) {
32 1
				$rad .= $rad_1x2 === $this->tips->utdelning->tipsrad[$k] ?
33 1
					$rad_1x2 : '<span class="ickevinst">' . $rad_1x2 . '</span>';
34
			}
35
36 1
			$rätt = antal_rätt($tipsvektor, $this->tips->utdelning->tipsrad_012);
37 1
			$this->rättvektor[$rätt]++;
38
39
			/**
40
			 * Välj ut rader med antal rätt i vinstgrupp 10–13.
41
			 */
42 1
			if ($rätt >= 10) {
43 1
				$this->vinst += $this->tips->utdelning->utdelning[MATCHANTAL - $rätt];
44 1
				$stil = match ($rätt) {
45 1
					13 => ['<strong><span class="vinstrad">', '</span></strong>'],
46 1
					12 => ['<strong>', '</strong>'],
47 1
					11 => ['<em>', '</em>'],
48 1
					default => ['', '']
49 1
				};
50
51 1
				$vinstrader .= t(7, "<code>{$stil[0]}$rad ($rätt r) (# $index){$stil[1]}</code><br>");
52
			}
53
		}
54
55 1
		return $vinstrader;
56
	}
57
}
58