diff --git a/composer.json b/composer.json index a1628f4..2e48936 100755 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "issues": "https://git.svoboda.works/mirzaev/minimal/issues" }, "require": { - "php": "~8.4" + "php": "~8.4", + "mobiledetect/mobiledetectlib": "^4.8" }, "suggest": { "mirzaev/baza": "Baza database", diff --git a/mirzaev/minimal/system/http/request.php b/mirzaev/minimal/system/http/request.php index 76b3808..f2c0794 100755 --- a/mirzaev/minimal/system/http/request.php +++ b/mirzaev/minimal/system/http/request.php @@ -11,6 +11,9 @@ use mirzaev\minimal\http\enumerations\method, mirzaev\minimal\http\enumerations\content, mirzaev\minimal\http\response; +// The smartphones detection library +use Detection\MobileDetect as mobile; + // Built-in libraries use DomainException as exception_domain, InvalidArgumentException as exception_argument, @@ -297,6 +300,50 @@ final class request get => $this->options ?? []; } + /** + * Smartphone + * + * @see https://docs.mobiledetect.net/home/usage-composer Documentation + * + * @var bool $smartphone The request was sent from a smartphone? + */ + public bool $smartphone { + // Read + get() { + if (!isset($this->{__PROPERTY__})) { + // The property is not initialized + + // Writing into the property + $this->{__PROPERTY__} = new mobile()->isMobile(); + } + + // Exit (success) + return $this->{__PROPERTY__}; + } + } + + /** + * Tablet + * + * @see https://docs.mobiledetect.net/home/usage-composer Documentation + * + * @var bool $tablet The request was sent from a tablet? + */ + public bool $tablet { + // Read + get() { + if (!isset($this->{__PROPERTY__})) { + // The property is not initialized + + // Writing into the property + $this->{__PROPERTY__} = new mobile()->isTablet(); + } + + // Exit (success) + return $this->{__PROPERTY__}; + } + } + /** * Constructor *