Skip to content

Commit

Permalink
Merge pull request #31 from woothee/support-vivaldi
Browse files Browse the repository at this point in the history
Support Vivaldi
  • Loading branch information
yuya-takeyama committed May 17, 2016
2 parents 5ade505 + c356e92 commit c7dcc98
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/AgentCategory/Browser/Vivaldi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Woothee\AgentCategory\Browser;

use Woothee\AgentCategory\AbstractCategory;
use Woothee\DataSet;

class Vivaldi extends AbstractCategory
{
public static function challenge($ua, &$result)
{
if (strpos($ua, 'Vivaldi') === false) {
return false;
}

$version = DataSet::VALUE_UNKNOWN;

if (preg_match('/Vivaldi\/([.0-9]+)/Du', $ua, $matches)) {
$version = $matches[1];
}

static::updateMap($result, DataSet::get('Vivaldi'));
static::updateVersion($result, $version);

return true;
}
}
5 changes: 5 additions & 0 deletions src/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Woothee\AgentCategory\Browser\Opera;
use Woothee\AgentCategory\Browser\SafariChrome;
use Woothee\AgentCategory\Browser\Sleipnir;
use Woothee\AgentCategory\Browser\Vivaldi;
use Woothee\AgentCategory\Browser\Webview;
use Woothee\AgentCategory\Crawler\Crawlers;
use Woothee\AgentCategory\Crawler\Google;
Expand Down Expand Up @@ -66,6 +67,10 @@ public function tryBrowser($ua, &$result)
return true;
}

if (Vivaldi::challenge($ua, $result)) {
return true;
}

if (SafariChrome::challenge($ua, $result)) {
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/DataSet.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Woothee;

// GENERATED from dataset.yml at Thu Aug 13 20:42:56 JST 2015 by yuya
// GENERATED from dataset.yml at Tue May 17 02:10:37 JST 2016 by yuya
class DataSet
{
const DATASET_KEY_LABEL = 'label';
Expand Down Expand Up @@ -88,6 +88,12 @@ class DataSet
'type' => 'browser',
'vendor' => 'Opera',
),
'Vivaldi' => array(
'label' => 'Vivaldi',
'name' => 'Vivaldi',
'type' => 'browser',
'vendor' => 'Vivaldi Technologies',
),
'Sleipnir' => array(
'label' => 'Sleipnir',
'name' => 'Sleipnir',
Expand Down
2 changes: 1 addition & 1 deletion woothee

0 comments on commit c7dcc98

Please sign in to comment.