FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Client.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Rsi\Fred;
4 
5 class Client extends Component{
6 
7  const TABLET = 'tablet';
8  const PHONE = 'phone';
9  const BOT = 'bot';
10 
12 
13  protected $_detection = null;
14  protected $_type = null;
15 
16  protected function getDetection(){
17  if(!$this->_detection) $this->_detection = new \Detection\MobileDetect();
18  return $this->_detection;
19  }
20 
21  protected function getMobile(){
22  return in_array($this->type,$this->mobileTypes);
23  }
24 
25  protected function getType(){
26  if($this->_type === null){
27  $this->_type = $this->session->type;
28  if($this->_type === null){
29  $type = false;
30  if($this->detection->is('Bot') || $this->detection->is('MobileBot')) $type = self::BOT;
31  elseif($this->detection->isMobile()) $type = $this->detection->isTablet() ? self::TABLET : self::PHONE;
32  $this->session->type = $this->_type = $type;
33  }
34  }
35  return $this->_type;
36  }
37 
38  protected function getUserAgent(){
39  return $this->detection->getUserAgent();
40  }
41 
42 }
Rsi\Fred\Client\BOT
const BOT
Definition: Client.php:9
Rsi\Fred\Client\getUserAgent
getUserAgent()
Definition: Client.php:38
Rsi\Fred\Client\PHONE
const PHONE
Definition: Client.php:8
Rsi\Fred\Client
Definition: Client.php:5
Rsi\Fred\Client\$_detection
$_detection
Definition: Client.php:13
Rsi\Fred\Component
Basic component class.
Definition: Component.php:8
Rsi\Fred\Client\$mobileTypes
$mobileTypes
Definition: Client.php:11
Rsi\Fred\Client\getDetection
getDetection()
Definition: Client.php:16
Rsi\Fred\Client\getType
getType()
Definition: Client.php:25
Rsi\Fred\Client\getMobile
getMobile()
Definition: Client.php:21
Rsi\Fred\Client\TABLET
const TABLET
Definition: Client.php:7
Rsi\Fred\Client\$_type
$_type
Definition: Client.php:14
Rsi\Fred
Definition: Alive.php:3