/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (isset($_SERVER['HTTP_USER_AGENT']) && amtUtils::isSmartPhone($_SERVER['HTTP_USER_AGENT']) || $request->has(requestScopeUtils::SMART_PHONE_KEY)) { requestScopeUtils::set(requestScopeUtils::SMART_PHONE_KEY, 't'); } else { requestScopeUtils::set(requestScopeUtils::SMART_PHONE_KEY, 'f'); } return $next($request); }
/** * isSmartPhoneのテスト * * @see App\Common\amtUtils */ public function testIsSmartPhone() { // iPhone $this->assertTrue(amtUtils::isSmartPhone("iPhone_dummy")); $this->assertTrue(amtUtils::isSmartPhone("dummy_iPhone")); $this->assertTrue(amtUtils::isSmartPhone("dummy_iPhone_dummy")); // Android $this->assertFalse(amtUtils::isSmartPhone("Android_dummy")); $this->assertFalse(amtUtils::isSmartPhone("dummy_Android")); $this->assertFalse(amtUtils::isSmartPhone("dummy_Android_dummy")); $this->assertFalse(amtUtils::isSmartPhone("Mobile_dummy")); $this->assertFalse(amtUtils::isSmartPhone("dummy_Mobile")); $this->assertFalse(amtUtils::isSmartPhone("dummy_Mobile_dummy")); $this->assertTrue(amtUtils::isSmartPhone("dummy_Mobile_Android_dummy")); $this->assertTrue(amtUtils::isSmartPhone("Mobile_dummy_Android")); $this->assertTrue(amtUtils::isSmartPhone("Android_dummy_Mobile")); // Windows Phone $this->assertTrue(amtUtils::isSmartPhone("Windows Phone_dummy")); $this->assertTrue(amtUtils::isSmartPhone("dummy_Windows Phone")); $this->assertTrue(amtUtils::isSmartPhone("dummy_Windows Phone_dummy")); }