Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
MediaTransformError
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 7
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 toHtml
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 toText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHtmlMsg
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMsg
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isError
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHttpStatusCode
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Base class for the output of file transformation methods.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Media
22 */
23
24use MediaWiki\Message\Message;
25use Wikimedia\Message\MessageParam;
26use Wikimedia\Message\MessageSpecifier;
27
28/**
29 * Basic media transform error class
30 *
31 * @newable
32 * @stable to extend
33 * @ingroup Media
34 */
35class MediaTransformError extends MediaTransformOutput {
36    /** @var Message */
37    private $msg;
38
39    /**
40     * @stable to call
41     *
42     * @param string $msg
43     * @param int $width
44     * @param int $height
45     * @param MessageParam|MessageSpecifier|string|int|float ...$args
46     */
47    public function __construct( $msg, $width, $height, ...$args ) {
48        $this->msg = wfMessage( $msg )->params( $args );
49        $this->width = (int)$width;
50        $this->height = (int)$height;
51        $this->url = false;
52        $this->path = false;
53    }
54
55    public function toHtml( $options = [] ) {
56        return "<div class=\"MediaTransformError\" style=\"" .
57            "width: {$this->width}px; height: {$this->height}px; display:inline-block;\">" .
58            $this->getHtmlMsg() .
59            "</div>";
60    }
61
62    public function toText() {
63        return $this->msg->text();
64    }
65
66    public function getHtmlMsg() {
67        return $this->msg->escaped();
68    }
69
70    public function getMsg() {
71        return $this->msg;
72    }
73
74    public function isError() {
75        return true;
76    }
77
78    /**
79     * @stable to override
80     *
81     * @return int
82     */
83    public function getHttpStatusCode() {
84        return 500;
85    }
86}