Passed
Push — develop ( c09191...4b5082 )
by nguereza
02:18
created

Path::isAbsolutePath()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 14
rs 10
1
<?php
2
3
/**
4
 * Platine Stdlib
5
 *
6
 * Platine Stdlib is a the collection of frequently used php features
7
 *
8
 * This content is released under the MIT License (MIT)
9
 *
10
 * Copyright (c) 2020 Platine Stdlib
11
 *
12
 * Permission is hereby granted, free of charge, to any person obtaining a copy
13
 * of this software and associated documentation files (the "Software"), to deal
14
 * in the Software without restriction, including without limitation the rights
15
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the Software is
17
 * furnished to do so, subject to the following conditions:
18
 *
19
 * The above copyright notice and this permission notice shall be included in all
20
 * copies or substantial portions of the Software.
21
 *
22
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
 * SOFTWARE.
29
 */
30
31
/**
32
 *  @file Path.php
33
 *
34
 *  The Path (File System, directory, file, etc.) helper class
35
 *
36
 *  @package    Platine\Stdlib\Helper
37
 *  @author Platine Developers Team
38
 *  @copyright  Copyright (c) 2020
39
 *  @license    http://opensource.org/licenses/MIT  MIT License
40
 *  @link   http://www.iacademy.cf
41
 *  @version 1.0.0
42
 *  @filesource
43
 */
44
45
declare(strict_types=1);
46
47
namespace Platine\Stdlib\Helper;
48
49
use InvalidArgumentException;
50
51
/**
52
 * Class Path
53
 * @package Platine\Stdlib\Helper
54
 */
55
class Path
56
{
57
58
    /**
59
     * normalize the path by replace the "\" to "/"
60
     * @param string $path
61
     * @param bool $suffix
62
     * @return string
63
     */
64
    public static function normalizePath(string $path, bool $suffix = false): string
65
    {
66
        return str_replace('\\', '/', $path) . ($suffix ? '/' : '');
67
    }
68
69
    /**
70
     * normalize the path by replace the "\", "/" to DIRECTORY_SEPARATOR value
71
     * @param string $path
72
     * @param bool $suffix
73
     * @return string
74
     */
75
    public static function normalizePathDS(string $path, bool $suffix = false): string
76
    {
77
        return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path)
78
                . ($suffix ? DIRECTORY_SEPARATOR : '');
79
    }
80
81
    /**
82
     * Whether the given path is an absolute path
83
     * @param string $path
84
     * @return bool
85
     */
86
    public static function isAbsolutePath(string $path): bool
87
    {
88
        if (!$path) {
89
            return false;
90
        }
91
92
        if (
93
            strpos($path, '/') === 0 //Linux/Mac
94
            || preg_match('#^[a-z]:[\/|\\\]{1}.+#i', $path) === 1 //Windows
95
        ) {
96
            return true;
97
        }
98
99
        return false;
100
    }
101
102
    /**
103
     * Return the real path for the given path
104
     * @param string $path
105
     * @return string
106
     */
107
    public static function realPath(string $path): string
108
    {
109
        $normalizedPath = self::normalizePathDS($path, false);
110
        $realPath = realpath($normalizedPath);
111
        if ($realPath === false) {
112
            throw new InvalidArgumentException(sprintf(
113
                'Path [%s] does not exists',
114
                $normalizedPath
115
            ));
116
        }
117
118
        return self::normalizePathDS($realPath, false);
119
    }
120
121
    /**
122
     * Returns canonicalized absolute pathname
123
     * Convert 'this/is/../a/./test/.///is' to 'this/a/test/is'
124
     *
125
     * @param string $path
126
     * @param bool $filter
127
     * @return string
128
     */
129
    public static function convert2Absolute(string $path, bool $filter = true): string
130
    {
131
        $normalizedPath = static::normalizePath($path);
132
        if (strpos($normalizedPath, '..') === false) {
133
            return $normalizedPath;
134
        }
135
136
        $first = '';
137
        $parts = explode('/', $normalizedPath);
138
139
        if ($filter) {
140
            $first = $normalizedPath[0] === '/' ? '/' : '';
141
            $parts = array_filter($parts);
142
        }
143
144
        $absolutes = [];
145
        foreach ($parts as $part) {
146
            if ($part === '.') {
147
                continue;
148
            }
149
150
            if ($part === '..') {
151
                array_pop($absolutes);
152
            } else {
153
                $absolutes[] = $part;
154
            }
155
        }
156
157
        return $first . implode('/', $absolutes);
158
    }
