Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
SearchResultThumbnail | |
0.00% |
0 / 20 |
|
0.00% |
0 / 8 |
110 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
getUrl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getWidth | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeight | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMimeType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSize | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getDuration | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Search\Entity; |
4 | |
5 | /** |
6 | * Class that stores information about thumbnail, e. g. url, width and height |
7 | * @newable |
8 | */ |
9 | class SearchResultThumbnail { |
10 | /** |
11 | * Internet mime type for the representation, like "image/png" or "audio/mp3" |
12 | * @var string |
13 | */ |
14 | private $mimeType; |
15 | |
16 | /** |
17 | * Size of the representation in bytes or null if not applicable |
18 | * @var int|callable|null |
19 | */ |
20 | private $size; |
21 | |
22 | /** |
23 | * Duration of the representation in seconds or null if not applicable |
24 | * @var int|null |
25 | */ |
26 | private $duration; |
27 | |
28 | /** |
29 | * Full URL to the contents of the file |
30 | * @var string |
31 | */ |
32 | private $url; |
33 | |
34 | /** |
35 | * Width of the representation in pixels or null if not applicable |
36 | * @var int|null |
37 | */ |
38 | private $width; |
39 | |
40 | /** |
41 | * Height of the representation in pixels or null if not applicable |
42 | * @var int|null |
43 | */ |
44 | private $height; |
45 | |
46 | /** |
47 | * String that represent file identity in storage or null |
48 | * @var string|null |
49 | */ |
50 | private $name; |
51 | |
52 | /** |
53 | * @param string $mimeType Internet mime type for the representation, |
54 | * like "image/png" or "audio/mp3" |
55 | * @param int|callable|null $size Size of the representation in bytes. |
56 | * This parameter has been deprecated in 1.41 and will be removed. |
57 | * @param int|null $width Width of the representation in pixels or null if not applicable |
58 | * @param int|null $height Height of the representation in pixels or null if not applicable |
59 | * @param int|null $duration Duration of the representation in seconds or |
60 | * null if not applicable |
61 | * @param string $url full URL to the contents of the file |
62 | * @param string|null $name full URL to the contents of the file |
63 | */ |
64 | public function __construct( |
65 | string $mimeType, |
66 | /* int|callable|null */ $size, |
67 | ?int $width, |
68 | ?int $height, |
69 | ?int $duration, |
70 | string $url, |
71 | ?string $name |
72 | ) { |
73 | $this->mimeType = $mimeType; |
74 | if ( $size !== null ) { |
75 | wfDeprecated( |
76 | __METHOD__ . ': Passing $size is discouraged for performance reasons.', |
77 | '1.41' |
78 | ); |
79 | } |
80 | $this->width = $width; |
81 | $this->height = $height; |
82 | $this->duration = $duration; |
83 | $this->url = $url; |
84 | $this->name = $name; |
85 | } |
86 | |
87 | /** |
88 | * Full URL to the contents of the file |
89 | */ |
90 | public function getUrl(): string { |
91 | return $this->url; |
92 | } |
93 | |
94 | /** |
95 | * Width of the representation in pixels or null if not applicable |
96 | * @return int|null |
97 | */ |
98 | public function getWidth(): ?int { |
99 | return $this->width; |
100 | } |
101 | |
102 | /** |
103 | * Height of the representation in pixels or null if not applicable |
104 | * @return int|null |
105 | */ |
106 | public function getHeight(): ?int { |
107 | return $this->height; |
108 | } |
109 | |
110 | /** |
111 | * Internet mime type for the representation, like "image/png" or "audio/mp3" |
112 | * @return string |
113 | */ |
114 | public function getMimeType(): string { |
115 | return $this->mimeType; |
116 | } |
117 | |
118 | /** |
119 | * @deprecated since 1.41, Do not use, resource intensive and thus |
120 | * degrade performance. |
121 | * |
122 | * Size of the representation in bytes or null if not applicable |
123 | * @return int|null |
124 | */ |
125 | public function getSize(): ?int { |
126 | if ( is_callable( $this->size ) ) { |
127 | $this->size = ( $this->size )(); |
128 | } |
129 | |
130 | return $this->size; |
131 | } |
132 | |
133 | /** |
134 | * Duration of the representation in seconds or null if not applicable |
135 | * @return int|null |
136 | */ |
137 | public function getDuration(): ?int { |
138 | return $this->duration; |
139 | } |
140 | |
141 | /** |
142 | * String that represent file identity in storage or null |
143 | * @return string|null |
144 | */ |
145 | public function getName(): ?string { |
146 | return $this->name; |
147 | } |
148 | } |