Code Duplication    Length = 20-20 lines in 2 locations

src/PhpSpreadsheet/IOFactory.php 2 locations

@@ 114-133 (lines=20) @@
111
     * @throws    Writer\Exception
112
     * @return    Writer\IWriter
113
     */
114
    public static function createWriter(Spreadsheet $spreadsheet, $writerType = '')
115
    {
116
        // Search type
117
        $searchType = 'IWriter';
118
119
        // Include class
120
        foreach (self::$searchLocations as $searchLocation) {
121
            if ($searchLocation['type'] == $searchType) {
122
                $className = str_replace('{0}', $writerType, $searchLocation['class']);
123
124
                $instance = new $className($spreadsheet);
125
                if ($instance !== null) {
126
                    return $instance;
127
                }
128
            }
129
        }
130
131
        // Nothing found...
132
        throw new Writer\Exception("No $searchType found for type $writerType");
133
    }
134
135
    /**
136
     * Create Reader\IReader
@@ 143-162 (lines=20) @@
140
     * @throws    Reader\Exception
141
     * @return    Reader\IReader
142
     */
143
    public static function createReader($readerType = '')
144
    {
145
        // Search type
146
        $searchType = 'IReader';
147
148
        // Include class
149
        foreach (self::$searchLocations as $searchLocation) {
150
            if ($searchLocation['type'] == $searchType) {
151
                $className = str_replace('{0}', $readerType, $searchLocation['class']);
152
153
                $instance = new $className();
154
                if ($instance !== null) {
155
                    return $instance;
156
                }
157
            }
158
        }
159
160
        // Nothing found...
161
        throw new Reader\Exception("No $searchType found for type $readerType");
162
    }
163
164
    /**
165
     * Loads Spreadsheet from file using automatic Reader\IReader resolution