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

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