Code Duplication    Length = 23-23 lines in 2 locations

src/Calculator/Helpers.php 2 locations

@@ 21-43 (lines=23) @@
18
     * @param  float $trainer the level of the the trainer
19
     * @return int   dusts to max the pokemon
20
     */
21
    public static function dustsToMax(float $pokemon, float $trainer)
22
    {
23
        $trainer += 1.5;
24
        $loop = $pokemon;
25
        $dusts = 0;
26
27
        $levels = (new LevelExtractor())
28
            ->getIntervalLevelFiltered($pokemon, $trainer);
29
30
        $levels
31
            ->each(function ($level) use (&$dusts, &$loop, $trainer) {
32
                $loop += 0.5;
33
                $dusts += $level->dust * 2;
34
            });
35
36
        if ($pokemon*2 % 2 === 1) {
37
            $dusts -= $levels->first()->dust;
38
        }
39
40
        $dusts -= $levels->last()->dust;
41
42
        return $dusts;
43
    }
44
45
    /**
46
     * Method to calculate how many candies are necessary to max a pokemon
@@ 51-73 (lines=23) @@
48
     * @param  float $trainer the level of the the trainer
49
     * @return int   dusts to max the pokemon
50
     */
51
    public static function candiesToMax(float $pokemon, float $trainer)
52
    {
53
        $trainer += 1.5;
54
        $loop = $pokemon;
55
        $candies = 0;
56
57
        $levels = (new LevelExtractor())
58
            ->getIntervalLevelFiltered($pokemon, $trainer);
59
60
        $levels
61
            ->each(function ($level) use (&$candies, &$loop, $trainer) {
62
                $loop += 0.5;
63
                $candies += $level->candy * 2;
64
            });
65
66
        if ($pokemon*2 % 2 === 1) {
67
            $candies -= $levels->first()->candy;
68
        }
69
70
        $candies -= $levels->last()->candy;
71
72
        return $candies;
73
    }
74
}
75