Skip to content

Commit 3652b1d

Browse files
author
Gabriel Ames-Bull
committed
New version 2.0
- Made all method static for easier access - Improved OS detection - Added language detection - Made PSR-0 compliant - Added unit tests - Added Autoloader
1 parent 93a5ec0 commit 3652b1d

File tree

14 files changed

+1778
-1153
lines changed

14 files changed

+1778
-1153
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.DS_Store
2+
3+
# Thumbnails
4+
._*
5+
6+
# Files that might appear on external disk
7+
.Spotlight-V100
8+
.Trashes
9+
10+
# Windows image file caches
11+
Thumbs.db
12+
13+
# Folder config file
14+
Desktop.ini

Browser.php

Lines changed: 0 additions & 1076 deletions
This file was deleted.

composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "gavroche/browser",
3+
"type": "library",
4+
"description": "Detecting the user's browser, operating system and language.",
5+
"keywords": ["browser", "os", "operating system", "language", "detection"],
6+
"homepage": "https://github.com/gavroche/php-browser",
7+
"license": "GPL-2.0",
8+
"authors": [
9+
{
10+
"name": "Gabriel Bull",
11+
"email": "[email protected]"
12+
},
13+
{
14+
"name": "Chris Schuld",
15+
"email": "unknown"
16+
}
17+
],
18+
"require": {
19+
"php": ">=5.3"
20+
},
21+
"autoload": {
22+
"psr-0" : {
23+
"Browser" : "lib/"
24+
}
25+
}
26+
}

lib/Browser/Autoloader.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Browser;
4+
5+
/**
6+
* Autoloads Browser classes
7+
*
8+
* @package browser
9+
*/
10+
class Autoloader {
11+
/**
12+
* Register the autoloader
13+
*
14+
* @return void
15+
*/
16+
public static function register() {
17+
ini_set('unserialize_callback_func', 'spl_autoload_call');
18+
spl_autoload_register(array(new self, 'autoload'));
19+
}
20+
21+
/**
22+
* Autoloader
23+
*
24+
* @param string
25+
* @return void
26+
*/
27+
public static function autoload( $class ) {
28+
if (0 !== strpos($class, 'Browser\\')) {
29+
return;
30+
} else if (file_exists($file = dirname(__FILE__) . '/' . preg_replace('!^Browser\\\!', '', $class) . '.php')) {
31+
require $file;
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)