gemz/useragent

This package is an easy wrapper for the Piwik Device Detector

Fund package maintenance!
Patreon

2.0.0 2022-10-05 11:40 UTC

This package is auto-updated.

Last update: 2024-05-05 14:52:28 UTC


README

Latest Version on Packagist GitHub Tests Action Status Quality Score Total Downloads

This package uses the Piwik Device Detector Package and builds a thin wrapper around it.

Installation

You can install the package via composer:

composer require gemz/useragent

Usage

use Gemz\Useragent;

// static instantiation
$parser = Useragent::agent($string);

// object instantiation
$parser = new Useragent($string);

// Get Result
$result = $parser->result(); // returns array

[
    'isBot' => false, 
    'browserType' => 'browser',
    'browserEngine' => 'Blink',
    'browserName' => 'Chrome',
    'browserVersion' => '79.0',
    'device' => 'desktop',
    'deviceModel' => '',
    'deviceBrand' => '', 
    'os' => 'Mac',
    'isMobile' => false,
]

// Set a new useragent
$result = $parser
    ->for($string)
    ->result();
    
// If you need full access to the piwik device detector instance 
$detector = $parser->parser(); // returns DeviceDetector\DeviceDetector;
$detector->... 

Testing

# unit tests
composer test

# you'll need a driver for code coverage
composer test-coverage

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email stefan@sriehl.com instead of using the issue tracker.

Credits

Support us

Gemz.io is maintained by Stefan Riehl. You'll find all open source projects on Gemz.io github.

License

The MIT License (MIT). Please see License File for more information.