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