Passed
Push — main ( 9152fd...203f91 )
by N.
03:37
created

Oddstabellrad::oddstabellrad()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 25
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 9
dl 0
loc 39
ccs 25
cts 25
cp 1
crap 1
rs 9.52
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
 * Klass Oddstabellrad.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\TT;
11
12
use Tips\Moduler\TT;
13
14
/**
15
 * Klass Oddstabellrad.
16
 * För topptipset.
17
 */
18
final class Oddstabellrad {
19
	/**
20
	 * Initiera.
21
	 */
22 1
	public function __construct(protected TT $tt) {
23 1
	}
24
25
	/**
26
	 * Tabellrad för prediktionsdata.
27
	 * @param string[] $teckenfördelning
28
	 * @param string[] $formaterad_dist
29
	 * @param int[] $tix
30
	 * @param string[] $odds
31
	 * @param string[] $oddsstil
32
	 * @param string[] $streckstil
33
	 */
34 1
	public function oddstabellrad(
35
		int $index,
36
		string $sorteringsstil,
37
		array $teckenfördelning,
38
		array $formaterad_dist,
39
		string $odds_finns,
40
		array $tix,
41
		array $odds,
42
		array $oddsstil,
43
		array $streckstil
44
	): string {
45 1
		$matchindex = $index + 1;
46
47
		/**
48
		 * SKicka till TT\Matchtabeller.
49
		 */
50 1
		return <<< EOT
51 1
								<tr>
52 1
									<td class="match höger">$matchindex</td>
53 1
									<td{$teckenfördelning[0]}>{$formaterad_dist[0]}</td>
54 1
									<td{$teckenfördelning[1]}>{$formaterad_dist[1]}</td>
55 1
									<td{$teckenfördelning[2]}>{$formaterad_dist[2]}</td>
56 1
									<td$sorteringsstil class="vänster">{$this->tt->hemmalag[$index]} – {$this->tt->bortalag[$index]}</td>
57 1
									<td class="input$odds_finns"><input class="oddskolumn" tabindex="{$tix[3 * $index]}" type="text" name="tt_odds[$index][]" size="2" maxlength="5" value="{$odds[0]}"></td>
58 1
									<td class="input$odds_finns"><input class="oddskolumn" tabindex="{$tix[3 * $index + 1]}" type="text" name="tt_odds[$index][]" size="2" maxlength="5" value="{$odds[1]}"></td>
59 1
									<td class="input$odds_finns"><input class="oddskolumn" tabindex="{$tix[3 * $index + 2]}" type="text" name="tt_odds[$index][]" size="2" maxlength="5" value="{$odds[2]}"></td>
60 1
									{$oddsstil[0]}
61 1
									{$oddsstil[1]}
62 1
									{$oddsstil[2]}
63 1
									<td class="höger">{$this->tt->tt_streck[$index][0]}</td>
64 1
									<td class="höger">{$this->tt->tt_streck[$index][1]}</td>
65 1
									<td class="höger">{$this->tt->tt_streck[$index][2]}</td>
66 1
									{$streckstil[0]}
67 1
									{$streckstil[1]}
68 1
									{$streckstil[2]}
69 1
									<td class="höger">{$this->tt->utfallshistorik[$index][0]}</td>
70 1
									<td class="höger">{$this->tt->utfallshistorik[$index][1]}</td>
71 1
									<td class="höger">{$this->tt->utfallshistorik[$index][2]}</td>
72 1
									<td class="höger vinst10">{$this->tt->utfallshistorik[$index][3]}</td>
73
								</tr>
74
75 1
EOT;
76
	}
77
}
78