Code Duplication    Length = 11-14 lines in 2 locations

src/Admin/Traits/Mapper.php 2 locations

@@ 141-151 (lines=11) @@
138
                            $mapper->remove($key);
139
140
                            // compensating the partial removal in Sonata Admin, that does not touch the groups when removing a field
141
                            if ($mapper instanceof BaseGroupedMapper) {
142
                                foreach ($groups = $this->{$fcts['groups']['getter']}() as $groupkey => $group) {
143
                                    if (isset($group['fields'][$key])) {
144
                                        unset($groups[$groupkey]['fields'][$key]);
145
                                        if (!$groups[$groupkey]['fields']) {
146
                                            unset($groups[$groupkey]);
147
                                        }
148
                                        $this->{$fcts['groups']['setter']}($groups);
149
                                    }
150
                                }
151
                            }
152
                        }
153
                    }
154
                }
@@ 196-209 (lines=14) @@
193
194
            // removing empty tabs
195
            $tabs = $this->{$fcts['tabs']['getter']}();
196
            if (is_array($tabs)) {
197
                foreach ($tabs as $tabkey => $tab) {
198
                    foreach ($tab['groups'] as $groupkey => $group) {
199
                        if (!isset($this->{$fcts['groups']['getter']}()[$group])) {
200
                            unset($tabs[$tabkey]['groups'][$groupkey]);
201
                        }
202
                    }
203
204
                    if (!$tabs[$tabkey]['groups']) {
205
                        unset($tabs[$tabkey]);
206
                    }
207
                }
208
                $this->{$fcts['tabs']['setter']}($tabs);
209
            }
210
        }
211
212
        $this->fixTemplates($mapper);