Conditions | 12 |
Paths | 84 |
Total Lines | 109 |
Code Lines | 80 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
70 | private function doPartijen(Worksheet $ws): int |
||
71 | { |
||
72 | $saring = explode("\n", $this->trn['PARINGEN']); |
||
73 | $s = $this->trn['PLAYERSNOID']; |
||
74 | $g = $this->trn['RONDEGAMES']; |
||
75 | $KD = $this->trn['KALENDERDATA']; |
||
76 | $si = $this->trn['PLAYERSIDS']; |
||
77 | |||
78 | $a = [ |
||
79 | ['Wit', null, null, null, 'Zwart', null, null, null, 'Wit', 'Uitslag', 'Zwart', 'Opmerking', 'Datum'], |
||
80 | ['Winstpunten', 'Weerstandspunten', 'punten', 'Tegenpunten', 'Winstpunten', 'Weerstandspunten', 'punten', 'Tegenpunten'], |
||
81 | |||
82 | ]; |
||
83 | $ws->fromArray($a, null, 'A1'); |
||
84 | |||
85 | $ws->getStyle('A1:L1')->applyFromArray(self::STYLEBOLD); |
||
86 | $ws->getStyle('A1:L1')->applyFromArray(self::STYLESIZE14); |
||
87 | |||
88 | $lijn = 1; |
||
89 | for ($i = 1; $i <= $this->trn['RONDEN']; ++$i) {//aantal ronden oneven->heen en even->terug |
||
90 | $countSaring = count($saring); |
||
91 | for ($j = 0; $j < $countSaring; ++$j) {//subronden |
||
92 | ++$lijn; |
||
93 | if (isset($KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j], $KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j]['RONDE'])) { |
||
94 | $ws->setCellValue([9, $lijn], $KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j]['RONDE']); |
||
95 | } else { |
||
96 | $ws->setCellValue([9, $lijn], 'Kalenderdata zijn niet(volledig) ingevuld'); |
||
97 | } |
||
98 | if (isset($KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j], $KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j]['TXT'])) { |
||
99 | $ws->setCellValue([10, $lijn], $KD[(($i - 1) * $this->trn['SUB_RONDEN']) + $j]['TXT']); |
||
100 | } else { |
||
101 | $ws->setCellValue([10, $lijn], 'Kalenderdata zijn niet(volledig) ingevuld'); |
||
102 | } |
||
103 | |||
104 | $ws->getStyle('A' . $lijn . ':L' . $lijn . '')->applyFromArray(self::STYLEBOLD14); |
||
105 | |||
106 | $s2 = explode(' ', $saring[$j]); |
||
107 | $counts2 = count($s2); |
||
108 | for ($k = 0; $k < $counts2; ++$k) {//borden |
||
109 | if (trim($s2[$k]) == '') { |
||
110 | continue; |
||
111 | } |
||
112 | $s3 = explode('-', $s2[$k]); //wit-zwart |
||
113 | $s3[0] = (int) $s3[0]; |
||
114 | $s3[1] = (int) $s3[1]; |
||
115 | ++$lijn; |
||
116 | $ws->setCellValue([1, $lijn], '=IF(SUBSTITUTE(TRIM($J' . $lijn . '),"-","")="","",XLOOKUP($K' . $lijn . ',Spelers!$B$2:$B$' . (count($s) + 1) . ',Spelers!$C$2:$C$' . (count($s) + 1) . ',FALSE) * VLOOKUP(J' . $lijn . ', PuntenLijst,4,FALSE))'); |
||
117 | $ws->setCellValue([2, $lijn], '=IF(SUBSTITUTE(TRIM($J' . $lijn . '),"-","")="","",VLOOKUP($K' . $lijn . ',Spelers!$B$2:$D$' . (count($s) + 1) . ',3,FALSE) * VLOOKUP(J' . $lijn . ', PuntenLijst,5,FALSE))'); |
||
118 | $ws->setCellValue([3, $lijn], '=IF(TRIM($J' . $lijn . ')="","",XLOOKUP($J' . $lijn . ', Punten!$A$2:$A$50,Punten!$B$2:$B$50,0,0))'); |
||
119 | $ws->setCellValue([4, $lijn], '=IF(TRIM($J' . $lijn . ')="","",XLOOKUP($J' . $lijn . ', Punten!$A$2:$A$50,Punten!$G$2:$G$50,0,0))'); |
||
120 | |||
121 | $ws->setCellValue([5, $lijn], '=IF(SUBSTITUTE(TRIM($J' . $lijn . '),"-","")="","",VLOOKUP($I' . $lijn . ',Spelers!$B$2:$D$' . (count($s) + 1) . ',3,FALSE) * VLOOKUP(J' . $lijn . ', PuntenLijst,6,FALSE))'); |
||
122 | $ws->setCellValue([6, $lijn], '=IF(SUBSTITUTE(TRIM($J' . $lijn . '),"-","")="","",VLOOKUP($I' . $lijn . ',Spelers!$B$2:$D$' . (count($s) + 1) . ',3,FALSE) * VLOOKUP(J' . $lijn . ', PuntenLijst,5,FALSE))'); |
||
123 | $ws->setCellValue([7, $lijn], '=IF(TRIM($J' . $lijn . ')="","",XLOOKUP($J' . $lijn . ', Punten!$A$2:$A$50,Punten!$C$2:$C$50,0,0))'); |
||
124 | $ws->setCellValue([8, $lijn], '=IF(TRIM($J' . $lijn . ')="","",XLOOKUP($J' . $lijn . ', Punten!$A$2:$A$50,Punten!$H$2:$H$50,0,0))'); |
||
125 | |||
126 | if ($this->odd($i)) { |
||
127 | if ( |
||
128 | isset($g[$i][$si[((int) $s3[0]) - 1]][$si[((int) $s3[1]) - 1]]) |
||
129 | ) { |
||
130 | $pw = $g[$i][$si[((int) $s3[0]) - 1]][$si[((int) $s3[1]) - 1]]; |
||
131 | } else { |
||
132 | $pw = ['SYMBOOLWIT' => '', 'SYMBOOLZWART' => '', 'UITSLAG' => '', 'OPMERKING' => '', 'DATUM' => '']; |
||
133 | } |
||
134 | $ws->setCellValue([9, $lijn], '=Spelers!$B$' . ($s3[0] + 1)); |
||
135 | $ws->setCellValue([11, $lijn], '=Spelers!$B$' . ($s3[1] + 1)); |
||
136 | } else { |
||
137 | if ( |
||
138 | isset($g[$i][$si[((int) $s3[1]) - 1]][$si[((int) $s3[0]) - 1]]) |
||
139 | ) { |
||
140 | $pw = $g[$i][$si[((int) $s3[1]) - 1]][$si[((int) $s3[0]) - 1]]; |
||
141 | } else { |
||
142 | $pw = ['SYMBOOLWIT' => '', 'SYMBOOLZWART' => '', 'UITSLAG' => '', 'OPMERKING' => '', 'DATUM' => '']; |
||
143 | } |
||
144 | $ws->setCellValue([9, $lijn], '=Spelers!$B$' . ($s3[1] + 1)); |
||
145 | $ws->setCellValue([11, $lijn], '=Spelers!$B$' . ($s3[0] + 1)); |
||
146 | } |
||
147 | if ($pw['SYMBOOLWIT'] != '') { |
||
148 | $ws->setCellValue([10, $lijn], $pw['SYMBOOLWIT'] . '-' . $pw['SYMBOOLZWART']); |
||
149 | } |
||
150 | $ws->setCellValue([13, $lijn], $pw['OPMERKING']); |
||
151 | $ws->setCellValue([14, $lijn], $pw['DATUM']); |
||
152 | |||
153 | $this->doValidationPunten($ws, 'J' . $lijn); |
||
154 | |||
155 | $ws->getRowDimension($lijn)->setOutlineLevel(1); |
||
156 | } |
||
157 | ++$lijn; |
||
158 | } |
||
159 | ++$lijn; |
||
160 | } |
||
161 | $ws->getStyle('J1:J' . $lijn)->applyFromArray(self::STYLECENTER); |
||
162 | |||
163 | $ws->getColumnDimension('A')->setVisible(false); |
||
164 | $ws->getColumnDimension('B')->setVisible(false); |
||
165 | $ws->getColumnDimension('C')->setVisible(false); |
||
166 | $ws->getColumnDimension('D')->setVisible(false); |
||
167 | $ws->getColumnDimension('E')->setVisible(false); |
||
168 | $ws->getColumnDimension('F')->setVisible(false); |
||
169 | $ws->getColumnDimension('G')->setVisible(false); |
||
170 | $ws->getColumnDimension('H')->setVisible(false); |
||
171 | |||
172 | for ($i = 65; $i < ord('M'); ++$i) { |
||
173 | $ws->getColumnDimension(chr($i))->setAutoSize(true); |
||
174 | } |
||
175 | $ws->setAutoFilter('A2:M' . $lijn); |
||
176 | $ws->setSelectedCell('A1'); |
||
177 | |||
178 | return $lijn; |
||
179 | } |
||
305 |