Skip to content

gemzio/useragent

Repository files navigation

Gemz Useragent Parser

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.

About

Simple wrapper for the Piwik Device Detector

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages