Code Duplication    Length = 20-20 lines in 2 locations

src/PhpSpreadsheet/IOFactory.php 2 locations

@@ 96-115 (lines=20) @@
93
     *
94
     * @return Writer\IWriter
95
     */
96
    public static function createWriter(Spreadsheet $spreadsheet, $writerType)
97
    {
98
        // Search type
99
        $searchType = 'IWriter';
100
101
        // Include class
102
        foreach (self::$searchLocations as $searchLocation) {
103
            if ($searchLocation['type'] == $searchType) {
104
                $className = str_replace('{0}', $writerType, $searchLocation['class']);
105
106
                $instance = new $className($spreadsheet);
107
                if ($instance !== null) {
108
                    return $instance;
109
                }
110
            }
111
        }
112
113
        // Nothing found...
114
        throw new Writer\Exception("No $searchType found for type $writerType");
115
    }
116
117
    /**
118
     * Create Reader\IReader.
@@ 128-147 (lines=20) @@
125
     *
126
     * @return Reader\IReader
127
     */
128
    public static function createReader($readerType)
129
    {
130
        // Search type
131
        $searchType = 'IReader';
132
133
        // Include class
134
        foreach (self::$searchLocations as $searchLocation) {
135
            if ($searchLocation['type'] == $searchType) {
136
                $className = str_replace('{0}', $readerType, $searchLocation['class']);
137
138
                $instance = new $className();
139
                if ($instance !== null) {
140
                    return $instance;
141
                }
142
            }
143
        }
144
145
        // Nothing found...
146
        throw new Reader\Exception("No $searchType found for type $readerType");
147
    }
148
149
    /**
150
     * Loads Spreadsheet from file using automatic Reader\IReader resolution.