public static function serve($source, $destination, $options = [])
    {
        if (empty($source)) {
            throw new ServeFailedException('Source argument missing');
        }
        if (empty($destination)) {
            throw new ServeFailedException('Destination argument missing');
        }
        if (@!file_exists($source)) {
            throw new ServeFailedException('Source file was not found');
        }

        list($whatToServe, $whyToServe, $msg) = DecideWhatToServe::decide($source, $destination, $options);

        Header::setHeader('X-WebP-Convert-Action: ' . $msg);

        switch ($whatToServe) {
            case 'destination':
                self::serveDestination($destination, $options);
                break;

            case 'source':
                self::serveOriginal($source, $options);
                break;

            case 'fresh-conversion':
                ServeFreshConversion::serve($source, $destination, $options);
                break;

            case 'report':
                Report::convertAndReport($source, $destination, $options);
                break;
        }
    }
public static function serve($source, $destination, $options = [])
    {
        if (empty($source)) {
            throw new ServeFailedException('Source argument missing');
        }
        if (empty($destination)) {
            throw new ServeFailedException('Destination argument missing');
        }
        if (@!file_exists($source)) {
            throw new ServeFailedException('Source file was not found');
        }

        list($whatToServe, $whyToServe, $msg) = DecideWhatToServe::decide($source, $destination, $options);

        Header::setHeader('X-WebP-Convert-Action: ' . $msg);

        switch ($whatToServe) {
            case 'destination':
                self::serveDestination($destination, $options);
                break;

            case 'source':
                self::serveOriginal($source, $options);
                break;

            case 'fresh-conversion':
                ServeFreshConversion::serve($source, $destination, $options);
                break;

            case 'report':
                Report::convertAndReport($source, $destination, $options);
                break;
        }
    }
public static function serve ( $ source , $ destination , $ options = [ ] ) { if ( empty ( $ source ) ) { throw new ServeFailedException ( 'Source argument missing' ) ; } if ( empty ( $ destination ) ) { throw new ServeFailedException ( 'Destination argument missing' ) ; } if ( @ ! file_exists ( $ source ) ) { throw new ServeFailedException ( 'Source file was not found' ) ; } list ( $ whatToServe , $ whyToServe , $ msg ) = DecideWhatToServe :: decide ( $ source , $ destination , $ options ) ; Header :: setHeader ( 'X-WebP-Convert-Action: ' . $ msg ) ; switch ( $ whatToServe ) { case 'destination' : self :: serveDestination ( $ destination , $ options ) ; break ; case 'source' : self :: serveOriginal ( $ source , $ options ) ; break ; case 'fresh-conversion' : ServeFreshConversion :: serve ( $ source , $ destination , $ options ) ; break ; case 'report' : Report :: convertAndReport ( $ source , $ destination , $ options ) ; break ; } }
Serve converted webp.

@param   string  $source              path to source file
@param   string  $destination         path to destination
@param   array   $options (optional)  options for serving/converting

@throws  ServeFailedException  If an argument is invalid or source file does not exists
@return  void
Serve converted webp .