| Conditions | 1 |
| Paths | 1 |
| Total Lines | 93 |
| Code Lines | 77 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 23 | public function testCreateObject(): void |
||
| 24 | { |
||
| 25 | new Preludium(); |
||
| 26 | |||
| 27 | $odds = [ |
||
| 28 | [3.3, 3.6, 2.15], |
||
| 29 | [2.2, 3.65, 2.55], |
||
| 30 | [1.79, 4.35, 4.76], |
||
| 31 | [1.74, 3.9, 3.65], |
||
| 32 | [1.45, 4.4, 5.4], |
||
| 33 | [2.25, 3.25, 3], |
||
| 34 | [4.1, 3.45, 1.81], |
||
| 35 | [7, 4.75, 1.36], |
||
| 36 | [1.48, 4.6, 5.1], |
||
| 37 | [1.28, 5.6, 10], |
||
| 38 | [1.42, 4.75, 6.5], |
||
| 39 | [4.5, 4.1, 1.67], |
||
| 40 | [1.33, 5.2, 8.5] |
||
| 41 | ]; |
||
| 42 | |||
| 43 | $sannolikheter = [ |
||
| 44 | [0.28972487366647953, 0.26558113419427287, 0.4446939921392476], |
||
| 45 | [0.40559973853360926, 0.2444710752805316, 0.349929186185859], |
||
| 46 | [0.5594265783010788, 0.23020082187561636, 0.21037259982330483], |
||
| 47 | [0.5200569925471284, 0.2320254274441035, 0.2479175800087681], |
||
| 48 | [0.625757176718462, 0.20621543323676586, 0.16802739004477218], |
||
| 49 | [0.4094488188976378, 0.2834645669291339, 0.30708661417322836], |
||
| 50 | [0.22453749483108898, 0.26684166052390285, 0.5086208446450081], |
||
| 51 | [0.13122080032500508, 0.19337802153158642, 0.6754011781434085], |
||
| 52 | [0.6203723291728369, 0.19959805373386927, 0.18002961709329388], |
||
| 53 | [0.7371524852569502, 0.16849199663016004, 0.09435551811288963], |
||
| 54 | [0.6590181430096052, 0.19701173959445034, 0.1439701173959445], |
||
| 55 | [0.20867365597951965, 0.22903206144093624, 0.5622942825795441], |
||
| 56 | [0.7080950321206004, 0.1811089216769997, 0.11079604620239984] |
||
| 57 | ]; |
||
| 58 | |||
| 59 | $this->assertEquals(odds_till_sannolikheter($odds), $sannolikheter); |
||
| 60 | |||
| 61 | $streck = [ |
||
| 62 | [30, 27, 43], |
||
| 63 | [44, 27, 29], |
||
| 64 | [59, 23, 18], |
||
| 65 | [43, 25, 32], |
||
| 66 | [70, 17, 13], |
||
| 67 | [47, 27, 26], |
||
| 68 | [27, 28, 45], |
||
| 69 | [18, 21, 61], |
||
| 70 | [55, 24, 21], |
||
| 71 | [75, 15, 10], |
||
| 72 | [69, 19, 12], |
||
| 73 | [26, 29, 45], |
||
| 74 | [76, 15, 9] |
||
| 75 | ]; |
||
| 76 | |||
| 77 | $streck_sannolikheter = [ |
||
| 78 | [0.3, 0.27, 0.43], |
||
| 79 | [0.44, 0.27, 0.29], |
||
| 80 | [0.59, 0.23, 0.18], |
||
| 81 | [0.43, 0.25, 0.32], |
||
| 82 | [0.7, 0.17, 0.13], |
||
| 83 | [0.47, 0.27, 0.26], |
||
| 84 | [0.27, 0.28, 0.45], |
||
| 85 | [0.18, 0.21, 0.61], |
||
| 86 | [0.55, 0.24, 0.21], |
||
| 87 | [0.75, 0.15, 0.1], |
||
| 88 | [0.69, 0.19, 0.12], |
||
| 89 | [0.26, 0.29, 0.45], |
||
| 90 | [0.76, 0.15, 0.09] |
||
| 91 | ]; |
||
| 92 | |||
| 93 | $this->assertEquals(streck_till_sannolikheter($streck), $streck_sannolikheter); |
||
| 94 | |||
| 95 | $streckodds = [ |
||
| 96 | [3.3333333333333335, 3.7037037037037033, 2.3255813953488373], |
||
| 97 | [2.272727272727273, 3.7037037037037033, 3.4482758620689657], |
||
| 98 | [1.6949152542372883, 4.3478260869565215, 5.555555555555555], |
||
| 99 | [2.3255813953488373, 4.0, 3.125], |
||
| 100 | [1.4285714285714286, 5.88235294117647, 7.692307692307692], |
||
| 101 | [2.127659574468085, 3.7037037037037033, 3.846153846153846], |
||
| 102 | [3.7037037037037033, 3.571428571428571, 2.2222222222222223], |
||
| 103 | [5.555555555555555, 4.761904761904762, 1.639344262295082], |
||
| 104 | [1.8181818181818181, 4.166666666666667, 4.761904761904762], |
||
| 105 | [1.3333333333333333, 6.666666666666667, 10.0], |
||
| 106 | [1.4492753623188408, 5.2631578947368425, 8.333333333333334], |
||
| 107 | [3.846153846153846, 3.4482758620689657, 2.2222222222222223], |
||
| 108 | [1.3157894736842106, 6.666666666666667, 11.11111111111111] |
||
| 109 | ]; |
||
| 110 | |||
| 111 | $this->assertEquals(sannolikheter_till_odds($streck_sannolikheter), $streckodds); |
||
| 112 | |||
| 113 | $this->assertEquals( |
||
| 114 | formatera_sannolikheter(odds_till_sannolikheter($streckodds)), |
||
| 115 | formatera_sannolikheter($streck_sannolikheter) |
||
| 116 | ); |
||
| 119 |