• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mimmi20 / ua-device-type / 18822923241

26 Oct 2025 07:51PM UTC coverage: 99.281% (-0.7%) from 100.0%
18822923241

Pull #615

github

mimmi20
add dependency
Pull Request #615: update device types

35 of 36 new or added lines in 1 file covered. (97.22%)

1 existing line in 1 file now uncovered.

138 of 139 relevant lines covered (99.28%)

28.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.28
/src/Type.php
1
<?php
2

3
/**
4
 * This file is part of the ua-device-type package.
5
 *
6
 * Copyright (c) 2015-2025, Thomas Mueller <mimmi20@live.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types = 1);
13

14
namespace UaDeviceType;
15

16
use Override;
17

18
use function mb_strtolower;
19

20
enum Type: string implements TypeInterface
21
{
22
    case Bot = 'bot';
23

24
    case Brailledisplay = 'braille-display';
25

26
    case Brailletouch = 'braille-touch';
27

28
    case Car = 'car';
29

30
    case CarEntertainmentSystem = 'car-entertainment-system';
31

32
    case Console = 'console';
33

34
    case Desktop = 'desktop';
35

36
    case DigitalCamera = 'digital-camera';
37

38
    case EbookReader = 'ebook-reader';
39

40
    case FeaturePhone = 'feature-phone';
41

42
    case FonePad = 'fone-pad';
43

44
    case FridgeFreezer = 'fridge-freezer';
45

46
    case Laptop = 'laptop';
47

48
    case MediaPlayer = 'media-player';
49

50
    case MobileConsole = 'mobile-console';
51

52
    case MobileDevice = 'mobile-device';
53

54
    case MobileMediaPlayer = 'mobile-media-player';
55

56
    case MobilePhone = 'mobile-phone';
57

58
    case Phablet = 'phablet';
59

60
    case Phone = 'phone';
61

62
    case Printer = 'printer';
63

64
    case SmartDisplay = 'smart-display';
65

66
    case Smartphone = 'smartphone';
67

68
    case SmartSpeaker = 'smart-speaker';
69

70
    case SmartWatch = 'smart-watch';
71

72
    case Tablet = 'tablet';
73

74
    case Tv = 'tv';
75

76
    case TvConsole = 'tv-console';
77

78
    case TvMediaPlayer = 'tv-media-player';
79

80
    case TvSettopBox = 'tv-set-top-box';
81

82
    case TvStick = 'tv-stick';
83

84
    case VideoPhone = 'video-phone';
85

86
    case Unknown = 'unknown';
87

88
    case Wearable = 'wearable';
89

90
    /**
91
     * @throws void
92
     *
93
     * @api
94
     */
95
    public static function fromName(string | null $name): self
45✔
96
    {
97
        if ($name === null) {
45✔
NEW
UNCOV
98
            return self::Unknown;
×
99
        }
100

101
        return match (mb_strtolower($name)) {
45✔
102
            'bot' => self::Bot,
1✔
103
            'brailledisplay', 'braille-display' => self::Brailledisplay,
1✔
104
            'brailletouch', 'braille-touch' => self::Brailletouch,
1✔
105
            'car' => self::Car,
1✔
106
            'carentertainmentsystem', 'car-entertainment-system', 'car entertainment system' => self::CarEntertainmentSystem,
1✔
107
            'console' => self::Console,
1✔
108
            'desktop' => self::Desktop,
1✔
109
            'digitalcamera', 'digital-camera', 'digital camera' => self::DigitalCamera,
1✔
110
            'ebookreader', 'ebook-reader', 'ebook reader' => self::EbookReader,
1✔
111
            'featurephone', 'feature-phone', 'feature phone' => self::FeaturePhone,
1✔
112
            'fonepad', 'fone-pad' => self::FonePad,
1✔
113
            'fridgefreezer', 'fridge-freezer', 'fridge freezer' => self::FridgeFreezer,
1✔
114
            'laptop' => self::Laptop,
1✔
115
            'mediaplayer', 'media-player', 'media player' => self::MediaPlayer,
1✔
116
            'mobileconsole', 'mobile-console', 'mobile console' => self::MobileConsole,
1✔
117
            'mobiledevice', 'mobile-device', 'mobile device' => self::MobileDevice,
1✔
118
            'mobilemediaplayer', 'mobile-media-player', 'mobile media player', 'portable media player' => self::MobileMediaPlayer,
2✔
119
            'mobilephone', 'mobile-phone', 'mobile phone' => self::MobilePhone,
1✔
120
            'phablet' => self::Phablet,
1✔
121
            'phone', 'non-mobile-phone', 'nonmobilephone', 'non-mobile phone' => self::Phone,
4✔
122
            'printer' => self::Printer,
1✔
123
            'smartdisplay', 'smart-display', 'smart display' => self::SmartDisplay,
1✔
124
            'smartphone' => self::Smartphone,
1✔
125
            'smartspeaker', 'smart-speaker', 'smart speaker', 'speaker' => self::SmartSpeaker,
3✔
126
            'smartwatch', 'smart-watch', 'watch' => self::SmartWatch,
3✔
127
            'tablet' => self::Tablet,
1✔
128
            'tv', 'smart-tv', 'tv device' => self::Tv,
3✔
129
            'tvconsole', 'tv-console', 'tv console' => self::TvConsole,
1✔
130
            'tvmediaplayer', 'tv-media-player', 'tv media player' => self::TvMediaPlayer,
1✔
131
            'tvsettopbox', 'tv-set-top-box', 'tv settop box' => self::TvSettopBox,
1✔
132
            'tvstick', 'tv-stick', 'tv stick' => self::TvStick,
1✔
133
            'videophone', 'video-phone' => self::VideoPhone,
1✔
134
            'wearable' => self::Wearable,
2✔
135
            default => self::Unknown,
45✔
136
        };
45✔
137
    }
