SimpleExcel\Parser\BaseParser::isFileReady PHP Метод

isFileReady() публичный Метод

Check whether file exists, valid, and readable
public isFileReady ( string $file_path ) : boolean
$file_path string Path to file
Результат boolean
    public function isFileReady($file_path)
    {
        // file exists?
        if (!file_exists($file_path)) {
            throw new \Exception('File ' . $file_path . ' doesn\'t exist', SimpleExcelException::FILE_NOT_FOUND);
            // extension valid?
        } else {
            if (strtoupper(pathinfo($file_path, PATHINFO_EXTENSION)) != strtoupper($this->file_extension)) {
                throw new \Exception('File extension ' . strtoupper(pathinfo($file_path, PATHINFO_EXTENSION)) . ' doesn\'t match with ' . $this->file_extension, SimpleExcelException::FILE_EXTENSION_MISMATCH);
                // file readable?
            } else {
                if (($handle = fopen($file_path, 'r')) === FALSE) {
                    throw new \Exception('Error reading the file in' . $file_path, SimpleExcelException::ERROR_READING_FILE);
                    fclose($handle);
                    // okay then
                } else {
                    return TRUE;
                }
            }
        }
    }