mimmi20/ua-result

该软件包已被废弃,不再维护。没有建议的替代软件包。

用于处理用户代理解析结果的 PHP 7.4+ 库


README

Latest Stable Version Latest Unstable Version License

代码状态

codecov Average time to resolve an issue Percentage of issues still open

描述

此库提供了一组表示用户代理检测结果的类。

要求

此库需要 PHP 7.4+。还需要一个 PSR-3 兼容的日志记录器。

安装

运行以下命令通过 Composer 安装

composer require mimmi20/ua-result

结果对象

结果对象是主要对象,仅包含其他对象。

浏览器对象

浏览器对象代表检测到的浏览器。

// get the result by detection or create it

$browser = $result->getBrowser();

// get the name
$name = $browser->getName();

// get the manufaturer
$manCompany = $browser->getManufacturer()->getName();
$manBrand   = $browser->getManufacturer()->getBrandName();

// get the version
$name = $browser->getVersion()->getVersion();

// get the type
$type  = $browser->getType()->getName();
$isbot = $browser->getType()->isBot();

引擎对象

引擎对象代表检测到的渲染引擎。

// get the result by detection or create it

$engine = $result->getEngine();

// get the name
$name = $engine->getName();

// get the manufaturer
$manCompany = $engine->getManufacturer()->getName();
$manBrand   = $engine->getManufacturer()->getBrandName();

// get the version
$name = $engine->getVersion()->getVersion();

设备对象

设备对象代表检测到的设备。

// get the result by detection or create it

$device = $result->getDevice();

// get the (code) name
$name = $device->getDeviceName();
// the device may have a different marketing name
$mname = $device->getMarketingName();

// get the manufaturer
$manCompany = $device->getManufacturer()->getName();
$manBrand   = $device->getManufacturer()->getBrandName();
// the device may be a branded version
$brand = $device->getBrand()->getBrandName();

// does the device support dual orientation?
$dualorien = $device->getDualOrientation();

// get the pointing method
$pointing = $device->getPointingMethod();

// get the display dimensions
$height = $device->getResolutionHeight();
$width  = $device->getResolutionWidth();

// get some more information about the device type
$type     = $device->getType()->getName();
$isPhone  = $device->getType()->isPhone();
$isTablet = $device->getType()->isTablet();

平台对象

平台对象代表检测到的平台。

// get the result by detection or create it

$platform = $result->getOs();

// get the (code) name
$name  = $platform->getName();
// the platform may have a different marketing name
$mname = $platform->getMarketingName();

// get the manufaturer
$manCompany = $platform->getManufacturer()->getName();
$manBrand   = $platform->getManufacturer()->getBrandName();

// get the version
$name = $platform->getVersion()->getVersion();

问题和功能请求

请在 GitHub 问题跟踪器 https://github.com/mimmi20/ua-result/issues 上报告您的问题并请求新功能。