public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
public static function for_file ( $ file ) { if ( ! $ file || ( is_string ( $ file ) && ! file_exists ( $ file ) ) ) { return null ; } // Ensure we have a File instance to work with if ( is_string ( $ file ) ) { /** @var File $fileObject */ $ fileObject = File :: create ( ) ; $ fileObject -> setFromLocalFile ( $ file ) ; $ file = $ fileObject ; } $ extension = $ file -> getExtension ( ) ; $ mime = $ file -> getMimeType ( ) ; foreach ( self :: get_extractor_classes ( ) as $ className ) { $ extractor = self :: get_extractor ( $ className ) ; // Skip unavailable extractors if ( ! $ extractor -> isAvailable ( ) ) { continue ; } // Check extension if ( $ extension && $ extractor -> supportsExtension ( $ extension ) ) { return $ extractor ; } // Check mime if ( $ mime && $ extractor -> supportsMime ( $ mime ) ) { return $ extractor ; } } }
Given a File object, decide which extractor instance to use to handle it

@param File|string $file
@return FileTextExtractor|null
Given a File object decide which extractor instance to use to handle it