mirror of
https://github.com/shlinkio/shlink.git
synced 2026-08-04 02:13:17 -05:00
Created persistence for device long URLs
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Model;
|
||||
|
||||
use Detection\MobileDetect;
|
||||
|
||||
enum DeviceType: string
|
||||
{
|
||||
case ANDROID = 'android';
|
||||
case IOS = 'ios';
|
||||
case DESKTOP = 'desktop';
|
||||
|
||||
public static function matchFromUserAgent(string $userAgent): ?self
|
||||
{
|
||||
$detect = new MobileDetect(null, $userAgent); // @phpstan-ignore-line
|
||||
|
||||
return match (true) {
|
||||
// $detect->is('iOS') && $detect->isTablet() => self::IOS, // TODO To detect iPad only
|
||||
// $detect->is('iOS') && ! $detect->isTablet() => self::IOS, // TODO To detect iPhone only
|
||||
// $detect->is('androidOS') && $detect->isTablet() => self::ANDROID, // TODO To detect Android tablets
|
||||
// $detect->is('androidOS') && ! $detect->isTablet() => self::ANDROID, // TODO To detect Android phones
|
||||
$detect->is('iOS') => self::IOS, // Detects both iPhone and iPad
|
||||
$detect->is('androidOS') => self::ANDROID, // Detects both android phones and android tablets
|
||||
! $detect->isMobile() && ! $detect->isTablet() => self::DESKTOP,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user