Code Duplication    Length = 21-21 lines in 2 locations

src/MapHandler.php 2 locations

@@ 115-135 (lines=21) @@
112
        return true;
113
    }
114
115
    public function setTypeDefaultExtension($type, $extension)
116
    {
117
        $type = strtolower($type);
118
        $extension = strtolower($extension);
119
120
        if (!isset($this->map['types'][$type])) {
121
            throw new MappingException('Cannot set ' . $extension . ' as default extension for type ' . $type . ', type not defined');
122
        }
123
        $key = array_search($extension, $this->map['types'][$type]);
124
        if ($key === false) {
125
            throw new MappingException('Cannot set ' . $extension . ' as default extension for type ' . $type . ', extension not associated to this type');
126
        }
127
        $tmp = [$extension];
128
        foreach ($this->map['types'][$type] as $k => $v) {
129
            if ($k === $key) {
130
                continue;
131
            }
132
            $tmp[] = $v;
133
        }
134
        $this->map['types'][$type] = $tmp;
135
    }
136
137
    public function setExtensionDefaultType($extension, $type)
138
    {
@@ 137-157 (lines=21) @@
134
        $this->map['types'][$type] = $tmp;
135
    }
136
137
    public function setExtensionDefaultType($extension, $type)
138
    {
139
        $type = strtolower($type);
140
        $extension = strtolower($extension);
141
142
        if (!isset($this->map['extensions'][$extension])) {
143
            throw new MappingException('Cannot set ' . $type . ' as default type for extension ' . $extension . ', extension not defined');
144
        }
145
        $key = array_search($type, $this->map['extensions'][$extension]);
146
        if ($key === false) {
147
            throw new MappingException('Cannot set ' . $type . ' as default type for extension ' . $extension . ', type not associated to this extension');
148
        }
149
        $tmp = [$type];
150
        foreach ($this->map['extensions'][$extension] as $k => $v) {
151
            if ($k === $key) {
152
                continue;
153
            }
154
            $tmp[] = $v;
155
        }
156
        $this->map['extensions'][$extension] = $tmp;
157
    }
158
}
159