-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5535 from Wazelin/feature/add-engine-version
Implemented Engine version parser.
- Loading branch information
Showing
22 changed files
with
4,187 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* Device Detector - The Universal Device Detection library for parsing User Agents | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later | ||
*/ | ||
namespace DeviceDetector\Parser\Client\Browser\Engine; | ||
|
||
use DeviceDetector\Parser\Client\ClientParserAbstract; | ||
|
||
/** | ||
* Class Version | ||
* | ||
* Client parser for browser engine version detection | ||
* | ||
* @package DeviceDetector\Parser\Client\Browser\Engine | ||
*/ | ||
class Version extends ClientParserAbstract | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $engine; | ||
|
||
/** | ||
* Version constructor. | ||
* | ||
* @param string $ua | ||
* @param string $engine | ||
*/ | ||
public function __construct($ua, $engine) | ||
{ | ||
parent::__construct($ua); | ||
|
||
$this->engine = $engine; | ||
} | ||
|
||
public function parse() | ||
{ | ||
if (empty($this->engine)) { | ||
return ''; | ||
} | ||
|
||
preg_match("~$this->engine\s*/?\s*((?(?=\d+\.\d)\d+[.\d]*|\d{1,7}(?=(?:\D|$))))~i", $this->userAgent, $matches); | ||
|
||
if (!$matches) { | ||
return ''; | ||
} | ||
|
||
return array_pop($matches); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.