159
160
    /**
161
     * Return the mime type for the given extension
162
     * @param string $extension
163
     * @return string
164
     */
165
    public static function getMimeByExtension(string $extension): string
166
    {
167
        $mimes = self::getMimes();
168
169
        return $mimes[$extension] ?? 'text/plain';
170
    }
171
172
    /**
173
     *  List of mime type
174
     * @return array<string, string>
175
     */
176
    private static function getMimes(): array
177
    {
178
        return  [
179
            '3dm' => 'x-world/x-3dmf',
180
            '3dmf' => 'x-world/x-3dmf',
181
            'a' => 'application/octet-stream',
182
            'aab' => 'application/x-authorware-bin',
183
            'aam' => 'application/x-authorware-map',
184
            'aas' => 'application/x-authorware-seg',
185
            'abc' => 'text/vnd.abc',
186
            'acgi' => 'text/html',
187
            'afl' => 'video/animaflex',
188
            'ai' => 'application/postscript',
189
            'aif' => 'audio/aiff',
190
            'aifc' => 'audio/aiff',
191
            'aiff' => 'audio/aiff',
192
            'aim' => 'application/x-aim',
193
            'aip' => 'text/x-audiosoft-intra',
194
            'ani' => 'application/x-navi-animation',
195
            'aos' => 'application/x-nokia-9000-communicator-add-on-software',
196
            'aps' => 'application/mime',
197
            'arc' => 'application/octet-stream',
198
            'arj' => 'application/octet-stream',
199
            'art' => 'image/x-jg',
200
            'asf' => 'video/x-ms-asf',
201
            'asm' => 'text/x-asm',
202
            'asp' => 'text/asp',
203
            'asx' => 'video/x-ms-asf',
204
            'au' => 'audio/x-au',
205
            'avi' => 'video/avi',
206
            'avs' => 'video/avs-video',
207
            'bcpio' => 'application/x-bcpio',
208
            'bin' => 'application/octet-stream',
209
            'bm' => 'image/bmp',
210
            'bmp' => 'image/bmp',
211
            'boo' => 'application/book',
212
            'book' => 'application/book',
213
            'boz' => 'application/x-bzip2',
214
            'bsh' => 'application/x-bsh',
215
            'bz' => 'application/x-bzip',
216
            'bz2' => 'application/x-bzip2',
217
            'c' => 'text/plain',
218
            'c++' => 'text/plain',
219
            'cat' => 'application/vnd.ms-pki.seccat',
220
            'cc' => 'text/plain',
221
            'ccad' => 'application/clariscad',
222
            'cco' => 'application/x-cocoa',
223
            'cdf' => 'application/cdf',
224
            'cer' => 'application/pkix-cert',
225
            'cha' => 'application/x-chat',
226
            'chat' => 'application/x-chat',
227
            'class' => 'application/java',
228
            'com' => 'application/octet-stream',
229
            'conf' => 'text/plain',
230
            'cpio' => 'application/x-cpio',
231
            'cpp' => 'text/x-c',
232
            'cpt' => 'application/x-cpt',
233
            'crl' => 'application/pkcs-crl',
234
            'crt' => 'application/pkix-cert',
235
            'csh' => 'application/x-csh',
236
            'css' => 'text/css',
237
            'cxx' => 'text/plain',
238
            'dcr' => 'application/x-director',
239
            'deepv' => 'application/x-deepv',
240
            'def' => 'text/plain',
241
            'der' => 'application/x-x509-ca-cert',
242
            'dif' => 'video/x-dv',
243
            'dir' => 'application/x-director',
244
            'dl' => 'video/dl',
245
            'doc' => 'application/msword',
246
            'docx'  => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
247
            'dot' => 'application/msword',
248
            'dp' => 'application/commonground',
249
            'drw' => 'application/drafting',
250
            'dump' => 'application/octet-stream',
251
            'dv' => 'video/x-dv',
252
            'dvi' => 'application/x-dvi',
253
            'dwf' => 'drawing/x-dwf (old)',
254
            'dwg' => 'image/x-dwg',
255
            'dxf' => 'application/dxf',
256
            'dxr' => 'application/x-director',
257
            'el' => 'text/x-script.elisp',
258
            'elc' => 'application/x-elc',
259
            'env' => 'application/x-envoy',
260
            'eps' => 'application/postscript',
261
            'es' => 'application/x-esrehber',
262
            'etx' => 'text/x-setext',
263
            'evy' => 'application/envoy',
264
            'exe' => 'application/octet-stream',
265
            'f' => 'text/plain',
266
            'f77' => 'text/x-fortran',
267
            'f90' => 'text/plain',
268
            'fdf' => 'application/vnd.fdf',
269
            'fif' => 'image/fif',
270
            'fli' => 'video/fli',
271
            'flo' => 'image/florian',
272
            'flx' => 'text/vnd.fmi.flexstor',
273
            'fmf' => 'video/x-atomic3d-feature',
274
            'for' => 'text/plain',
275
            'fpx' => 'image/vnd.fpx',
276
            'frl' => 'application/freeloader',
277
            'funk' => 'audio/make',
278
            'g' => 'text/plain',
279
            'g3' => 'image/g3fax',
280
            'gif' => 'image/gif',
281
            'gl' => 'video/gl',
282
            'gsd' => 'audio/x-gsm',
283
            'gsm' => 'audio/x-gsm',
284
            'gsp' => 'application/x-gsp',
285
            'gss' => 'application/x-gss',
286
            'gtar' => 'application/x-gtar',
287
            'gz' => 'application/x-gzip',
288
            'gzip' => 'application/x-gzip',
289
            'h' => 'text/plain',
290
            'hdf' => 'application/x-hdf',
291
            'help' => 'application/x-helpfile',
292
            'hgl' => 'application/vnd.hp-hpgl',
293
            'hh' => 'text/plain',
294
            'hlb' => 'text/x-script',
295
            'hlp' => 'application/hlp',
296
            'hpg' => 'application/vnd.hp-hpgl',
297
            'hpgl' => 'application/vnd.hp-hpgl',
298
            'hqx' => 'application/binhex',
299
            'hta' => 'application/hta',
300
            'htc' => 'text/x-component',
301
            'htm' => 'text/html',
302
            'html' => 'text/html',
303
            'htmls' => 'text/html',
304
            'htt' => 'text/webviewhtml',
305
            'htx' => 'text/html',
306
            'ice' => 'x-conference/x-cooltalk',
307
            'ico' => 'image/x-icon',
308
            'idc' => 'text/plain',
309
            'ief' => 'image/ief',
310
            'iefs' => 'image/ief',
311
            'iges' => 'application/iges',
312
            'igs' => 'application/iges',
313
            'ima' => 'application/x-ima',
314
            'imap' => 'application/x-httpd-imap',
315
            'inf' => 'application/inf',
316
            'ins' => 'application/x-internett-signup',
317
            'ip' => 'application/x-ip2',
318
            'isu' => 'video/x-isvideo',
319
            'it' => 'audio/it',
320
            'iv' => 'application/x-inventor',
321
            'ivr' => 'i-world/i-vrml',
322
            'ivy' => 'application/x-livescreen',
323
            'jam' => 'audio/x-jam',
324
            'jav' => 'text/plain',
325
            'java' => 'text/plain',
326
            'jcm' => 'application/x-java-commerce',
327
            'jfif' => 'image/jpeg',
328
            'jfif-tbnl' => 'image/jpeg',
329
            'jpe' => 'image/jpeg',
330
            'jpeg' => 'image/jpeg',
331
            'jpg' => 'image/jpeg',
332
            'jps' => 'image/x-jps',
333
            'js' => 'text/javascript',
334
            'jut' => 'image/jutvision',
335
            'kar' => 'audio/midi',
336
            'ksh' => 'application/x-ksh',
337
            'la' => 'audio/nspaudio',
338
            'lam' => 'audio/x-liveaudio',
339
            'latex' => 'application/x-latex',
340
            'lha' => 'application/octet-stream',
341
            'lhx' => 'application/octet-stream',
342
            'list' => 'text/plain',
343
            'lma' => 'audio/nspaudio',
344
            'log' => 'text/plain',
345
            'lsp' => 'application/x-lisp',
346
            'lst' => 'text/plain',
347
            'lsx' => 'text/x-la-asf',
348
            'ltx' => 'application/x-latex',
349
            'lzx' => 'application/lzx',
350
            'm' => 'text/plain',
351
            'm1v' => 'video/mpeg',
352
            'm2a' => 'audio/mpeg',
353
            'm2v' => 'video/mpeg',
354
            'm3u' => 'audio/x-mpequrl',
355
            'man' => 'application/x-troff-man',
356
            'map' => 'application/x-navimap',
357
            'mar' => 'text/plain',
358
            'mbd' => 'application/mbedlet',
359
            'mc$' => 'application/x-magic-cap-package-1.0',
360
            'mcd' => 'application/mcad',
361
            'mcf' => 'text/mcf',
362
            'mcp' => 'application/netmc',
363
            'me' => 'application/x-troff-me',
364
            'mht' => 'message/rfc822',
365
            'mhtml' => 'message/rfc822',
366
            'mid' => 'audio/midi',
367
            'midi' => 'audio/midi',
368
            'mif' => 'application/x-mif',
369
            'mime' => 'www/mime',
370
            'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile',
371
            'mjpg' => 'video/x-motion-jpeg',
372
            'mm' => 'application/base64',
373
            'mme' => 'application/base64',
374
            'mod' => 'audio/mod',
375
            'moov' => 'video/quicktime',
376
            'mov' => 'video/quicktime',
377
            'movie' => 'video/x-sgi-movie',
378
            'mp2' => 'video/mpeg',
379
            'mp3' => 'audio/mpeg3',
380
            'mpa' => 'audio/mpeg',
381
            'mpc' => 'application/x-project',
382
            'mpe' => 'video/mpeg',
383
            'mpeg' => 'video/mpeg',
384
            'mpg' => 'video/mpeg',
385
            'mpga' => 'audio/mpeg',
386
            'mpp' => 'application/vnd.ms-project',
387
            'mpt' => 'application/x-project',
388
            'mpv' => 'application/x-project',
389
            'mpx' => 'application/x-project',
390
            'mrc' => 'application/marc',
391
            'ms' => 'application/x-troff-ms',
392
            'mv' => 'video/x-sgi-movie',
393
            'my' => 'audio/make',
394
            'mzz' => 'application/x-vnd.audioexplosion.mzz',
395
            'nap' => 'image/naplps',
396
            'naplps' => 'image/naplps',
397
            'nc' => 'application/x-netcdf',
398
            'ncm' => 'application/vnd.nokia.configuration-message',
399
            'nif' => 'image/x-niff',
400
            'niff' => 'image/x-niff',
401
            'nix' => 'application/x-mix-transfer',
402
            'nsc' => 'application/x-conference',
403
            'nvd' => 'application/x-navidoc',
404
            'o' => 'application/octet-stream',
405
            'oda' => 'application/oda',
406
            'omc' => 'application/x-omc',
407
            'omcd' => 'application/x-omcdatamaker',
408
            'omcr' => 'application/x-omcregerator',
409
            'p' => 'text/x-pascal',
410
            'p10' => 'application/pkcs10',
411
            'p12' => 'application/pkcs-12',
412
            'p7a' => 'application/x-pkcs7-signature',
413
            'p7c' => 'application/pkcs7-mime',
414
            'p7m' => 'application/pkcs7-mime',
415
            'p7r' => 'application/x-pkcs7-certreqresp',
416
            'p7s' => 'application/pkcs7-signature',
417
            'part' => 'application/pro_eng',
418
            'pas' => 'text/pascal',
419
            'pbm' => 'image/x-portable-bitmap',
420
            'pcl' => 'application/x-pcl',
421
            'pct' => 'image/x-pict',
422
            'pcx' => 'image/x-pcx',
423
            'pdb' => 'chemical/x-pdb',
424
            'pdf' => 'application/pdf',
425
            'pfunk' => 'audio/make',
426
            'pgm' => 'image/x-portable-graymap',
427
            'pic' => 'image/pict',
428
            'pict' => 'image/pict',
429
            'pkg' => 'application/x-newton-compatible-pkg',
430
            'pko' => 'application/vnd.ms-pki.pko',
431
            'pl' => 'text/plain',
432
            'plx' => 'application/x-pixclscript',
433
            'pm' => 'image/x-xpixmap',
434
            'pm4' => 'application/x-pagemaker',
435
            'pm5' => 'application/x-pagemaker',
436
            'png' => 'image/png',
437
            'pnm' => 'application/x-portable-anymap',
438
            'pot' => 'application/mspowerpoint',
439
            'pov' => 'model/x-pov',
440
            'ppa' => 'application/vnd.ms-powerpoint',
441
            'ppm' => 'image/x-portable-pixmap',
442
            'pps' => 'application/mspowerpoint',
443
            'ppt' => 'application/mspowerpoint',
444
            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
445
            'ppz' => 'application/mspowerpoint',
446
            'pre' => 'application/x-freelance',
447
            'prt' => 'application/pro_eng',
448
            'ps' => 'application/postscript',
449
            'psd' => 'application/octet-stream',
450
            'pvu' => 'paleovu/x-pv',
451
            'pwz' => 'application/vnd.ms-powerpoint',
452
            'py' => 'text/x-script.phyton',
453
            'pyc' => 'application/x-bytecode.python',
454
            'qcp' => 'audio/vnd.qcelp',
455
            'qd3' => 'x-world/x-3dmf',
456
            'qd3d' => 'x-world/x-3dmf',
457
            'qif' => 'image/x-quicktime',
458
            'qt' => 'video/quicktime',
459
            'qtc' => 'video/x-qtc',
460
            'qti' => 'image/x-quicktime',
461
            'qtif' => 'image/x-quicktime',
462
            'ra' => 'audio/x-realaudio',
463
            'ram' => 'audio/x-pn-realaudio',
464
            'ras' => 'image/cmu-raster',
465
            'rast' => 'image/cmu-raster',
466
            'rexx' => 'text/x-script.rexx',
467
            'rf' => 'image/vnd.rn-realflash',
468
            'rgb' => 'image/x-rgb',
469
            'rm' => 'application/vnd.rn-realmedia',
470
            'rmi' => 'audio/mid',
471
            'rmm' => 'audio/x-pn-realaudio',
472
            'rmp' => 'audio/x-pn-realaudio',
473
            'rng' => 'application/ringing-tones',
474
            'rnx' => 'application/vnd.rn-realplayer',
475
            'roff' => 'application/x-troff',
476
            'rp' => 'image/vnd.rn-realpix',
477
            'rpm' => 'audio/x-pn-realaudio-plugin',
478
            'rt' => 'text/richtext',
479
            'rtf' => 'application/rtf',
480
            'rtx' => 'application/rtf',
481
            'rv' => 'video/vnd.rn-realvideo',
482
            's' => 'text/x-asm',
483
            's3m' => 'audio/s3m',
484
            'saveme' => 'application/octet-stream',
485
            'sbk' => 'application/x-tbook',
486
            'scm' => 'text/x-script.scheme',
487
            'sdml' => 'text/plain',
488
            'sdp' => 'application/sdp',
489
            'sdr' => 'application/sounder',
490
            'sea' => 'application/sea',
491
            'set' => 'application/set',
492
            'sgm' => 'text/sgml',
493
            'sgml' => 'text/sgml',
494
            'sh' => 'application/x-sh',
495
            'shar' => 'application/x-shar',
496
            'shtml' => 'text/html',
497
            'sid' => 'audio/x-psid',
498
            'sit' => 'application/x-sit',
499
            'skd' => 'application/x-koan',
500
            'skm' => 'application/x-koan',
501
            'skp' => 'application/x-koan',
502
            'skt' => 'application/x-koan',
503
            'sl' => 'application/x-seelogo',
504
            'smi' => 'application/smil',
505
            'smil' => 'application/smil',
506
            'snd' => 'audio/basic',
507
            'sol' => 'application/solids',
508
            'spc' => 'text/x-speech',
509
            'spl' => 'application/futuresplash',
510
            'spr' => 'application/x-sprite',
511
            'sprite' => 'application/x-sprite',
512
            'src' => 'application/x-wais-source',
513
            'ssi' => 'text/x-server-parsed-html',
514
            'ssm' => 'application/streamingmedia',
515
            'sst' => 'application/vnd.ms-pki.certstore',
516
            'step' => 'application/step',
517
            'stl' => 'application/vnd.ms-pki.stl',
518
            'stp' => 'application/step',
519
            'sv4cpio' => 'application/x-sv4cpio',
520
            'sv4crc' => 'application/x-sv4crc',
521
            'svf' => 'image/vnd.dwg',
522
            'svr' => 'application/x-world',
523
            'swf' => 'application/x-shockwave-flash',
524
            't' => 'application/x-troff',
525
            'talk' => 'text/x-speech',
526
            'tar' => 'application/x-tar',
527
            'tbk' => 'application/toolbook',
528
            'tcl' => 'application/x-tcl',
529
            'tcsh' => 'text/x-script.tcsh',
530
            'tex' => 'application/x-tex',
531
            'texi' => 'application/x-texinfo',
532
            'texinfo' => 'application/x-texinfo',
533
            'text' => 'text/plain',
534
            'tgz' => 'application/x-compressed',
535
            'tif' => 'image/tiff',
536
            'tiff' => 'image/tiff',
537
            'tr' => 'application/x-troff',
538
            'tsi' => 'audio/tsp-audio',
539
            'tsp' => 'audio/tsplayer',
540
            'tsv' => 'text/tab-separated-values',
541
            'turbot' => 'image/florian',
542
            'txt' => 'text/plain',
543
            'uil' => 'text/x-uil',
544
            'uni' => 'text/uri-list',
545
            'unis' => 'text/uri-list',
546
            'unv' => 'application/i-deas',
547
            'uri' => 'text/uri-list',
548
            'uris' => 'text/uri-list',
549
            'ustar' => 'application/x-ustar',
550
            'uu' => 'application/octet-stream',
551
            'uue' => 'text/x-uuencode',
552
            'vcd' => 'application/x-cdlink',
553
            'vcs' => 'text/x-vcalendar',
554
            'vda' => 'application/vda',
555
            'vdo' => 'video/vdo',
556
            'vew' => 'application/groupwise',
557
            'viv' => 'video/vnd.vivo',
558
            'vivo' => 'video/vnd.vivo',
559
            'vmd' => 'application/vocaltec-media-desc',
560
            'vmf' => 'application/vocaltec-media-file',
561
            'voc' => 'audio/voc',
562
            'vos' => 'video/vosaic',
563
            'vox' => 'audio/voxware',
564
            'vqe' => 'audio/x-twinvq-plugin',
565
            'vqf' => 'audio/x-twinvq',
566
            'vql' => 'audio/x-twinvq-plugin',
567
            'vrml' => 'application/x-vrml',
568
            'vrt' => 'x-world/x-vrt',
569
            'vsd' => 'application/x-visio',
570
            'vst' => 'application/x-visio',
571
            'vsw' => 'application/x-visio',
572
            'w60' => 'application/wordperfect6.0',
573
            'w61' => 'application/wordperfect6.1',
574
            'w6w' => 'application/msword',
575
            'wav' => 'audio/wav',
576
            'wb1' => 'application/x-qpro',
577
            'wbmp' => 'image/vnd.wap.wbmp',
578
            'web' => 'application/vnd.xara',
579
            'wiz' => 'application/msword',
580
            'wk1' => 'application/x-123',
581
            'wmf' => 'windows/metafile',
582
            'wml' => 'text/vnd.wap.wml',
583
            'wmlc' => 'application/vnd.wap.wmlc',
584
            'wmls' => 'text/vnd.wap.wmlscript',
585
            'wmlsc' => 'application/vnd.wap.wmlscriptc',
586
            'word' => 'application/msword',
587
            'wp' => 'application/wordperfect',
588
            'wp5' => 'application/wordperfect',
589
            'wp6' => 'application/wordperfect',
590
            'wpd' => 'application/wordperfect',
591
            'wq1' => 'application/x-lotus',
592
            'wri' => 'application/mswrite',
593
            'wrl' => 'application/x-world',
594
            'wrz' => 'x-world/x-vrml',
595
            'wsc' => 'text/scriplet',
596
            'wsrc' => 'application/x-wais-source',
597
            'wtk' => 'application/x-wintalk',
598
            'xbm' => 'image/xbm',
599
            'xdr' => 'video/x-amt-demorun',
600
            'xgz' => 'xgl/drawing',
601
            'xif' => 'image/vnd.xiff',
602
            'xl' => 'application/excel',
603
            'xla' => 'application/excel',
604
            'xlb' => 'application/excel',
605
            'xlc' => 'application/excel',
606
            'xld' => 'application/excel',
607
            'xlk' => 'application/excel',
608
            'xll' => 'application/excel',
609
            'xlm' => 'application/excel',
610
            'xls' => 'application/excel',
611
            'xlsx'  => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
612
            'xlt' => 'application/excel',
613
            'xlv' => 'application/excel',
614
            'xlw' => 'application/excel',
615
            'xm' => 'audio/xm',
616
            'xml' => 'text/xml',
617
            'xmz' => 'xgl/movie',
618
            'xpix' => 'application/x-vnd.ls-xpix',
619
            'xpm' => 'image/xpm',
620
            'x-png' => 'image/png',
621
            'xsl'   => 'application/xml',
622
            'xsr' => 'video/x-amt-showrun',
623
            'xwd' => 'image/x-xwd',
624
            'xyz' => 'chemical/x-pdb',
625
            'z' => 'application/x-compressed',
626
            'zip' => 'application/zip',
627
            'zoo' => 'application/octet-stream',
628
            'zsh' => 'text/x-script.zsh'
629
        ];
630
    }
631
}
632