Completed
Push — develop ( 3851aa...435d68 )
by Adrien
21:08
created

Migrator::migrate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 9
cp 0
crap 6
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Helper;
4
5
class Migrator
6
{
7
    /**
8
     * Return the ordered mapping from old PHPExcel class names to new PhpSpreadsheet one
9
     * @return string[]
10
     */
11 1
    public function getMapping()
12
    {
13
        // Order matters here, we should have the deepest namespaces first (the most "unique" strings)
14
        $mapping = [
15 1
            'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE\\Blip',
16
            'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer\\SpContainer',
17
            'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE',
18
            'PHPExcel_Shared_Escher_DgContainer_SpgrContainer' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer\\SpgrContainer',
19
            'PHPExcel_Shared_Escher_DggContainer_BstoreContainer' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer\\BstoreContainer',
20
            'PHPExcel_Shared_OLE_PPS_File' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\File',
21
            'PHPExcel_Shared_OLE_PPS_Root' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS\\Root',
22
            'PHPExcel_Worksheet_AutoFilter_Column_Rule' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column\\Rule',
23
            'PHPExcel_Writer_OpenDocument_Cell_Comment' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Cell\\Comment',
24
            'PHPExcel_Calculation_Token_Stack' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack',
25
            'PHPExcel_Chart_Renderer_jpgraph' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Renderer\\JpGraph',
26
            'PHPExcel_Reader_Excel5_Escher' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\Escher',
27
            'PHPExcel_Reader_Excel5_MD5' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\MD5',
28
            'PHPExcel_Reader_Excel5_RC4' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xls\\RC4',
29
            'PHPExcel_Reader_Excel2007_Chart' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Chart',
30
            'PHPExcel_Reader_Excel2007_Theme' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx\\Theme',
31
            'PHPExcel_Shared_Escher_DgContainer' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DgContainer',
32
            'PHPExcel_Shared_Escher_DggContainer' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher\\DggContainer',
33
            'CholeskyDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\CholeskyDecomposition',
34
            'EigenvalueDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\EigenvalueDecomposition',
35
            'PHPExcel_Shared_JAMA_LUDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\LUDecomposition',
36
            'PHPExcel_Shared_JAMA_Matrix' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\Matrix',
37
            'QRDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition',
38
            'PHPExcel_Shared_JAMA_QRDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\QRDecomposition',
39
            'SingularValueDecomposition' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\JAMA\\SingularValueDecomposition',
40
            'PHPExcel_Shared_OLE_ChainedBlockStream' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\ChainedBlockStream',
41
            'PHPExcel_Shared_OLE_PPS' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLE\\PPS',
42
            'PclZip' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\PCLZip\\PclZip',
43
            'PHPExcel_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\BestFit',
44
            'PHPExcel_Exponential_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\ExponentialBestFit',
45
            'PHPExcel_Linear_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LinearBestFit',
46
            'PHPExcel_Logarithmic_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\LogarithmicBestFit',
47
            'polynomialBestFit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit',
48
            'PHPExcel_Polynomial_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PolynomialBestFit',
49
            'powerBestFit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit',
50
            'PHPExcel_Power_Best_Fit' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\PowerBestFit',
51
            'trendClass' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\Trend',
52
            'PHPExcel_Worksheet_AutoFilter_Column' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter\\Column',
53
            'PHPExcel_Worksheet_Drawing_Shadow' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing\\Shadow',
54
            'PHPExcel_Writer_OpenDocument_Content' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Content',
55
            'PHPExcel_Writer_OpenDocument_Meta' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Meta',
56
            'PHPExcel_Writer_OpenDocument_MetaInf' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\MetaInf',
57
            'PHPExcel_Writer_OpenDocument_Mimetype' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Mimetype',
58
            'PHPExcel_Writer_OpenDocument_Settings' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Settings',
59
            'PHPExcel_Writer_OpenDocument_Styles' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Styles',
60
            'PHPExcel_Writer_OpenDocument_Thumbnails' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\Thumbnails',
61
            'PHPExcel_Writer_OpenDocument_WriterPart' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods\\WriterPart',
62
            'PHPExcel_Writer_PDF_Core' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\PDF\\Core',
63
            'PHPExcel_Writer_PDF_DomPDF' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\PDF\\DomPDF',
64
            'PHPExcel_Writer_PDF_mPDF' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\PDF\\MPDF',
65
            'PHPExcel_Writer_PDF_tcPDF' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\PDF\\TcPDF',
66
            'PHPExcel_Writer_Excel5_BIFFwriter' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\BIFFwriter',
67
            'PHPExcel_Writer_Excel5_Escher' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Escher',
68
            'PHPExcel_Writer_Excel5_Font' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Font',
69
            'PHPExcel_Writer_Excel5_Parser' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Parser',
70
            'PHPExcel_Writer_Excel5_Workbook' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Workbook',
71
            'PHPExcel_Writer_Excel5_Worksheet' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Worksheet',
72
            'PHPExcel_Writer_Excel5_Xf' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls\\Xf',
73
            'PHPExcel_Writer_Excel2007_Chart' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Chart',
74
            'PHPExcel_Writer_Excel2007_Comments' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Comments',
75
            'PHPExcel_Writer_Excel2007_ContentTypes' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\ContentTypes',
76
            'PHPExcel_Writer_Excel2007_DocProps' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\DocProps',
77
            'PHPExcel_Writer_Excel2007_Drawing' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Drawing',
78
            'PHPExcel_Writer_Excel2007_Rels' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Rels',
79
            'PHPExcel_Writer_Excel2007_RelsRibbon' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsRibbon',
80
            'PHPExcel_Writer_Excel2007_RelsVBA' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsVBA',
81
            'PHPExcel_Writer_Excel2007_StringTable' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\StringTable',
82
            'PHPExcel_Writer_Excel2007_Style' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Style',
83
            'PHPExcel_Writer_Excel2007_Theme' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Theme',
84
            'PHPExcel_Writer_Excel2007_Workbook' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Workbook',
85
            'PHPExcel_Writer_Excel2007_Worksheet' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Worksheet',
86
            'PHPExcel_Writer_Excel2007_WriterPart' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\WriterPart',
87
            'PHPExcel_CachedObjectStorage_APC' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\APC',
88
            'PHPExcel_CachedObjectStorage_CacheBase' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\CacheBase',
89
            'PHPExcel_CachedObjectStorage_DiscISAM' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\DiscISAM',
90
            'PHPExcel_CachedObjectStorage_ICache' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\ICache',
91
            'PHPExcel_CachedObjectStorage_Igbinary' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\Igbinary',
92
            'PHPExcel_CachedObjectStorage_Memcache' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\Memcache',
93
            'PHPExcel_CachedObjectStorage_Memory' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\Memory',
94
            'PHPExcel_CachedObjectStorage_MemoryGZip' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\MemoryGZip',
95
            'PHPExcel_CachedObjectStorage_MemorySerialized' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\MemorySerialized',
96
            'PHPExcel_CachedObjectStorage_PHPTemp' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\PHPTemp',
97
            'PHPExcel_CachedObjectStorage_SQLite' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\SQLite',
98
            'PHPExcel_CachedObjectStorage_SQLite3' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\SQLite3',
99
            'PHPExcel_CachedObjectStorage_Wincache' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorage\\Wincache',
100
            'PHPExcel_CalcEngine_CyclicReferenceStack' => '\\PhpOffice\\PhpSpreadsheet\\CalcEngine\\CyclicReferenceStack',
101
            'PHPExcel_CalcEngine_Logger' => '\\PhpOffice\\PhpSpreadsheet\\CalcEngine\\Logger',
102
            'PHPExcel_Calculation_Functions' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Functions',
103
            'PHPExcel_Calculation_Function' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Categories',
104
            'PHPExcel_Calculation_Database' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Database',
105
            'PHPExcel_Calculation_DateTime' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\DateTime',
106
            'PHPExcel_Calculation_Engineering' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Engineering',
107
            'PHPExcel_Calculation_Exception' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Exception',
108
            'PHPExcel_Calculation_ExceptionHandler' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\ExceptionHandler',
109
            'PHPExcel_Calculation_Financial' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Financial',
110
            'PHPExcel_Calculation_FormulaParser' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaParser',
111
            'PHPExcel_Calculation_FormulaToken' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\FormulaToken',
112
            'PHPExcel_Calculation_Logical' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Logical',
113
            'PHPExcel_Calculation_LookupRef' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef',
114
            'PHPExcel_Calculation_MathTrig' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\MathTrig',
115
            'PHPExcel_Calculation_Statistical' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical',
116
            'PHPExcel_Calculation_TextData' => '\\PhpOffice\\PhpSpreadsheet\\Calculation\\TextData',
117
            'PHPExcel_Cell_AdvancedValueBinder' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\AdvancedValueBinder',
118
            'PHPExcel_Cell_DataType' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\DataType',
119
            'PHPExcel_Cell_DataValidation' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\DataValidation',
120
            'PHPExcel_Cell_DefaultValueBinder' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder',
121
            'PHPExcel_Cell_Hyperlink' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\Hyperlink',
122
            'PHPExcel_Cell_IValueBinder' => '\\PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder',
123
            'PHPExcel_Chart_Axis' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Axis',
124
            'PHPExcel_Chart_DataSeries' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\DataSeries',
125
            'PHPExcel_Chart_DataSeriesValues' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\DataSeriesValues',
126
            'PHPExcel_Chart_Exception' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Exception',
127
            'PHPExcel_Chart_GridLines' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\GridLines',
128
            'PHPExcel_Chart_Layout' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Layout',
129
            'PHPExcel_Chart_Legend' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Legend',
130
            'PHPExcel_Chart_PlotArea' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\PlotArea',
131
            'PHPExcel_Properties' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Properties',
132
            'PHPExcel_Chart_Title' => '\\PhpOffice\\PhpSpreadsheet\\Chart\\Title',
133
            'PHPExcel_DocumentProperties' => '\\PhpOffice\\PhpSpreadsheet\\Document\\Properties',
134
            'PHPExcel_DocumentSecurity' => '\\PhpOffice\\PhpSpreadsheet\\Document\\Security',
135
            'PHPExcel_Helper_HTML' => '\\PhpOffice\\PhpSpreadsheet\\Helper\\HTML',
136
            'PHPExcel_Reader_Abstract' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\BaseReader',
137
            'PHPExcel_Reader_CSV' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\CSV',
138
            'PHPExcel_Reader_DefaultReadFilter' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\DefaultReadFilter',
139
            'PHPExcel_Reader_Excel2003XML' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Excel2003XML',
140
            'PHPExcel_Reader_Exception' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Exception',
141
            'PHPExcel_Reader_Gnumeric' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric',
142
            'PHPExcel_Reader_HTML' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\HTML',
143
            'PHPExcel_Reader_IReadFilter' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\IReadFilter',
144
            'PHPExcel_Reader_IReader' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\IReader',
145
            'PHPExcel_Reader_OOCalc' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Ods',
146
            'PHPExcel_Reader_SYLK' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\SYLK',
147
            'PHPExcel_Reader_Excel5' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xls',
148
            'PHPExcel_Reader_Excel2007' => '\\PhpOffice\\PhpSpreadsheet\\Reader\\Xlsx',
149
            'PHPExcel_RichText_ITextElement' => '\\PhpOffice\\PhpSpreadsheet\\RichText\\ITextElement',
150
            'PHPExcel_RichText_Run' => '\\PhpOffice\\PhpSpreadsheet\\RichText\\Run',
151
            'PHPExcel_RichText_TextElement' => '\\PhpOffice\\PhpSpreadsheet\\RichText\\TextElement',
152
            'PHPExcel_Shared_CodePage' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\CodePage',
153
            'PHPExcel_Shared_Date' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Date',
154
            'PHPExcel_Shared_Drawing' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Drawing',
155
            'PHPExcel_Shared_Escher' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Escher',
156
            'PHPExcel_Shared_File' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\File',
157
            'PHPExcel_Shared_Font' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Font',
158
            'PHPExcel_Shared_OLE' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLE',
159
            'PHPExcel_Shared_OLERead' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\OLERead',
160
            'PHPExcel_Shared_PasswordHasher' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\PasswordHasher',
161
            'PHPExcel_Shared_String' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\StringHelper',
162
            'PHPExcel_Shared_TimeZone' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\TimeZone',
163
            'PHPExcel_Shared_XMLWriter' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\XMLWriter',
164
            'PHPExcel_Shared_Excel5' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\Xls',
165
            'PHPExcel_Shared_ZipArchive' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\ZipArchive',
166
            'PHPExcel_Shared_ZipStreamWrapper' => '\\PhpOffice\\PhpSpreadsheet\\Shared\\ZipStreamWrapper',
167
            'PHPExcel_Style_Alignment' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Alignment',
168
            'PHPExcel_Style_Border' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Border',
169
            'PHPExcel_Style_Borders' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Borders',
170
            'PHPExcel_Style_Color' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Color',
171
            'PHPExcel_Style_Conditional' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Conditional',
172
            'PHPExcel_Style_Fill' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Fill',
173
            'PHPExcel_Style_Font' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Font',
174
            'PHPExcel_Style_NumberFormat' => '\\PhpOffice\\PhpSpreadsheet\\Style\\NumberFormat',
175
            'PHPExcel_Style_Protection' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Protection',
176
            'PHPExcel_Style_Supervisor' => '\\PhpOffice\\PhpSpreadsheet\\Style\\Supervisor',
177
            'PHPExcel_Worksheet_AutoFilter' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\AutoFilter',
178
            'PHPExcel_Worksheet_BaseDrawing' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\BaseDrawing',
179
            'PHPExcel_Worksheet_CellIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\CellIterator',
180
            'PHPExcel_Worksheet_Column' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Column',
181
            'PHPExcel_Worksheet_ColumnCellIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnCellIterator',
182
            'PHPExcel_Worksheet_ColumnDimension' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnDimension',
183
            'PHPExcel_Worksheet_ColumnIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\ColumnIterator',
184
            'PHPExcel_Worksheet_Drawing' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Drawing',
185
            'PHPExcel_Worksheet_HeaderFooter' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooter',
186
            'PHPExcel_Worksheet_HeaderFooterDrawing' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\HeaderFooterDrawing',
187
            'PHPExcel_WorksheetIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Iterator',
188
            'PHPExcel_Worksheet_MemoryDrawing' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\MemoryDrawing',
189
            'PHPExcel_Worksheet_PageMargins' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\PageMargins',
190
            'PHPExcel_Worksheet_PageSetup' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\PageSetup',
191
            'PHPExcel_Worksheet_Protection' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Protection',
192
            'PHPExcel_Worksheet_Row' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\Row',
193
            'PHPExcel_Worksheet_RowCellIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\RowCellIterator',
194
            'PHPExcel_Worksheet_RowDimension' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\RowDimension',
195
            'PHPExcel_Worksheet_RowIterator' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\RowIterator',
196
            'PHPExcel_Worksheet_SheetView' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet\\SheetView',
197
            'PHPExcel_Writer_Abstract' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\BaseWriter',
198
            'PHPExcel_Writer_CSV' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\CSV',
199
            'PHPExcel_Writer_Exception' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Exception',
200
            'PHPExcel_Writer_HTML' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\HTML',
201
            'PHPExcel_Writer_IWriter' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\IWriter',
202
            'PHPExcel_Writer_OpenDocument' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Ods',
203
            'PHPExcel_Writer_PDF' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\PDF',
204
            'PHPExcel_Writer_Excel5' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xls',
205
            'PHPExcel_Writer_Excel2007' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx',
206
            'PHPExcel_Autoloader' => '\\PhpOffice\\PhpSpreadsheet\\Autoloader',
207
            'PHPExcel_CachedObjectStorageFactory' => '\\PhpOffice\\PhpSpreadsheet\\CachedObjectStorageFactory',
208
            'PHPExcel_Calculation' => '\\PhpOffice\\PhpSpreadsheet\\Calculation',
209
            'PHPExcel_Cell' => '\\PhpOffice\\PhpSpreadsheet\\Cell',
210
            'PHPExcel_Chart' => '\\PhpOffice\\PhpSpreadsheet\\Chart',
211
            'PHPExcel_Comment' => '\\PhpOffice\\PhpSpreadsheet\\Comment',
212
            'PHPExcel_Exception' => '\\PhpOffice\\PhpSpreadsheet\\Exception',
213
            'PHPExcel_HashTable' => '\\PhpOffice\\PhpSpreadsheet\\HashTable',
214
            'PHPExcel_IComparable' => '\\PhpOffice\\PhpSpreadsheet\\IComparable',
215
            'PHPExcel_IOFactory' => '\\PhpOffice\\PhpSpreadsheet\\IOFactory',
216
            'PHPExcel_NamedRange' => '\\PhpOffice\\PhpSpreadsheet\\NamedRange',
217
            'PHPExcel_ReferenceHelper' => '\\PhpOffice\\PhpSpreadsheet\\ReferenceHelper',
218
            'PHPExcel_RichText' => '\\PhpOffice\\PhpSpreadsheet\\RichText',
219
            'PHPExcel_Settings' => '\\PhpOffice\\PhpSpreadsheet\\Settings',
220
            'PHPExcel_Style' => '\\PhpOffice\\PhpSpreadsheet\\Style',
221
            'PHPExcel_Worksheet' => '\\PhpOffice\\PhpSpreadsheet\\Worksheet',
222
            'PHPExcel' => '\\PhpOffice\\PhpSpreadsheet\\Spreadsheet',
223
            // methods
224
            'MINUTEOFHOUR' => 'MINUTE',
225
            'SECONDOFMINUTE' => 'SECOND',
226
            'DAYOFWEEK' => 'WEEKDAY',
227
            'WEEKOFYEAR' => 'WEEKNUM',
228
        ];
229
230 1
        return $mapping;
231
    }
232
233
    /**
234
     * Search in all files in given directory
235
     * @param string $path
236
     */
237
    private function recursiveReplace($path)
238
    {
239
        $patterns = [
240
            '/*.md',
241
            '/*.php',
242
            '/*.txt',
243
            '/*.TXT',
244
        ];
245
246
        $from = array_keys($this->getMapping());
247
        $to = array_values($this->getMapping());
248
249
        foreach ($patterns as $pattern) {
250
            foreach (glob($path . $pattern) as $file) {
251
                $original = file_get_contents($file);
252
                $converted = str_replace($from, $to, $original);
253
254
                if ($original !== $converted) {
255
                    echo $file . " converted\n";
256
                    file_put_contents($file, $converted);
257
                }
258
            }
259
        }
260
261
        // Do the recursion in subdirectory
262
        foreach (glob($path . '/*', GLOB_ONLYDIR) as $subpath) {
263
            if (strpos($subpath, $path . '/') === 0) {
264
                $this->recursiveReplace($subpath);
265
            }
266
        }
267
    }
268
269
    public function migrate()
270
    {
271
        $path = realpath(getcwd());
272
        echo 'This will search and replace recursively in ' . $path . PHP_EOL;
273
        echo 'You MUST backup your files first, or you risk losing data.' . PHP_EOL;
274
        echo 'Are you sure ? (y/n)';
275
276
        $confirm = fread(STDIN, 1);
277
        if ($confirm === 'y') {
278
            $this->recursiveReplace($path);
279
        }
280
    }
281
}
282