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 
11  public $mobileTypes = [self::TABLET,self::PHONE];
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 }
const BOT
Definition: Client.php:9
const PHONE
Definition: Client.php:8
Basic component class.
Definition: Component.php:8
const TABLET
Definition: Client.php:7