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

@@ 106-118 (lines=13) @@
103
        };
104
    }
105
106
    private static function byHardwareType(): Closure
107
    {
108
        $order = ['SERVER', 'CHASSIS', 'MOTHERBOARD', 'CPU', 'RAM', 'HDD', 'SSD'];
109
110
        return function (Price $price) use ($order) {
111
            $type = substr($price->object->name, 0, strpos($price->object->name, ':'));
112
            if (($key = array_search($type, $order, true)) !== false) {
113
                return $key;
114
            }
115
116
            return INF;
117
        };
118
    }
119
120
    private static function byTargetObjectName(): Closure
121
    {