diff --git a/System/File/ExtensionType.php b/System/File/ExtensionType.php index 8628e1177..74213e718 100644 --- a/System/File/ExtensionType.php +++ b/System/File/ExtensionType.php @@ -40,4 +40,5 @@ abstract class ExtensionType extends Enum public const IMAGE = 512; public const EXECUTABLE = 1024; public const DIRECTORY = 2048; + public const WORD = 4096; } diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index 740340b17..f1c6d579a 100644 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -24,16 +24,18 @@ namespace phpOMS\System\File; */ final class FileUtils { - public const CODE_EXTENSION = ['cpp', 'c', 'h', 'hpp', 'cs', 'css', 'scss', 'htm', 'html', 'js', 'php', 'rb', 'rs', 'ts']; - public const TEXT_EXTENSION = ['doc', 'docx', 'txt', 'md', 'csv']; - public const PRESENTATION_EXTENSION = ['ppt', 'pptx']; + public const CODE_EXTENSION = ['cpp', 'c', 'h', 'hpp', 'cs', 'css', 'scss', 'htm', 'html', 'js', 'java', 'sh', 'vb', 'php', 'rb', 'rs', 'ts', 'swift', 'class', 'htaccess', 'sql', 'py', 'bat', 'xml']; + public const TEXT_EXTENSION = ['log', 'txt', 'md', 'csv', 'tex', 'latex', 'cfg', 'config', 'conf', 'ini']; + public const WORD_EXTENSION = ['doc', 'docx', 'rtf', 'odt']; + public const PRESENTATION_EXTENSION = ['ppt', 'pptx', 'pps', 'odp', 'key']; public const PDF_EXTENSION = ['pdf']; - public const ARCHIVE_EXTENSION = ['zip', '7z', 'rar']; - public const AUDIO_EXTENSION = ['mp3', 'wav']; - public const VIDEO_EXTENSION = ['mp4']; - public const SPREADSHEET_EXTENSION = ['xls', 'xlsm']; - public const IMAGE_EXTENSION = ['png', 'gif', 'jpg', 'jpeg', 'tiff', 'bmp', 'svg']; + public const ARCHIVE_EXTENSION = ['zip', '7z', 'rar', 'tar', 'gz', 'z', 'deb', 'rpm', 'pkg']; + public const AUDIO_EXTENSION = ['mp3', 'wav', 'wma', 'ogg']; + public const VIDEO_EXTENSION = ['mp4', 'flv', 'vob', 'wmv', 'swf', 'mpg', 'mpeg', 'mov', 'mkv', 'h264', 'avi']; + public const SPREADSHEET_EXTENSION = ['xls', 'xlsm', 'xlr', 'ods']; + public const IMAGE_EXTENSION = ['png', 'gif', 'jpg', 'jpeg', 'tif', 'tiff', 'bmp', 'svg', 'ico']; public const DIRECTORY = ['collection']; + public const SYSTEM_EXTENSION = ['bak', 'dll', 'sys', 'tmp', 'msi', 'so', 'exe', 'bin', 'iso']; /** * Constructor. @@ -63,6 +65,8 @@ final class FileUtils return ExtensionType::CODE; } elseif (\in_array($extension, self::TEXT_EXTENSION)) { return ExtensionType::TEXT; + } elseif (\in_array($extension, self::WORD_EXTENSION)) { + return ExtensionType::WORD; } elseif (\in_array($extension, self::PRESENTATION_EXTENSION)) { return ExtensionType::PRESENTATION; } elseif (\in_array($extension, self::PDF_EXTENSION)) { diff --git a/tests/System/File/ExtensionTypeTest.php b/tests/System/File/ExtensionTypeTest.php index c7a2946b0..5d535d622 100644 --- a/tests/System/File/ExtensionTypeTest.php +++ b/tests/System/File/ExtensionTypeTest.php @@ -23,7 +23,7 @@ class ExtensionTypeTest extends \PHPUnit\Framework\TestCase { public function testEnums() : void { - self::assertCount(12, ExtensionType::getConstants()); + self::assertCount(13, ExtensionType::getConstants()); self::assertEquals(ExtensionType::getConstants(), \array_unique(ExtensionType::getConstants())); self::assertEquals(1, ExtensionType::UNKNOWN); @@ -38,5 +38,6 @@ class ExtensionTypeTest extends \PHPUnit\Framework\TestCase self::assertEquals(512, ExtensionType::IMAGE); self::assertEquals(1024, ExtensionType::EXECUTABLE); self::assertEquals(2048, ExtensionType::DIRECTORY); + self::assertEquals(4096, ExtensionType::WORD); } }