public function validateFile(File $file)
    {
        if (!$this->acceptsExtension($file->getExtension())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with extension %s", $file->getExtension()));
        }

        if (!$this->acceptsMime($file->getMime())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime of %s", $file->getMime()));
        }

        if (!$this->acceptsMimeType($file->getMimeType())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime type of %s", $file->getMimeType()));
        }

        if (!$this->acceptsMimeEncoding($file->getMimeEncoding())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime encoding of %s", $file->getMimeEncoding()));
        }

        if ($this->getRequiredType()) {
            if ($this->getRequiredType() !== $file->getType()) {
                throw new Exception\InvalidFileException(sprintf("This definition only accept files of type %s", $this->getRequiredType()));
            }
        }

        if (!$this->getAllowDirectory() && $file->isDir()) {
            throw new Exception\InvalidFileException("This definition cannot accept a directory as input");
        }

        return true;
    }
public function validateFile(File $file)
    {
        if (!$this->acceptsExtension($file->getExtension())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with extension %s", $file->getExtension()));
        }

        if (!$this->acceptsMime($file->getMime())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime of %s", $file->getMime()));
        }

        if (!$this->acceptsMimeType($file->getMimeType())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime type of %s", $file->getMimeType()));
        }

        if (!$this->acceptsMimeEncoding($file->getMimeEncoding())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime encoding of %s", $file->getMimeEncoding()));
        }

        if ($this->getRequiredType()) {
            if ($this->getRequiredType() !== $file->getType()) {
                throw new Exception\InvalidFileException(sprintf("This definition only accept files of type %s", $this->getRequiredType()));
            }
        }

        if (!$this->getAllowDirectory() && $file->isDir()) {
            throw new Exception\InvalidFileException("This definition cannot accept a directory as input");
        }

        return true;
    }
public function validateFile ( File $ file ) { if ( ! $ this -> acceptsExtension ( $ file -> getExtension ( ) ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition does not accept files with extension %s" , $ file -> getExtension ( ) ) ) ; } if ( ! $ this -> acceptsMime ( $ file -> getMime ( ) ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition does not accept files with mime of %s" , $ file -> getMime ( ) ) ) ; } if ( ! $ this -> acceptsMimeType ( $ file -> getMimeType ( ) ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition does not accept files with mime type of %s" , $ file -> getMimeType ( ) ) ) ; } if ( ! $ this -> acceptsMimeEncoding ( $ file -> getMimeEncoding ( ) ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition does not accept files with mime encoding of %s" , $ file -> getMimeEncoding ( ) ) ) ; } if ( $ this -> getRequiredType ( ) ) { if ( $ this -> getRequiredType ( ) !== $ file -> getType ( ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition only accept files of type %s" , $ this -> getRequiredType ( ) ) ) ; } } if ( ! $ this -> getAllowDirectory ( ) && $ file -> isDir ( ) ) { throw new Exception \ InvalidFileException ( "This definition cannot accept a directory as input" ) ; } return true ; }
Return true if FileHandlerDefinition accepts a given file, otherwise throw an exception on failure.

@param  File    $file
@return boolean
Return true if FileHandlerDefinition accepts a given file otherwise throw an exception on failure .