Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Report
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 convertAndReport
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2namespace WebPConvert\Serve;
3
4use WebPConvert\Helpers\InputValidator;
5use WebPConvert\Loggers\EchoLogger;
6use WebPConvert\WebPConvert;
7
8/**
9 * Class for generating a HTML report of converting an image.
10 *
11 * @package    WebPConvert
12 * @author     Bjørn Rosell <it@rosell.dk>
13 * @since      Class available since Release 2.0.0
14 */
15class Report
16{
17    public static function convertAndReport($source, $destination, $options)
18    {
19        InputValidator::checkSourceAndDestination($source, $destination);
20        ?>
21<html>
22    <head>
23        <style>td {vertical-align: top} table {color: #666}</style>
24        <script>
25            function showOptions(elToHide) {
26                document.getElementById('options').style.display='block';
27                elToHide.style.display='none';
28            }
29        </script>
30    </head>
31    <body>
32        <table>
33            <tr><td><i>source:</i></td><td><?php echo htmlentities($source) ?></td></tr>
34            <tr><td><i>destination:</i></td><td><?php echo htmlentities($destination) ?><td></tr>
35        </table>
36        <br>
37        <?php
38        try {
39            $echoLogger = new EchoLogger();
40            $options['log-call-arguments'] = true;
41            WebPConvert::convert($source, $destination, $options['convert'], $echoLogger);
42        } catch (\Exception $e) {
43            $msg = $e->getMessage();
44            echo '<b>' . $msg . '</b>';
45
46            //echo '<p>Rethrowing exception for your convenience</p>';
47            //throw ($e);
48        }
49        ?>
50    </body>
51    </html>
52        <?php
53    }
54}