138

139
    /**
140
     * Returns the type name of the device
141
     *
142
     * @throws void
143
     */
144
    #[Override]
45✔
145
    public function getType(): string
146
    {
147
        return $this->value;
45✔
148
    }
149

150
    /**
151
     * Returns the name of the type
152
     *
153
     * @throws void
154
     */
155
    #[Override]
45✔
156
    public function getName(): string
157
    {
158
        return match ($this) {
45✔
159
            self::CarEntertainmentSystem => 'Car Entertainment System',
45✔
160
            self::DigitalCamera => 'Digital Camera',
44✔
161
            self::EbookReader => 'Ebook Reader',
43✔
162
            self::FeaturePhone => 'Feature Phone',
42✔
163
            self::FridgeFreezer => 'Fridge Freezer',
41✔
164
            self::MediaPlayer => 'Media Player',
40✔
165
            self::MobileConsole => 'Mobile Console',
39✔
166
            self::MobileDevice => 'Mobile Device',
38✔
167
            self::MobileMediaPlayer => 'Mobile Media Player',
37✔
168
            self::MobilePhone => 'Mobile Phone',
35✔
169
            self::SmartDisplay => 'Smart Display',
34✔
170
            self::SmartSpeaker => 'Smart Speaker',
33✔
171
            self::Tv => 'TV',
30✔
172
            self::TvConsole => 'TV Console',
27✔
173
            self::TvMediaPlayer => 'TV Media Player',
26✔
174
            self::TvSettopBox => 'TV SetTop Box',
25✔
175
            self::TvStick => 'TV Stick',
24✔
176
            default => $this->name,
45✔
177
        };
45✔
178
    }
179

180
    /**
181
     * Returns True, if the device is a mobile device
182
     *
183
     * @throws void
184
     */
185
    #[Override]
45✔
186
    public function isMobile(): bool
187
    {
188
        return match ($this) {
45✔
189
            self::Brailletouch, self::DigitalCamera, self::EbookReader, self::FeaturePhone, self::FonePad, self::MobileConsole, self::MobileDevice, self::MobileMediaPlayer, self::MobilePhone, self::Phablet, self::Smartphone, self::Tablet, self::SmartWatch, self::Wearable => true,
45✔
190
            default => false,
45✔
191
        };
45✔
192
    }
193

194
    /**
195
     * Returns True, if the device is a desktop device
196
     *
197
     * @throws void
198
     */
199
    #[Override]
45✔
200
    public function isDesktop(): bool
201
    {
202
        return match ($this) {
45✔
203
            self::Brailledisplay, self::Desktop, self::Laptop => true,
45✔
204
            default => false,
45✔
205
        };
45✔
206
    }
207

208
    /**
209
     * Returns True, if the device is a gaming device
210
     *
211
     * @throws void
212
     */
213
    #[Override]
45✔
214
    public function isConsole(): bool
215
    {
216
        return match ($this) {
45✔
217
            self::Console, self::MobileConsole, self::TvConsole => true,
45✔
218
            default => false,
45✔
219
        };
45✔
220
    }
221

222
    /**
223
     * Returns True, if the device is a tv device
224
     *
225
     * @throws void
226
     */
227
    #[Override]
45✔
228
    public function isTv(): bool
229
    {
230
        return match ($this) {
45✔
231
            self::Tv, self::TvConsole, self::TvMediaPlayer, self::TvSettopBox, self::TvStick => true,
45✔
232
            default => false,
45✔
233
        };
45✔
234
    }
235

236
    /**
237
     * Returns True, if the device is a phone device
238
     *
239
     * @throws void
240
     */
241
    #[Override]
45✔
242
    public function isPhone(): bool
243
    {
244
        return match ($this) {
45✔
245
            self::FeaturePhone, self::FonePad, self::MobilePhone, self::Phablet, self::Phone, self::Smartphone, self::VideoPhone => true,
45✔
246
            default => false,
45✔
247
        };
45✔
248
    }
