Complex classes like FileUtils often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FileUtils, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 54 | class FileUtils |
||
| 55 | { |
||
| 56 | /** |
||
| 57 | * A hash array for mapping file extensions to MIME types. |
||
| 58 | * |
||
| 59 | * @var array |
||
| 60 | * |
||
| 61 | * @since 1.0 |
||
| 62 | */ |
||
| 63 | private static $extensionToMIMEMappings = array( |
||
| 64 | '3dm' => 'x-world/x-3dmf', |
||
| 65 | '3dmf' => 'x-world/x-3dmf', |
||
| 66 | 'a' => 'application/octet-stream', |
||
| 67 | 'aab' => 'application/x-authorware-bin', |
||
| 68 | 'aam' => 'application/x-authorware-map', |
||
| 69 | 'aas' => 'application/x-authorware-seg', |
||
| 70 | 'abc' => 'text/vnd.abc', |
||
| 71 | 'acgi' => 'text/html', |
||
| 72 | 'afl' => 'video/animaflex', |
||
| 73 | 'ai' => 'application/postscript', |
||
| 74 | 'aif' => 'audio/aiff', |
||
| 75 | 'aifc' => 'audio/aiff', |
||
| 76 | 'aiff' => 'audio/aiff', |
||
| 77 | 'aim' => 'application/x-aim', |
||
| 78 | 'aip' => 'text/x-audiosoft-intra', |
||
| 79 | 'ani' => 'application/x-navi-animation', |
||
| 80 | 'aos' => 'application/x-nokia-9000-communicator-add-on-software', |
||
| 81 | 'aps' => 'application/mime', |
||
| 82 | 'arc' => 'application/octet-stream', |
||
| 83 | 'arj' => 'application/arj', |
||
| 84 | 'art' => 'image/x-jg', |
||
| 85 | 'asf' => 'video/x-ms-asf', |
||
| 86 | 'asm' => 'text/x-asm', |
||
| 87 | 'asp' => 'text/asp', |
||
| 88 | 'asx' => 'application/x-mplayer2', |
||
| 89 | 'au' => 'audio/basic', |
||
| 90 | 'avi' => 'application/x-troff-msvideo', |
||
| 91 | 'avs' => 'video/avs-video', |
||
| 92 | 'bcpio' => 'application/x-bcpio', |
||
| 93 | 'bin' => 'application/octet-stream', |
||
| 94 | 'bm' => 'image/bmp', |
||
| 95 | 'bmp' => 'image/bmp', |
||
| 96 | 'boo' => 'application/book', |
||
| 97 | 'book' => 'application/book', |
||
| 98 | 'boz' => 'application/x-bzip2', |
||
| 99 | 'bsh' => 'application/x-bsh', |
||
| 100 | 'bz' => 'application/x-bzip', |
||
| 101 | 'bz2' => 'application/x-bzip2', |
||
| 102 | 'c' => 'text/plain', |
||
| 103 | 'c++' => 'text/plain', |
||
| 104 | 'cat' => 'application/vnd.ms-pki.seccat', |
||
| 105 | 'cc' => 'text/plain', |
||
| 106 | 'ccad' => 'application/clariscad', |
||
| 107 | 'cco' => 'application/x-cocoa', |
||
| 108 | 'cdf' => 'application/cdf', |
||
| 109 | 'cer' => 'application/pkix-cert', |
||
| 110 | 'cha' => 'application/x-chat', |
||
| 111 | 'chat' => 'application/x-chat', |
||
| 112 | 'class' => 'application/java', |
||
| 113 | 'com' => 'application/octet-stream', |
||
| 114 | 'conf' => 'text/plain', |
||
| 115 | 'cpio' => 'application/x-cpio', |
||
| 116 | 'cpp' => 'text/x-c', |
||
| 117 | 'cpt' => 'application/mac-compactpro', |
||
| 118 | 'crl' => 'application/pkcs-crl', |
||
| 119 | 'crt' => 'application/pkix-cert', |
||
| 120 | 'csh' => 'application/x-csh', |
||
| 121 | 'css' => 'application/x-pointplus', |
||
| 122 | 'cxx' => 'text/plain', |
||
| 123 | 'dcr' => 'application/x-director', |
||
| 124 | 'deepv' => 'application/x-deepv', |
||
| 125 | 'def' => 'text/plain', |
||
| 126 | 'der' => 'application/x-x509-ca-cert', |
||
| 127 | 'dif' => 'video/x-dv', |
||
| 128 | 'dir' => 'application/x-director', |
||
| 129 | 'dl' => 'video/dl', |
||
| 130 | 'doc' => 'application/msword', |
||
| 131 | 'dot' => 'application/msword', |
||
| 132 | 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
||
| 133 | 'dp' => 'application/commonground', |
||
| 134 | 'drw' => 'application/drafting', |
||
| 135 | 'dump' => 'application/octet-stream', |
||
| 136 | 'dv' => 'video/x-dv', |
||
| 137 | 'dvi' => 'application/x-dvi', |
||
| 138 | 'dwf' => 'drawing/x-dwf (old)', |
||
| 139 | 'dwg' => 'application/acad', |
||
| 140 | 'dxf' => 'application/dxf', |
||
| 141 | 'dxr' => 'application/x-director', |
||
| 142 | 'el' => 'text/x-script.elisp', |
||
| 143 | 'elc' => 'application/x-bytecode.elisp (compiled elisp)', |
||
| 144 | 'env' => 'application/x-envoy', |
||
| 145 | 'eps' => 'application/postscript', |
||
| 146 | 'es' => 'application/x-esrehber', |
||
| 147 | 'etx' => 'text/x-setext', |
||
| 148 | 'evy' => 'application/envoy', |
||
| 149 | 'exe' => 'application/octet-stream', |
||
| 150 | 'f' => 'text/plain', |
||
| 151 | 'f77' => 'text/x-fortran', |
||
| 152 | 'f90' => 'text/plain', |
||
| 153 | 'fdf' => 'application/vnd.fdf', |
||
| 154 | 'fif' => 'application/fractals', |
||
| 155 | 'fli' => 'video/fli', |
||
| 156 | 'flo' => 'image/florian', |
||
| 157 | 'flx' => 'text/vnd.fmi.flexstor', |
||
| 158 | 'fmf' => 'video/x-atomic3d-feature', |
||
| 159 | 'for' => 'text/plain', |
||
| 160 | 'fpx' => 'image/vnd.fpx', |
||
| 161 | 'frl' => 'application/freeloader', |
||
| 162 | 'funk' => 'audio/make', |
||
| 163 | 'g' => 'text/plain', |
||
| 164 | 'g3' => 'image/g3fax', |
||
| 165 | 'gif' => 'image/gif', |
||
| 166 | 'gl' => 'video/gl', |
||
| 167 | 'gsd' => 'audio/x-gsm', |
||
| 168 | 'gsm' => 'audio/x-gsm', |
||
| 169 | 'gsp' => 'application/x-gsp', |
||
| 170 | 'gss' => 'application/x-gss', |
||
| 171 | 'gtar' => 'application/x-gtar', |
||
| 172 | 'gz' => 'application/x-compressed', |
||
| 173 | 'gzip' => 'application/x-gzip', |
||
| 174 | 'h' => 'text/plain', |
||
| 175 | 'hdf' => 'application/x-hdf', |
||
| 176 | 'help' => 'application/x-helpfile', |
||
| 177 | 'hgl' => 'application/vnd.hp-hpgl', |
||
| 178 | 'hh' => 'text/plain', |
||
| 179 | 'hlb' => 'text/x-script', |
||
| 180 | 'hlp' => 'application/hlp', |
||
| 181 | 'hpg' => 'application/vnd.hp-hpgl', |
||
| 182 | 'hpgl' => 'application/vnd.hp-hpgl', |
||
| 183 | 'hqx' => 'application/binhex', |
||
| 184 | 'hta' => 'application/hta', |
||
| 185 | 'htc' => 'text/x-component', |
||
| 186 | 'htm' => 'text/html', |
||
| 187 | 'html' => 'text/html', |
||
| 188 | 'htmls' => 'text/html', |
||
| 189 | 'htt' => 'text/webviewhtml', |
||
| 190 | 'htx' => 'text/html', |
||
| 191 | 'ice' => 'x-conference/x-cooltalk', |
||
| 192 | 'ico' => 'image/x-icon', |
||
| 193 | 'idc' => 'text/plain', |
||
| 194 | 'ief' => 'image/ief', |
||
| 195 | 'iefs' => 'image/ief', |
||
| 196 | 'iges' => 'application/iges', |
||
| 197 | 'igs' => 'application/iges', |
||
| 198 | 'ima' => 'application/x-ima', |
||
| 199 | 'imap' => 'application/x-httpd-imap', |
||
| 200 | 'inf' => 'application/inf', |
||
| 201 | 'ins' => 'application/x-internett-signup', |
||
| 202 | 'ip' => 'application/x-ip2', |
||
| 203 | 'isu' => 'video/x-isvideo', |
||
| 204 | 'it' => 'audio/it', |
||
| 205 | 'iv' => 'application/x-inventor', |
||
| 206 | 'ivr' => 'i-world/i-vrml', |
||
| 207 | 'ivy' => 'application/x-livescreen', |
||
| 208 | 'jam' => 'audio/x-jam', |
||
| 209 | 'jav' => 'text/plain', |
||
| 210 | 'java' => 'text/plain', |
||
| 211 | 'jcm' => 'application/x-java-commerce', |
||
| 212 | 'jfif' => 'image/jpeg', |
||
| 213 | 'jfif-tbnl' => 'image/jpeg', |
||
| 214 | 'jpe' => 'image/jpeg', |
||
| 215 | 'jpeg' => 'image/jpeg', |
||
| 216 | 'jpg' => 'image/jpeg', |
||
| 217 | 'jps' => 'image/x-jps', |
||
| 218 | 'js' => 'application/x-javascript', |
||
| 219 | 'jut' => 'image/jutvision', |
||
| 220 | 'kar' => 'audio/midi', |
||
| 221 | 'ksh' => 'application/x-ksh', |
||
| 222 | 'la' => 'audio/nspaudio', |
||
| 223 | 'lam' => 'audio/x-liveaudio', |
||
| 224 | 'latex' => 'application/x-latex', |
||
| 225 | 'lha' => 'application/lha', |
||
| 226 | 'lhx' => 'application/octet-stream', |
||
| 227 | 'list' => 'text/plain', |
||
| 228 | 'lma' => 'audio/nspaudio', |
||
| 229 | 'log' => 'text/plain', |
||
| 230 | 'lsp' => 'application/x-lisp', |
||
| 231 | 'lst' => 'text/plain', |
||
| 232 | 'lsx' => 'text/x-la-asf', |
||
| 233 | 'ltx' => 'application/x-latex', |
||
| 234 | 'lzh' => 'application/octet-stream', |
||
| 235 | 'lzx' => 'application/lzx', |
||
| 236 | 'm' => 'text/plain', |
||
| 237 | 'm1v' => 'video/mpeg', |
||
| 238 | 'm2a' => 'audio/mpeg', |
||
| 239 | 'm2v' => 'video/mpeg', |
||
| 240 | 'm3u' => 'audio/x-mpequrl', |
||
| 241 | 'man' => 'application/x-troff-man', |
||
| 242 | 'map' => 'application/x-navimap', |
||
| 243 | 'mar' => 'text/plain', |
||
| 244 | 'mbd' => 'application/mbedlet', |
||
| 245 | 'mc$' => 'application/x-magic-cap-package-1.0', |
||
| 246 | 'mcd' => 'application/mcad', |
||
| 247 | 'mcf' => 'image/vasa', |
||
| 248 | 'mcp' => 'application/netmc', |
||
| 249 | 'me' => 'application/x-troff-me', |
||
| 250 | 'mht' => 'message/rfc822', |
||
| 251 | 'mhtml' => 'message/rfc822', |
||
| 252 | 'mid' => 'application/x-midi', |
||
| 253 | 'midi' => 'application/x-midi', |
||
| 254 | 'mif' => 'application/x-frame', |
||
| 255 | 'mime' => 'message/rfc822', |
||
| 256 | 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile', |
||
| 257 | 'mjpg' => 'video/x-motion-jpeg', |
||
| 258 | 'mm' => 'application/base64', |
||
| 259 | 'mme' => 'application/base64', |
||
| 260 | 'mod' => 'audio/mod', |
||
| 261 | 'moov' => 'video/quicktime', |
||
| 262 | 'mov' => 'video/quicktime', |
||
| 263 | 'movie' => 'video/x-sgi-movie', |
||
| 264 | 'mp2' => 'audio/mpeg', |
||
| 265 | 'mp3' => 'audio/mpeg3', |
||
| 266 | 'mpa' => 'audio/mpeg', |
||
| 267 | 'mpc' => 'application/x-project', |
||
| 268 | 'mpe' => 'video/mpeg', |
||
| 269 | 'mpeg' => 'video/mpeg', |
||
| 270 | 'mpg' => 'audio/mpeg', |
||
| 271 | 'mpga' => 'audio/mpeg', |
||
| 272 | 'mpp' => 'application/vnd.ms-project', |
||
| 273 | 'mpt' => 'application/x-project', |
||
| 274 | 'mpv' => 'application/x-project', |
||
| 275 | 'mpx' => 'application/x-project', |
||
| 276 | 'mrc' => 'application/marc', |
||
| 277 | 'ms' => 'application/x-troff-ms', |
||
| 278 | 'mv' => 'video/x-sgi-movie', |
||
| 279 | 'my' => 'audio/make', |
||
| 280 | 'mzz' => 'application/x-vnd.audioexplosion.mzz', |
||
| 281 | 'nap' => 'image/naplps', |
||
| 282 | 'naplps' => 'image/naplps', |
||
| 283 | 'nc' => 'application/x-netcdf', |
||
| 284 | 'ncm' => 'application/vnd.nokia.configuration-message', |
||
| 285 | 'nif' => 'image/x-niff', |
||
| 286 | 'niff' => 'image/x-niff', |
||
| 287 | 'nix' => 'application/x-mix-transfer', |
||
| 288 | 'nsc' => 'application/x-conference', |
||
| 289 | 'nvd' => 'application/x-navidoc', |
||
| 290 | 'o' => 'application/octet-stream', |
||
| 291 | 'oda' => 'application/oda', |
||
| 292 | 'omc' => 'application/x-omc', |
||
| 293 | 'omcd' => 'application/x-omcdatamaker', |
||
| 294 | 'omcr' => 'application/x-omcregerator', |
||
| 295 | 'p' => 'text/x-pascal', |
||
| 296 | 'p10' => 'application/pkcs10', |
||
| 297 | 'p12' => 'application/pkcs-12', |
||
| 298 | 'p7a' => 'application/x-pkcs7-signature', |
||
| 299 | 'p7c' => 'application/pkcs7-mime', |
||
| 300 | 'p7m' => 'application/pkcs7-mime', |
||
| 301 | 'p7r' => 'application/x-pkcs7-certreqresp', |
||
| 302 | 'p7s' => 'application/pkcs7-signature', |
||
| 303 | 'part' => 'application/pro_eng', |
||
| 304 | 'pas' => 'text/pascal', |
||
| 305 | 'pbm' => 'image/x-portable-bitmap', |
||
| 306 | 'pcl' => 'application/vnd.hp-pcl', |
||
| 307 | 'pct' => 'image/x-pict', |
||
| 308 | 'pcx' => 'image/x-pcx', |
||
| 309 | 'pdb' => 'chemical/x-pdb', |
||
| 310 | 'pdf' => 'application/pdf', |
||
| 311 | 'pfunk' => 'audio/make', |
||
| 312 | 'pgm' => 'image/x-portable-graymap', |
||
| 313 | 'pic' => 'image/pict', |
||
| 314 | 'pict' => 'image/pict', |
||
| 315 | 'pkg' => 'application/x-newton-compatible-pkg', |
||
| 316 | 'pko' => 'application/vnd.ms-pki.pko', |
||
| 317 | 'pl' => 'text/plain', |
||
| 318 | 'plx' => 'application/x-pixclscript', |
||
| 319 | 'pm' => 'image/x-xpixmap', |
||
| 320 | 'pm4' => 'application/x-pagemaker', |
||
| 321 | 'pm5' => 'application/x-pagemaker', |
||
| 322 | 'png' => 'image/png', |
||
| 323 | 'pnm' => 'application/x-portable-anymap', |
||
| 324 | 'pot' => 'application/mspowerpoint', |
||
| 325 | 'pov' => 'model/x-pov', |
||
| 326 | 'ppa' => 'application/vnd.ms-powerpoint', |
||
| 327 | 'ppm' => 'image/x-portable-pixmap', |
||
| 328 | 'pps' => 'application/mspowerpoint', |
||
| 329 | 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', |
||
| 330 | 'ppt' => 'application/mspowerpoint', |
||
| 331 | 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', |
||
| 332 | 'ppz' => 'application/mspowerpoint', |
||
| 333 | 'pre' => 'application/x-freelance', |
||
| 334 | 'prt' => 'application/pro_eng', |
||
| 335 | 'ps' => 'application/postscript', |
||
| 336 | 'psd' => 'application/octet-stream', |
||
| 337 | 'pvu' => 'paleovu/x-pv', |
||
| 338 | 'pwz' => 'application/vnd.ms-powerpoint', |
||
| 339 | 'py' => 'text/x-script.phyton', |
||
| 340 | 'pyc' => 'applicaiton/x-bytecode.python', |
||
| 341 | 'qcp' => 'audio/vnd.qcelp', |
||
| 342 | 'qd3' => 'x-world/x-3dmf', |
||
| 343 | 'qd3d' => 'x-world/x-3dmf', |
||
| 344 | 'qif' => 'image/x-quicktime', |
||
| 345 | 'qt' => 'video/quicktime', |
||
| 346 | 'qtc' => 'video/x-qtc', |
||
| 347 | 'qti' => 'image/x-quicktime', |
||
| 348 | 'qtif' => 'image/x-quicktime', |
||
| 349 | 'ra' => 'audio/x-pn-realaudio', |
||
| 350 | 'ram' => 'audio/x-pn-realaudio', |
||
| 351 | 'ras' => 'application/x-cmu-raster', |
||
| 352 | 'rast' => 'image/cmu-raster', |
||
| 353 | 'rexx' => 'text/x-script.rexx', |
||
| 354 | 'rf' => 'image/vnd.rn-realflash', |
||
| 355 | 'rgb' => 'image/x-rgb', |
||
| 356 | 'rm' => 'application/vnd.rn-realmedia', |
||
| 357 | 'rmi' => 'audio/mid', |
||
| 358 | 'rmm' => 'audio/x-pn-realaudio', |
||
| 359 | 'rmp' => 'audio/x-pn-realaudio', |
||
| 360 | 'rng' => 'application/ringing-tones', |
||
| 361 | 'rnx' => 'application/vnd.rn-realplayer', |
||
| 362 | 'roff' => 'application/x-troff', |
||
| 363 | 'rp' => 'image/vnd.rn-realpix', |
||
| 364 | 'rpm' => 'audio/x-pn-realaudio-plugin', |
||
| 365 | 'rt' => 'text/richtext', |
||
| 366 | 'rtf' => 'application/rtf', |
||
| 367 | 'rtx' => 'application/rtf', |
||
| 368 | 'rv' => 'video/vnd.rn-realvideo', |
||
| 369 | 's' => 'text/x-asm', |
||
| 370 | 's3m' => 'audio/s3m', |
||
| 371 | 'saveme' => 'application/octet-stream', |
||
| 372 | 'sbk' => 'application/x-tbook', |
||
| 373 | 'scm' => 'application/x-lotusscreencam', |
||
| 374 | 'sdml' => 'text/plain', |
||
| 375 | 'sdp' => 'application/sdp', |
||
| 376 | 'sdr' => 'application/sounder', |
||
| 377 | 'sea' => 'application/sea', |
||
| 378 | 'set' => 'application/set', |
||
| 379 | 'sgm' => 'text/sgml', |
||
| 380 | 'sgml' => 'text/sgml', |
||
| 381 | 'sh' => 'application/x-bsh', |
||
| 382 | 'shar' => 'application/x-bsh', |
||
| 383 | 'shtml' => 'text/html', |
||
| 384 | 'sid' => 'audio/x-psid', |
||
| 385 | 'sit' => 'application/x-sit', |
||
| 386 | 'skd' => 'application/x-koan', |
||
| 387 | 'skm' => 'application/x-koan', |
||
| 388 | 'skp' => 'application/x-koan', |
||
| 389 | 'skt' => 'application/x-koan', |
||
| 390 | 'sl' => 'application/x-seelogo', |
||
| 391 | 'smi' => 'application/smil', |
||
| 392 | 'smil' => 'application/smil', |
||
| 393 | 'snd' => 'audio/basic', |
||
| 394 | 'sol' => 'application/solids', |
||
| 395 | 'spc' => 'application/x-pkcs7-certificates', |
||
| 396 | 'spl' => 'application/futuresplash', |
||
| 397 | 'spr' => 'application/x-sprite', |
||
| 398 | 'sprite' => 'application/x-sprite', |
||
| 399 | 'src' => 'application/x-wais-source', |
||
| 400 | 'ssi' => 'text/x-server-parsed-html', |
||
| 401 | 'ssm' => 'application/streamingmedia', |
||
| 402 | 'sst' => 'application/vnd.ms-pki.certstore', |
||
| 403 | 'step' => 'application/step', |
||
| 404 | 'stl' => 'application/sla', |
||
| 405 | 'stp' => 'application/step', |
||
| 406 | 'sv4cpio' => 'application/x-sv4cpio', |
||
| 407 | 'sv4crc' => 'application/x-sv4crc', |
||
| 408 | 'svf' => 'image/vnd.dwg', |
||
| 409 | 'svr' => 'application/x-world', |
||
| 410 | 'swf' => 'application/x-shockwave-flash', |
||
| 411 | 't' => 'application/x-troff', |
||
| 412 | 'talk' => 'text/x-speech', |
||
| 413 | 'tar' => 'application/x-tar', |
||
| 414 | 'tbk' => 'application/toolbook', |
||
| 415 | 'tcl' => 'application/x-tcl', |
||
| 416 | 'tcsh' => 'text/x-script.tcsh', |
||
| 417 | 'tex' => 'application/x-tex', |
||
| 418 | 'texi' => 'application/x-texinfo', |
||
| 419 | 'texinfo' => 'application/x-texinfo', |
||
| 420 | 'text' => 'application/plain', |
||
| 421 | 'tgz' => 'application/gnutar', |
||
| 422 | 'tif' => 'image/tiff', |
||
| 423 | 'tiff' => 'image/tiff', |
||
| 424 | 'tr' => 'application/x-troff', |
||
| 425 | 'tsi' => 'audio/tsp-audio', |
||
| 426 | 'tsp' => 'application/dsptype', |
||
| 427 | 'tsv' => 'text/tab-separated-values', |
||
| 428 | 'turbot' => 'image/florian', |
||
| 429 | 'txt' => 'text/plain', |
||
| 430 | 'uil' => 'text/x-uil', |
||
| 431 | 'uni' => 'text/uri-list', |
||
| 432 | 'unis' => 'text/uri-list', |
||
| 433 | 'unv' => 'application/i-deas', |
||
| 434 | 'uri' => 'text/uri-list', |
||
| 435 | 'uris' => 'text/uri-list', |
||
| 436 | 'ustar' => 'application/x-ustar', |
||
| 437 | 'uu' => 'application/octet-stream', |
||
| 438 | 'uue' => 'text/x-uuencode', |
||
| 439 | 'vcd' => 'application/x-cdlink', |
||
| 440 | 'vcs' => 'text/x-vcalendar', |
||
| 441 | 'vda' => 'application/vda', |
||
| 442 | 'vdo' => 'video/vdo', |
||
| 443 | 'vew' => 'application/groupwise', |
||
| 444 | 'viv' => 'video/vivo', |
||
| 445 | 'vivo' => 'video/vivo', |
||
| 446 | 'vmd' => 'application/vocaltec-media-desc', |
||
| 447 | 'vmf' => 'application/vocaltec-media-file', |
||
| 448 | 'voc' => 'audio/voc', |
||
| 449 | 'vos' => 'video/vosaic', |
||
| 450 | 'vox' => 'audio/voxware', |
||
| 451 | 'vqe' => 'audio/x-twinvq-plugin', |
||
| 452 | 'vqf' => 'audio/x-twinvq', |
||
| 453 | 'vql' => 'audio/x-twinvq-plugin', |
||
| 454 | 'vrml' => 'application/x-vrml', |
||
| 455 | 'vrt' => 'x-world/x-vrt', |
||
| 456 | 'vsd' => 'application/x-visio', |
||
| 457 | 'vst' => 'application/x-visio', |
||
| 458 | 'vsw' => 'application/x-visio', |
||
| 459 | 'w60' => 'application/wordperfect6.0', |
||
| 460 | 'w61' => 'application/wordperfect6.1', |
||
| 461 | 'w6w' => 'application/msword', |
||
| 462 | 'wav' => 'audio/wav', |
||
| 463 | 'wb1' => 'application/x-qpro', |
||
| 464 | 'wbmp' => 'image/vnd.wap.wbmp', |
||
| 465 | 'web' => 'application/vnd.xara', |
||
| 466 | 'wiz' => 'application/msword', |
||
| 467 | 'wk1' => 'application/x-123', |
||
| 468 | 'wmf' => 'windows/metafile', |
||
| 469 | 'wml' => 'text/vnd.wap.wml', |
||
| 470 | 'wmlc' => 'application/vnd.wap.wmlc', |
||
| 471 | 'wmls' => 'text/vnd.wap.wmlscript', |
||
| 472 | 'wmlsc' => 'application/vnd.wap.wmlscriptc', |
||
| 473 | 'word' => 'application/msword', |
||
| 474 | 'wp' => 'application/wordperfect', |
||
| 475 | 'wp5' => 'application/wordperfect', |
||
| 476 | 'wp6' => 'application/wordperfect', |
||
| 477 | 'wpd' => 'application/wordperfect', |
||
| 478 | 'wq1' => 'application/x-lotus', |
||
| 479 | 'wri' => 'application/mswrite', |
||
| 480 | 'wrl' => 'application/x-world', |
||
| 481 | 'wrz' => 'model/vrml', |
||
| 482 | 'wsc' => 'text/scriplet', |
||
| 483 | 'wsrc' => 'application/x-wais-source', |
||
| 484 | 'wtk' => 'application/x-wintalk', |
||
| 485 | 'xbm' => 'image/x-xbitmap', |
||
| 486 | 'xdr' => 'video/x-amt-demorun', |
||
| 487 | 'xgz' => 'xgl/drawing', |
||
| 488 | 'xif' => 'image/vnd.xiff', |
||
| 489 | 'xl' => 'application/excel', |
||
| 490 | 'xla' => 'application/excel', |
||
| 491 | 'xlb' => 'application/excel', |
||
| 492 | 'xlc' => 'application/excel', |
||
| 493 | 'xld' => 'application/excel', |
||
| 494 | 'xlk' => 'application/excel', |
||
| 495 | 'xll' => 'application/excel', |
||
| 496 | 'xlm' => 'application/excel', |
||
| 497 | 'xls' => 'application/excel', |
||
| 498 | 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
||
| 499 | 'xlt' => 'application/excel', |
||
| 500 | 'xlv' => 'application/excel', |
||
| 501 | 'xlw' => 'application/excel', |
||
| 502 | 'xm' => 'audio/xm', |
||
| 503 | 'xml' => 'application/xml', |
||
| 504 | 'xmz' => 'xgl/movie', |
||
| 505 | 'xpix' => 'application/x-vnd.ls-xpix', |
||
| 506 | 'xpm' => 'image/x-xpixmap', |
||
| 507 | 'x-png' => 'image/png', |
||
| 508 | 'xsr' => 'video/x-amt-showrun', |
||
| 509 | 'xwd' => 'image/x-xwd', |
||
| 510 | 'xyz' => 'chemical/x-pdb', |
||
| 511 | 'z' => 'application/x-compress', |
||
| 512 | 'zip' => 'application/zip', |
||
| 513 | 'zoo' => 'application/octet-stream', |
||
| 514 | 'zsh' => 'text/x-script.zsh', |
||
| 515 | ); |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Method that allows you to determine a MIME type for a file which you provide the extension for. |
||
| 519 | * |
||
| 520 | * @param string $ext The file extension. |
||
| 521 | * |
||
| 522 | * @return string |
||
| 523 | * |
||
| 524 | * @throws \Alpha\Exception\IllegalArguementException |
||
| 525 | * |
||
| 526 | * @since 1.0 |
||
| 527 | */ |
||
| 528 | public static function getMIMETypeByExtension($ext) |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Renders the contents of the directory as a HTML list. |
||
| 540 | * |
||
| 541 | * @param string $sourceDir The path to the source directory. |
||
| 542 | * @param string $fileList The HTML list of files generated (pass by reference). |
||
| 543 | * @param int $fileCount The current file count (used in recursive calls). |
||
| 544 | * @param string[] $excludeFiles An array of file names to exclude from the list rendered. |
||
| 545 | * |
||
| 546 | * @return int The current filecount for the directory. |
||
| 547 | * |
||
| 548 | * @throws \Alpha\Exception\AlphaException |
||
| 549 | * |
||
| 550 | * @since 1.0 |
||
| 551 | */ |
||
| 552 | public static function listDirectoryContents($sourceDir, &$fileList, $fileCount = 0, $excludeFiles = array()) |
||
| 576 | |||
| 577 | /** |
||
| 578 | * Gets the contents of the directory recursively as a nested hash array (dirname => file1, file2, file3...). |
||
| 579 | * |
||
| 580 | * @param string $sourceDir The path to the source directory. |
||
| 581 | * @param array $fileList The list of files generated (pass by reference). |
||
| 582 | * |
||
| 583 | * @return array |
||
| 584 | * |
||
| 585 | * @throws \Alpha\Exception\AlphaException |
||
| 586 | * |
||
| 587 | * @since 3.0 |
||
| 588 | */ |
||
| 589 | public static function getDirectoryContents($sourceDir, &$fileList = array()) |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Recursively deletes the contents of the directory indicated (the directory itself is not deleted). |
||
| 610 | * |
||
| 611 | * @param string $sourceDir The path to the source directory. |
||
| 612 | * @param string[] $excludeFiles An array of file names to exclude from the deletion. |
||
| 613 | * |
||
| 614 | * @throws \Alpha\Exception\AlphaException |
||
| 615 | * |
||
| 616 | * @since 1.0 |
||
| 617 | */ |
||
| 618 | public static function deleteDirectoryContents($sourceDir, $excludeFiles = array()) |
||
| 638 | |||
| 639 | /** |
||
| 640 | * Recursively copies the indicated folder, or single file, to the destination location. |
||
| 641 | * |
||
| 642 | * @param string $source The path to the source directory or file. |
||
| 643 | * @param string $dest The destination source directory or file. |
||
| 644 | * |
||
| 645 | * @throws \Alpha\Exception\AlphaException |
||
| 646 | * |
||
| 647 | * @since 1.1 |
||
| 648 | */ |
||
| 649 | public static function copy($source, $dest) |
||
| 681 | |||
| 682 | /** |
||
| 683 | * Recursively compresses the contents of the source directory indicated to the destintation zip archive. |
||
| 684 | * |
||
| 685 | * @param string $source The path to the source directory or file. |
||
| 686 | * @param string $dest The destination zip file file. |
||
| 687 | * |
||
| 688 | * @throws \Alpha\Exception\AlphaException |
||
| 689 | * |
||
| 690 | * @since 1.1 |
||
| 691 | */ |
||
| 692 | public static function zip($source, $dest) |
||
| 728 | } |
||
| 729 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.