Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.

Commit a4c8e1e

Browse files
committed
Update docs and Requirements
1 parent 668e389 commit a4c8e1e

File tree

6 files changed

+47
-46
lines changed

6 files changed

+47
-46
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/.idea/
2-
*.txt
1+
/.idea
2+
/vendor
3+
*.lock
34
*.DS_Store
45
.Spotlight-V100
5-
.Trashes
6+
.Trashes

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
}
1313
],
1414
"require": {
15-
"sinergi/browser-detector": "^6.0"
15+
"php": ">=5.5.9",
16+
"sinergi/browser-detector": "^6.1"
1617
},
1718
"autoload": {
1819
"psr-4": {

config/browser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3-
use Sinergi\BrowserDetector\Browser;
43
use Sinergi\BrowserDetector\Os;
4+
use Sinergi\BrowserDetector\Browser;
55

66
return [
77

readme.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ Require this package with composer using the following command
66
```
77
composer require tibian/browser-requirement
88
```
9+
910
After updating composer, add the service provider to the providers array in config/app.php
10-
```
11+
```php
1112
TiBian\BrowserRequirement\BrowserRequirementServiceProvider::class,
1213
```
1314

1415
### Config
1516
Publish the config file to change it as you wish.
1617
```
18+
php artisan vendor:publish
19+
20+
or
21+
1722
php artisan vendor:publish --provider="TiBian\BrowserRequirement\BrowserRequirementServiceProvider" --tag=config
1823
```
1924

2025
### Usage
2126
Open the config/browser.php and you are ready to start.
2227

2328
>Let set-up minimum Browser Requirement for OS X and Windows...
24-
```
29+
```php
2530
Os::OSX => [
2631
Browser::CHROME => 25,
2732
Browser::FIREFOX => 25,
@@ -41,22 +46,16 @@ Os::WINDOWS => [
4146
### Routes
4247
This is a Example from the Routes you need, you are free to customize the Routes like you wish.
4348

44-
```
49+
```php
4550
Route::get("requirement-browser", "ErrorsController@browser")
4651
->name('requirement::browser');
4752
```
4853

49-
```
54+
```php
5055
Route::get("/", "PagesController@index")
5156
->name('home');
5257
```
5358

54-
### I'm looking for:
55-
- Individuals who can contribute to the Documentation.
56-
- Participation in other Open Source Projects.
57-
58-
> Visit my Web Site and learn more [about me](https://tibian.me)
59-
6059
##### Any idea for new projects, feel free to Contact me.
6160

6261
##### Thank you for visiting my Repository.

src/BrowserRequirement.php

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,20 @@ class BrowserRequirement
5050
protected $isUnsupportedBrowser;
5151

5252
/**
53-
* OS Object
54-
*
55-
* @var object Os
53+
* @var \Sinergi\BrowserDetector\Os
5654
*/
5755
protected $os;
5856

5957
/**
60-
* Browser Object
61-
*
62-
* @var object Browser
58+
* @var \Sinergi\BrowserDetector\Browser
6359
*/
6460
protected $browser;
6561

6662
/**
6763
* BrowserRequirement constructor.
6864
*
69-
* @param Browser $browser
70-
* @param Os $os
65+
* @param \Sinergi\BrowserDetector\Browser $browser
66+
* @param \Sinergi\BrowserDetector\Os $os
7167
*/
7268
public function __construct(Browser $browser, Os $os)
7369
{
@@ -83,14 +79,34 @@ public function __construct(Browser $browser, Os $os)
8379
}
8480

8581
/**
86-
* Determine if the Browser is Unsupported
82+
* Handle an incoming request.
8783
*
84+
* @param \Illuminate\Http\Request $request
85+
* @param \Closure $next
86+
*
87+
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
88+
*/
89+
public function handle(Request $request, Closure $next)
90+
{
91+
if ($this->isUnsupportedBrowser) {
92+
if (! $this->isUnsupportedPage()) {
93+
return redirect($this->routeUnsupportedBrowser);
94+
}
95+
} else {
96+
if ($this->isUnsupportedPage()) {
97+
return redirect($this->routeSupportedBrowser);
98+
}
99+
}
100+
101+
return $next($request);
102+
}
103+
104+
/**
88105
* @return bool
89106
*/
90-
private function isUnsupportedBrowser()
107+
protected function isUnsupportedBrowser()
91108
{
92109
if (array_key_exists($this->os->getName(), $this->supportedVersions)) {
93-
94110
$browsers = $this->supportedVersions[$this->os->getName()];
95111

96112
foreach ($browsers as $browser => $version) {
@@ -106,24 +122,10 @@ private function isUnsupportedBrowser()
106122
}
107123

108124
/**
109-
* Handle an incoming request.
110-
*
111-
* @param \Illuminate\Http\Request $request
112-
* @param \Closure $next
113-
* @return mixed
125+
* @return bool
114126
*/
115-
public function handle(Request $request, Closure $next)
127+
protected function isUnsupportedPage()
116128
{
117-
if ($this->isUnsupportedBrowser) {
118-
if ($this->currentPage != $this->routeUnsupportedBrowser) {
119-
return redirect($this->routeUnsupportedBrowser);
120-
}
121-
} else {
122-
if ($this->currentPage == $this->routeUnsupportedBrowser) {
123-
return redirect($this->routeSupportedBrowser);
124-
}
125-
}
126-
127-
return $next($request);
129+
return $this->currentPage == $this->routeUnsupportedBrowser;
128130
}
129131
}

src/BrowserRequirementServiceProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BrowserRequirementServiceProvider extends ServiceProvider
1515
/**
1616
* Bootstrap the application services.
1717
*
18-
* @return void
18+
* @param \Illuminate\Routing\Router $router
1919
*/
2020
public function boot(Router $router)
2121
{
@@ -28,8 +28,6 @@ public function boot(Router $router)
2828

2929
/**
3030
* Register the application services.
31-
*
32-
* @return void
3331
*/
3432
public function register()
3533
{

0 commit comments

Comments
 (0)