1 | <?php |
||
13 | abstract class IOFactory |
||
14 | { |
||
15 | private static $readers = [ |
||
16 | 'Xlsx' => Reader\Xlsx::class, |
||
17 | 'Xls' => Reader\Xls::class, |
||
18 | 'Xml' => Reader\Xml::class, |
||
19 | 'Ods' => Reader\Ods::class, |
||
20 | 'Slk' => Reader\Slk::class, |
||
21 | 'Gnumeric' => Reader\Gnumeric::class, |
||
22 | 'Html' => Reader\Html::class, |
||
23 | 'Csv' => Reader\Csv::class, |
||
24 | ]; |
||
25 | |||
26 | private static $writers = [ |
||
27 | 'Xls' => Writer\Xls::class, |
||
28 | 'Xlsx' => Writer\Xlsx::class, |
||
29 | 'Ods' => Writer\Ods::class, |
||
30 | 'Csv' => Writer\Csv::class, |
||
31 | 'Html' => Writer\Html::class, |
||
32 | 'Tcpdf' => Writer\Pdf\Tcpdf::class, |
||
33 | 'Dompdf' => Writer\Pdf\Dompdf::class, |
||
34 | 'Mpdf' => Writer\Pdf\Mpdf::class, |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Create Writer\IWriter. |
||
39 | * |
||
40 | * @param Spreadsheet $spreadsheet |
||
41 | * @param string $writerType Example: Xlsx |
||
42 | * |
||
43 | * @throws Writer\Exception |
||
44 | * |
||
45 | * @return Writer\IWriter |
||
46 | */ |
||
47 | 69 | public static function createWriter(Spreadsheet $spreadsheet, $writerType) |
|
59 | |||
60 | /** |
||
61 | * Create Reader\IReader. |
||
62 | * |
||
63 | * @param string $readerType Example: Xlsx |
||
64 | * |
||
65 | * @throws Reader\Exception |
||
66 | * |
||
67 | * @return Reader\IReader |
||
68 | */ |
||
69 | 63 | public static function createReader($readerType) |
|
81 | |||
82 | /** |
||
83 | * Loads Spreadsheet from file using automatic Reader\IReader resolution. |
||
84 | * |
||
85 | * @param string $pFilename The name of the spreadsheet file |
||
86 | * |
||
87 | * @throws Reader\Exception |
||
88 | * |
||
89 | * @return Spreadsheet |
||
90 | */ |
||
91 | 11 | public static function load($pFilename) |
|
97 | |||
98 | /** |
||
99 | * Identify file type using automatic Reader\IReader resolution. |
||
100 | * |
||
101 | * @param string $pFilename The name of the spreadsheet file to identify |
||
102 | * |
||
103 | * @throws Reader\Exception |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 11 | public static function identify($pFilename) |
|
116 | |||
117 | /** |
||
118 | * Create Reader\IReader for file using automatic Reader\IReader resolution. |
||
119 | * |
||
120 | * @param string $filename The name of the spreadsheet file |
||
121 | * |
||
122 | * @throws Reader\Exception |
||
123 | * |
||
124 | * @return Reader\IReader |
||
125 | */ |
||
126 | 29 | public static function createReaderForFile($filename) |
|
155 | |||
156 | /** |
||
157 | * Guess a reader type from the file extension, if any. |
||
158 | * |
||
159 | * @param string $filename |
||
160 | * |
||
161 | * @return null|string |
||
162 | */ |
||
163 | 26 | private static function getReaderTypeFromExtension($filename) |
|
200 | |||
201 | /** |
||
202 | * Register a writer with its type and class name. |
||
203 | * |
||
204 | * @param string $writerType |
||
205 | * @param string $writerClass |
||
206 | */ |
||
207 | 7 | public static function registerWriter($writerType, $writerClass) |
|
215 | |||
216 | /** |
||
217 | * Register a reader with its type and class name. |
||
218 | * |
||
219 | * @param string $readerType |
||
220 | * @param string $readerClass |
||
221 | */ |
||
222 | 2 | public static function registerReader($readerType, $readerClass) |
|
230 | } |
||
231 |