Code Duplication    Length = 21-21 lines in 2 locations

src/commands/Search/Filter/SubfiltersProducer.php 2 locations

@@ 58-78 (lines=21) @@
55
            : $this->produceAsSeparateClass($filter);
56
    }
57
58
    private function produceAsGeneric(FilterInterface $filter): array
59
    {
60
        $type = $filter->type();
61
        if (!isset($this->constantsMap[$type])) {
62
            return [];
63
        }
64
65
        $result = [];
66
        foreach ($this->constantsMap[$type] as $suffix => $newType) {
67
            $attributeName = $filter->name() . $suffix;
68
69
            if (is_array($newType)) {
70
                $className = array_shift($newType);
71
                $result[] = new $className($attributeName, $newType[0]);
72
            } else {
73
                $result[] = GenericFilter::__callStatic($newType, [$attributeName]);
74
            }
75
        }
76
77
        return $result;
78
    }
79
80
    private function produceAsSeparateClass(FilterInterface $filter): array
81
    {
@@ 80-100 (lines=21) @@
77
        return $result;
78
    }
79
80
    private function produceAsSeparateClass(FilterInterface $filter): array
81
    {
82
        $type = get_class($filter);
83
        if (!isset($this->map[$type])) {
84
            return [];
85
        }
86
87
        $result = [];
88
        foreach ($this->map[$type] as $suffix => $newType) {
89
            $attributeName = $filter->name() . $suffix;
90
91
            if (is_array($newType)) {
92
                $className = array_shift($newType);
93
                $result[] = new $className($attributeName, $newType[0]);
94
            } else {
95
                $result[] = new $newType($attributeName);
96
            }
97
        }
98
99
        return $result;
100
    }
101
}
102