@@ -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}
0 commit comments