Debian Codegraph @

includes/search/Entity/SearchResultThumbnail.php

raw symbols SCIP
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 * @return string
90 */
91 public function getUrl(): string {
92 return $this->url;
93 }
94
95 /**
96 * Width of the representation in pixels or null if not applicable
97 * @return int|null
98 */
99 public function getWidth(): ?int {
100 return $this->width;
101 }
102
103 /**
104 * Height of the representation in pixels or null if not applicable
105 * @return int|null
106 */
107 public function getHeight(): ?int {
108 return $this->height;
109 }
110
111 /**
112 * Internet mime type for the representation, like "image/png" or "audio/mp3"
113 * @return string
114 */
115 public function getMimeType(): string {
116 return $this->mimeType;
117 }
118
119 /**
120 * @deprecated since 1.41, Do not use, resource intensive and thus
121 * degrade performance.
122 *
123 * Size of the representation in bytes or null if not applicable
124 * @return int|null
125 */
126 public function getSize(): ?int {
127 if ( is_callable( $this->size ) ) {
128 $this->size = ( $this->size )();
129 }
130
131 return $this->size;
132 }
133
134 /**
135 * Duration of the representation in seconds or null if not applicable
136 * @return int|null
137 */
138 public function getDuration(): ?int {
139 return $this->duration;
140 }
141
142 /**
143 * String that represent file identity in storage or null
144 * @return string|null
145 */
146 public function getName(): ?string {
147 return $this->name;
148 }
149 }