Code Duplication    Length = 13-15 lines in 2 locations

src/helpers/ChargeSort.php 1 location

@@ 33-47 (lines=15) @@
30
            ->asc(self::keepDiscountsWithParents());
31
    }
32
33
    private static function byHardwareType(): \Closure
34
    {
35
        $order = ['SERVER', 'CHASSIS', 'MOTHERBOARD', 'CPU', 'RAM', 'HDD', 'SSD'];
36
37
        return function (Charge $charge) use ($order) {
38
            if ($charge->class === 'part') {
39
                $type = substr($charge->name, 0, strpos($charge->name, ':'));
40
                if (($key = array_search($type, $order, true)) !== false) {
41
                    return $key;
42
                }
43
            }
44
45
            return INF;
46
        };
47
    }
48
49
    private static function byType(): \Closure
50
    {

src/helpers/PriceSort.php 1 location

@@ 96-108 (lines=13) @@
93
        };
94
    }
95
96
    private static function byHardwareType(): \Closure
97
    {
98
        $order = ['SERVER', 'CHASSIS', 'MOTHERBOARD', 'CPU', 'RAM', 'HDD', 'SSD'];
99
100
        return function (Price $price) use ($order) {
101
            $type = substr($price->object->name, 0, strpos($price->object->name, ':'));
102
            if (($key = array_search($type, $order, true)) !== false) {
103
                return $key;
104
            }
105
106
            return INF;
107
        };
108
    }
109
110
    private static function byTargetObjectName(): \Closure
111
    {