249

250
    /**
251
     * Returns True, if the device is a tablet device
252
     *
253
     * @throws void
254
     */
255
    #[Override]
45✔
256
    public function isTablet(): bool
257
    {
258
        return match ($this) {
45✔
259
            self::Brailletouch, self::FonePad, self::MediaPlayer, self::Tablet => true,
45✔
260
            default => false,
45✔
261
        };
45✔
262
    }
263

264
    /**
265
     * Returns True, if the device is a tablet device
266
     *
267
     * @throws void
268
     */
269
    #[Override]
45✔
270
    public function hasDisplay(): bool
271
    {
272
        return match ($this) {
45✔
273
            self::Bot, self::Car, self::Console, self::Desktop, self::SmartSpeaker, self::TvConsole, self::TvMediaPlayer, self::TvSettopBox, self::TvStick, self::Unknown => false,
45✔
274
            default => true,
45✔
275
        };
45✔
276
    }
277

278
    /**
279
     * Returns True, if the device is a tablet device
280
     *
281
     * @throws void
282
     */
283
    #[Override]
45✔
284
    public function hasTouch(): bool
285
    {
286
        return match ($this) {
45✔
287
            self::Bot, self::Brailledisplay, self::Car, self::Console, self::Desktop, self::FeaturePhone, self::Laptop, self::MobileDevice, self::MobilePhone, self::Phone, self::SmartSpeaker, self::Tv, self::TvConsole, self::TvMediaPlayer, self::TvSettopBox, self::TvStick, self::Unknown => false,
45✔
288
            default => true,
45✔
289
        };
45✔
290
    }
291

292
    /**
293
     * Returns a description for the device
294
     *
295
     * @throws void
296
     */
297
    #[Override]
45✔
298
    public function getDescription(): string
299
    {
300
        return match ($this) {
45✔
301
            self::Bot => 'a device type related to bots',
45✔
302
            self::Brailledisplay => 'a device without touch but with a braille output',
44✔
303
            self::Brailletouch => 'a device with touch and a braille output',
43✔
304
            self::Car => 'a device implemented in a car, but not for entertainment',
42✔
305
            self::CarEntertainmentSystem => 'a entertainment device implemented in a car',
41✔
306
            self::Console => 'a non-mobile device without its own screen mainly used to play games',
40✔
307
            self::Desktop => 'a non-mobile device without its own screen',
39✔
308
            self::DigitalCamera => 'a mobile device to create photos',
38✔
309
            self::EbookReader => 'a mobile device with its own screen to read E-Books',
37✔
310
            self::FeaturePhone => 'a mobile device with its own screen, mostly without touch or older platforms',
36✔
311
            self::FonePad => 'a tablet device which is able to make phone calls',
35✔
312
            self::FridgeFreezer => 'a fridge/freezer with a touch screen',
34✔
313
            self::Laptop => 'a non-mobile device with its own screen',
33✔
314
            self::MediaPlayer => 'a non-mobile entertainment device with its own screen without the ability to make phone calls',
32✔
315
            self::MobileConsole => 'a mobile device with its own screen without ability to make phone calls, mainly used to gaming',
31✔
316
            self::MobileDevice => 'a general mobile device with its own screen without the ability to make phone calls',
30✔
317
            self::MobileMediaPlayer => 'a mobile entertainment device with its own screen without the ability to make phone calls',
29✔
318
            self::MobilePhone => 'a general mobile device which is able to make phone calls',
27✔
319
            self::Phablet => 'a mobile device with its own screen which is able to make phone calls',
26✔
320
            self::Phone => 'a non-mobile device without touch display which is able to make phone calls',
25✔
321
            self::Printer => 'a printer with a touch screen',
21✔
322
            self::SmartDisplay => 'a non-mobile device with its own touch screen',
20✔
323
            self::Smartphone => 'a mobile device with its own touch screen which is able to make phone calls',
19✔
324
            self::SmartSpeaker => 'a smart speaker without its own screen',
18✔
325
            self::SmartWatch => 'a smart watch',
15✔
326
            self::Tablet => 'a mobile device with its own screen which is not able to make phone calls',
12✔
327
            self::Tv => 'a tv',
11✔
328
            self::TvConsole => 'a non-mobile device which uses a tv as screen, mainly used for gaming',
8✔
329
            self::TvMediaPlayer => 'a general media player which uses a tv as screen',
7✔
330
            self::TvSettopBox => 'a media player which uses a tv as screen',
6✔
331
            self::TvStick => 'a media player in the form of a USB stick which uses a tv as screen',
5✔
332
            self::VideoPhone => 'a non-mobile device with touch display which is able to make phone calls',
4✔
333
            self::Wearable => 'a general mobile device with its own touch screen',
3✔
334
            default => 'an unknown device',
45✔
335
        };
45✔
336
    }
337
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc