PageRenderTime 150ms CodeModel.GetById 61ms app.highlight 45ms RepoModel.GetById 35ms app.codeStats 1ms

/concreteOLD/libraries/3rdparty/Zend/Http/UserAgent.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 853 lines | 433 code | 84 blank | 336 comment | 53 complexity | 48399995b0bbd6368f07d4feadb401ba MD5 | raw file
  1<?php
  2/**
  3 * Zend Framework
  4 *
  5 * LICENSE
  6 *
  7 * This source file is subject to the new BSD license that is bundled
  8 * with this package in the file LICENSE.txt.
  9 * It is also available through the world-wide-web at this URL:
 10 * http://framework.zend.com/license/new-bsd
 11 * If you did not receive a copy of the license and are unable to
 12 * obtain it through the world-wide-web, please send an email
 13 * to license@zend.com so we can send you a copy immediately.
 14 *
 15 * @category   Zend
 16 * @package    Zend_Http_UserAgent
 17 * @subpackage UserAgent
 18 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 20 */
 21
 22/**
 23 * Lists of User Agent chains for testing :
 24 *
 25 * - http://www.useragentstring.com/layout/useragentstring.php
 26 * - http://user-agent-string.info/list-of-ua
 27 * - http://www.user-agents.org/allagents.xml
 28 * - http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones
 29 * - http://www.mobilemultimedia.be/fr/
 30 *
 31 * @category   Zend
 32 * @package    Zend_Http_UserAgent
 33 * @subpackage UserAgent
 34 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 35 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 36 */
 37class Zend_Http_UserAgent implements Serializable
 38{
 39    /**
 40     * 'desktop' by default if the sequence return false for each item or is empty
 41     */
 42    const DEFAULT_IDENTIFICATION_SEQUENCE = 'mobile,desktop';
 43
 44    /**
 45     * Default persitent storage adapter : Session or NonPersitent
 46     */
 47    const DEFAULT_PERSISTENT_STORAGE_ADAPTER = 'Session';
 48
 49    /**
 50     * 'desktop' by default if the sequence return false for each item
 51     */
 52    const DEFAULT_BROWSER_TYPE = 'desktop';
 53
 54    /**
 55     * Default User Agent chain to prevent empty value
 56     */
 57    const DEFAULT_HTTP_USER_AGENT = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)';
 58
 59    /**
 60     * Default Http Accept param to prevent empty value
 61     */
 62    const DEFAULT_HTTP_ACCEPT = "application/xhtml+xml";
 63
 64    /**
 65     * Default markup language
 66     */
 67    const DEFAULT_MARKUP_LANGUAGE = "xhtml";
 68
 69    /**
 70     * Browser type
 71     *
 72     * @var string
 73     */
 74    protected $_browserType;
 75
 76    /**
 77     * Browser type class
 78     *
 79     * Map of browser types to classes.
 80     *
 81     * @var array
 82     */
 83    protected $_browserTypeClass = array();
 84
 85    /**
 86     * Array to store config
 87     *
 88     * Default values are provided to ensure specific keys are present at
 89     * instantiation.
 90     *
 91     * @var array
 92     */
 93    protected $_config = array(
 94        'identification_sequence' => self::DEFAULT_IDENTIFICATION_SEQUENCE,
 95        'storage'                 => array(
 96            'adapter'             => self::DEFAULT_PERSISTENT_STORAGE_ADAPTER,
 97        ),
 98    );
 99
100    /**
101     * Identified device
102     *
103     * @var Zend_Http_UserAgent_Device
104     */
105    protected $_device;
106
107    /**
108     * Whether or not this instance is immutable.
109     *
110     * If true, none of the following may be modified:
111     * - $_server
112     * - $_browserType
113     * - User-Agent (defined in $_server)
114     * - HTTP Accept value (defined in $_server)
115     * - $_storage
116     *
117     * @var bool
118     */
119    protected $_immutable = false;
120
121    /**
122     * Plugin loaders
123     * @var array
124     */
125    protected $_loaders = array();
126
127    /**
128     * Valid plugin loader types
129     * @var array
130     */
131    protected $_loaderTypes = array('storage', 'device');
132
133    /**
134     * Trace of items matched to identify the browser type
135     *
136     * @var array
137     */
138    protected $_matchLog = array();
139
140    /**
141     * Server variable
142     *
143     * @var array
144     */
145    protected $_server;
146
147    /**
148     * Persistent storage handler
149     *
150     * @var Zend_Http_UserAgent_Storage
151     */
152    protected $_storage;
153
154    /**
155     * Constructor
156     *
157     * @param  null|array|Zend_Config|ArrayAccess $options
158     * @return void
159     */
160    public function __construct($options = null)
161    {
162        if (null !== $options) {
163            $this->setOptions($options);
164        }
165    }
166
167    /**
168     * Serialized representation of the object
169     *
170     * @return string
171     */
172    public function serialize()
173    {
174        $device = $this->getDevice();
175        $spec = array(
176            'browser_type' => $this->_browserType,
177            'config'       => $this->_config,
178            'device_class' => get_class($device),
179            'device'       => $device->serialize(),
180            'user_agent'   => $this->getServerValue('http_user_agent'),
181            'http_accept'  => $this->getServerValue('http_accept'),
182        );
183        return serialize($spec);
184    }
185
186    /**
187     * Unserialize a previous representation of the object
188     *
189     * @param  string $serialized
190     * @return void
191     */
192    public function unserialize($serialized)
193    {
194        $spec = unserialize($serialized);
195
196        $this->setOptions($spec);
197
198        // Determine device class and ensure the class is loaded
199        $deviceClass          = $spec['device_class'];
200        if (!class_exists($deviceClass)) {
201            $this->_getUserAgentDevice($this->getBrowserType());
202        }
203
204        // Get device specification and instantiate
205        $deviceSpec            = unserialize($spec['device']);
206        $deviceSpec['_config'] = $this->getConfig();
207        $deviceSpec['_server'] = $this->getServer();
208        $this->_device = new $deviceClass($deviceSpec);
209    }
210
211    /**
212     * Configure instance
213     *
214     * @param  array|Zend_Config|ArrayAccess $options
215     * @return Zend_Http_UserAgent
216     */
217    public function setOptions($options)
218    {
219        if ($options instanceof Zend_Config) {
220            $options = $options->toArray();
221        }
222
223        if (!is_array($options)
224            && !$options instanceof ArrayAccess
225            && !$options instanceof Traversable
226        ) {
227            require_once 'Zend/Http/UserAgent/Exception.php';
228            throw new Zend_Http_UserAgent_Exception(sprintf(
229                'Invalid argument; expected array, Zend_Config object, or object implementing ArrayAccess and Traversable; received %s',
230                (is_object($options) ? get_class($options) : gettype($options))
231            ));
232        }
233
234        // Set $_SERVER first
235        if (isset($options['server'])) {
236            $this->setServer($options['server']);
237            unset($options['server']);
238        }
239
240        // Get plugin loaders sorted
241        if (isset($options['plugin_loader'])) {
242            $plConfig = $options['plugin_loader'];
243            if (is_array($plConfig) || $plConfig instanceof Traversable) {
244                foreach ($plConfig as $type => $class) {
245                    $this->setPluginLoader($type, $class);
246                }
247            }
248            unset($plConfig, $options['plugin_loader']);
249        }
250
251        // And then loop through the remaining options
252        $config = array();
253        foreach ($options as $key => $value) {
254            switch (strtolower($key)) {
255                case 'browser_type':
256                    $this->setBrowserType($value);
257                    break;
258                case 'http_accept':
259                    $this->setHttpAccept($value);
260                    break;
261                case 'user_agent':
262                    $this->setUserAgent($value);
263                    break;
264                default:
265                    // Cache remaining options for $_config
266                    $config[$key] = $value;
267                    break;
268            }
269        }
270        $this->setConfig($config);
271
272        return $this;
273    }
274
275    /**
276     * Comparison of the UserAgent chain and browser signatures.
277     *
278     * The comparison is case-insensitive : the browser signatures must be in lower
279     * case
280     *
281     * @param  string $deviceClass Name of class against which a match will be attempted
282     * @return bool
283     */
284    protected function _match($deviceClass)
285    {
286        // Validate device class
287        $r = new ReflectionClass($deviceClass);
288        if (!$r->implementsInterface('Zend_Http_UserAgent_Device')) {
289            throw new Zend_Http_UserAgent_Exception(sprintf(
290                'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device',
291                $deviceClass
292            ));
293        }
294
295        $userAgent = $this->getUserAgent();
296
297        // Call match method on device class
298        return call_user_func(
299            array($deviceClass, 'match'),
300            $userAgent,
301            $this->getServer()
302        );
303    }
304
305    /**
306     * Loads class for a user agent device
307     *
308     * @param  string $browserType Browser type
309     * @return string
310     * @throws Zend_Loader_PluginLoader_Exception if unable to load UA device
311     */
312    protected function _getUserAgentDevice($browserType)
313    {
314        $browserType = strtolower($browserType);
315        if (isset($this->_browserTypeClass[$browserType])) {
316            return $this->_browserTypeClass[$browserType];
317        }
318
319        if (isset($this->_config[$browserType])
320            && isset($this->_config[$browserType]['device'])
321        ) {
322            $deviceConfig = $this->_config[$browserType]['device'];
323            if (is_array($deviceConfig) && isset($deviceConfig['classname'])) {
324                $device = (string) $deviceConfig['classname'];
325                if (!class_exists($device)) {
326                    require_once 'Zend/Http/UserAgent/Exception.php';
327                    throw new Zend_Http_UserAgent_Exception(sprintf(
328                        'Invalid classname "%s" provided in device configuration for browser type "%s"',
329                        $device,
330                        $browserType
331                    ));
332                }
333            } elseif (is_array($deviceConfig) && isset($deviceConfig['path'])) {
334                $loader = $this->getPluginLoader('device');
335                $path   = $deviceConfig['path'];
336                $prefix = isset($deviceConfig['prefix']) ? $deviceConfig['prefix'] : 'Zend_Http_UserAgent';
337                $loader->addPrefixPath($prefix, $path);
338
339                $device = $loader->load($browserType);
340            } else {
341                $loader = $this->getPluginLoader('device');
342                $device = $loader->load($browserType);
343            }
344        } else {
345            $loader = $this->getPluginLoader('device');
346            $device = $loader->load($browserType);
347        }
348
349        $this->_browserTypeClass[$browserType] = $device;
350
351        return $device;
352    }
353
354    /**
355     * Returns the User Agent value
356     *
357     * If $userAgent param is null, the value of $_server['HTTP_USER_AGENT'] is
358     * returned.
359     *
360     * @return string
361     */
362    public function getUserAgent()
363    {
364        if (null === ($ua = $this->getServerValue('http_user_agent'))) {
365            $ua = self::DEFAULT_HTTP_USER_AGENT;
366            $this->setUserAgent($ua);
367        }
368
369        return $ua;
370    }
371
372    /**
373     * Force or replace the UA chain in $_server variable
374     *
375     * @param  string $userAgent Forced UserAgent chain
376     * @return Zend_Http_UserAgent
377     */
378    public function setUserAgent($userAgent)
379    {
380        $this->setServerValue('http_user_agent', $userAgent);
381        return $this;
382    }
383
384    /**
385     * Returns the HTTP Accept server param
386     *
387     * @param  string $httpAccept (option) forced HTTP Accept chain
388     * @return string
389     */
390    public function getHttpAccept($httpAccept = null)
391    {
392        if (null === ($accept = $this->getServerValue('http_accept'))) {
393            $accept = self::DEFAULT_HTTP_ACCEPT;
394            $this->setHttpAccept($accept);
395        }
396        return $accept;
397    }
398
399    /**
400     * Force or replace the HTTP_ACCEPT chain in self::$_server variable
401     *
402     * @param  string $httpAccept Forced HTTP Accept chain
403     * @return Zend_Http_UserAgent
404     */
405    public function setHttpAccept($httpAccept)
406    {
407        $this->setServerValue('http_accept', $httpAccept);
408        return $this;
409    }
410
411    /**
412     * Returns the persistent storage handler
413     *
414     * Session storage is used by default unless a different storage adapter
415     * has been set via the "persistent_storage_adapter" key. That key should
416     * contain either a fully qualified class name, or a short name that
417     * resolves via the plugin loader.
418     *
419     * @param  string $browser Browser identifier (User Agent chain)
420     * @return Zend_Http_UserAgent_Storage
421     */
422    public function getStorage($browser = null)
423    {
424        if (null === $browser) {
425            $browser = $this->getUserAgent();
426        }
427        if (null === $this->_storage) {
428            $config  = $this->_config['storage'];
429            $adapter = $config['adapter'];
430            if (!class_exists($adapter)) {
431                $loader = $this->getPluginLoader('storage');
432                $adapter = $loader->load($adapter);
433                $loader = $this->getPluginLoader('storage');
434            }
435            $options = array('browser_type' => $browser);
436            if (isset($config['options'])) {
437                $options = array_merge($options, $config['options']);
438            }
439            $this->setStorage(new $adapter($options));
440        }
441        return $this->_storage;
442    }
443
444    /**
445     * Sets the persistent storage handler
446     *
447     * @param  Zend_Http_UserAgent_Storage $storage
448     * @return Zend_Http_UserAgent
449     */
450    public function setStorage(Zend_Http_UserAgent_Storage $storage)
451    {
452        if ($this->_immutable) {
453            require_once 'Zend/Http/UserAgent/Exception.php';
454            throw new Zend_Http_UserAgent_Exception(
455                'The User-Agent device object has already been retrieved; the storage object is now immutable'
456            );
457        }
458
459        $this->_storage = $storage;
460        return $this;
461    }
462
463    /**
464     * Clean the persistent storage
465     *
466     * @param  string $browser Browser identifier (User Agent chain)
467     * @return void
468     */
469    public function clearStorage($browser = null)
470    {
471        $this->getStorage($browser)->clear();
472    }
473
474    /**
475     * Get user configuration
476     *
477     * @return array
478     */
479    public function getConfig()
480    {
481        return $this->_config;
482    }
483
484    /**
485     * Config parameters is an Array or a Zend_Config object
486     *
487     * The allowed parameters are :
488     * - the identification sequence (can be empty) => desktop browser type is the
489     * default browser type returned
490     * $config['identification_sequence'] : ',' separated browser types
491     * - the persistent storage adapter
492     * $config['persistent_storage_adapter'] = "Session" or "NonPersistent"
493     * - to add or replace a browser type device
494     * $config[(type)]['device']['path']
495     * $config[(type)]['device']['classname']
496     * - to add or replace a browser type features adapter
497     * $config[(type)]['features']['path']
498     * $config[(type)]['features']['classname']
499     *
500     * @param  mixed $config (option) Config array
501     * @return Zend_Http_UserAgent
502     */
503    public function setConfig($config = array())
504    {
505        if ($config instanceof Zend_Config) {
506            $config = $config->toArray();
507        }
508
509        // Verify that Config parameters are in an array.
510        if (!is_array($config) && !$config instanceof Traversable) {
511            require_once 'Zend/Http/UserAgent/Exception.php';
512            throw new Zend_Http_UserAgent_Exception(sprintf(
513                'Config parameters must be in an array or a Traversable object; received "%s"',
514                (is_object($config) ? get_class($config) : gettype($config))
515            ));
516        }
517
518        if ($config instanceof Traversable) {
519            $tmp = array();
520            foreach ($config as $key => $value) {
521                $tmp[$key] = $value;
522            }
523            $config = $tmp;
524            unset($tmp);
525        }
526
527        $this->_config = array_merge($this->_config, $config);
528        return $this;
529    }
530
531    /**
532     * Returns the device object
533     *
534     * This is the object that will contain the various discovered device
535     * capabilities.
536     *
537     * @return Zend_Http_UserAgent_Device $device
538     */
539    public function getDevice()
540    {
541        if (null !== $this->_device) {
542            return $this->_device;
543        }
544
545        $userAgent = $this->getUserAgent();
546
547        // search an existing identification in the session
548        $storage = $this->getStorage($userAgent);
549
550        if (!$storage->isEmpty()) {
551            // If the user agent and features are already existing, the
552            // Zend_Http_UserAgent object is serialized in the session
553            $object = $storage->read();
554            $this->unserialize($object);
555        } else {
556            // Otherwise, the identification is made and stored in the session.
557            // Find the browser type:
558            $this->setBrowserType($this->_matchUserAgent());
559            $this->_createDevice();
560
561            // put the result in storage:
562            $this->getStorage($userAgent)
563                 ->write($this->serialize());
564        }
565
566        // Mark the object as immutable
567        $this->_immutable = true;
568
569        // Return the device instance
570        return $this->_device;
571    }
572
573    /**
574     * Retrieve the browser type
575     *
576     * @return string $browserType
577     */
578    public function getBrowserType()
579    {
580        return $this->_browserType;
581    }
582
583    /**
584     * Set the browser "type"
585     *
586     * @param string $browserType
587     * @return Zend_Http_UserAgent
588     */
589    public function setBrowserType($browserType)
590    {
591        if ($this->_immutable) {
592            require_once 'Zend/Http/UserAgent/Exception.php';
593            throw new Zend_Http_UserAgent_Exception(
594                'The User-Agent device object has already been retrieved; the browser type is now immutable'
595            );
596        }
597
598        $this->_browserType = $browserType;
599        return $this;
600    }
601
602    /**
603     * Retrieve the "$_SERVER" array
604     *
605     * Basically, the $_SERVER array or an equivalent container storing the
606     * data that will be introspected.
607     *
608     * If the value has not been previously set, it sets itself from the
609     * $_SERVER superglobal.
610     *
611     * @return array
612     */
613    public function getServer()
614    {
615        if (null === $this->_server) {
616            $this->setServer($_SERVER);
617        }
618        return $this->_server;
619    }
620
621    /**
622     * Set the "$_SERVER" array
623     *
624     * Basically, the $_SERVER array or an equivalent container storing the
625     * data that will be introspected.
626     *
627     * @param  array|ArrayAccess $server
628     * @return void
629     * @throws Zend_Http_UserAgent_Exception on invalid parameter
630     */
631    public function setServer($server)
632    {
633        if ($this->_immutable) {
634            require_once 'Zend/Http/UserAgent/Exception.php';
635            throw new Zend_Http_UserAgent_Exception(
636                'The User-Agent device object has already been retrieved; the server array is now immutable'
637            );
638        }
639
640        if (!is_array($server) && !$server instanceof Traversable) {
641            require_once 'Zend/Http/UserAgent/Exception.php';
642            throw new Zend_Http_UserAgent_Exception(sprintf(
643                'Expected an array or object implementing Traversable; received %s',
644                (is_object($server) ? get_class($server) : gettype($server))
645            ));
646        }
647
648        // Get an array if we don't have one
649        if ($server instanceof ArrayObject) {
650            $server = $server->getArrayCopy();
651        } elseif ($server instanceof Traversable) {
652            $tmp = array();
653            foreach ($server as $key => $value) {
654                $tmp[$key] = $value;
655            }
656            $server = $tmp;
657            unset($tmp);
658        }
659
660        // Normalize key case
661        $server = array_change_key_case($server, CASE_LOWER);
662
663        $this->_server = $server;
664        return $this;
665    }
666
667    /**
668     * Retrieve a server value
669     *
670     * @param  string $key
671     * @return mixed
672     */
673    public function getServerValue($key)
674    {
675        $key    = strtolower($key);
676        $server = $this->getServer();
677        $return = null;
678        if (isset($server[$key])) {
679            $return = $server[$key];
680        }
681        unset($server);
682        return $return;
683    }
684
685    /**
686     * Set a server value
687     *
688     * @param  string|int|float $key
689     * @param  mixed $value
690     * @return void
691     */
692    public function setServerValue($key, $value)
693    {
694        if ($this->_immutable) {
695            require_once 'Zend/Http/UserAgent/Exception.php';
696            throw new Zend_Http_UserAgent_Exception(
697                'The User-Agent device object has already been retrieved; the server array is now immutable'
698            );
699        }
700
701        $server = $this->getServer(); // ensure it's been initialized
702        $key    = strtolower($key);
703        $this->_server[$key] = $value;
704        return $this;
705    }
706
707    /**
708     * Set plugin loader
709     *
710     * @param  string $type Type of plugin loader; one of 'storage', (?)
711     * @param  string|Zend_Loader_PluginLoader $loader
712     * @return Zend_Http_UserAgent
713     */
714    public function setPluginLoader($type, $loader)
715    {
716        $type       = $this->_validateLoaderType($type);
717
718        if (is_string($loader)) {
719            if (!class_exists($loader)) {
720                require_once 'Zend/Loader.php';
721                Zend_Loader::loadClass($loader);
722            }
723            $loader = new $loader();
724        } elseif (!is_object($loader)) {
725            require_once 'Zend/Http/UserAgent/Exception.php';
726            throw new Zend_Http_UserAgent_Exception(sprintf(
727                'Expected a plugin loader class or object; received %s',
728                gettype($loader)
729            ));
730        }
731        if (!$loader instanceof Zend_Loader_PluginLoader) {
732            require_once 'Zend/Http/UserAgent/Exception.php';
733            throw new Zend_Http_UserAgent_Exception(sprintf(
734                'Expected an object extending Zend_Loader_PluginLoader; received %s',
735                get_class($loader)
736            ));
737        }
738
739        $basePrefix = 'Zend_Http_UserAgent_';
740        $basePath   = 'Zend/Http/UserAgent/';
741        switch ($type) {
742            case 'storage':
743                $prefix = $basePrefix . 'Storage';
744                $path   = $basePath   . 'Storage';
745                break;
746            case 'device':
747                $prefix = $basePrefix;
748                $path   = $basePath;
749                break;
750        }
751        $loader->addPrefixPath($prefix, $path);
752        $this->_loaders[$type] = $loader;
753        return $this;
754    }
755
756    /**
757     * Get a plugin loader
758     *
759     * @param  string $type A valid plugin loader type; see {@link $_loaderTypes}
760     * @return Zend_Loader_PluginLoader
761     */
762    public function getPluginLoader($type)
763    {
764        $type = $this->_validateLoaderType($type);
765        if (!isset($this->_loaders[$type])) {
766            require_once 'Zend/Loader/PluginLoader.php';
767            $this->setPluginLoader($type, new Zend_Loader_PluginLoader());
768        }
769        return $this->_loaders[$type];
770    }
771
772    /**
773     * Validate a plugin loader type
774     *
775     * Verifies that it is in {@link $_loaderTypes}, and returns a normalized
776     * version of the type.
777     *
778     * @param  string $type
779     * @return string
780     * @throws Zend_Http_UserAgent_Exception on invalid type
781     */
782    protected function _validateLoaderType($type)
783    {
784        $type = strtolower($type);
785        if (!in_array($type, $this->_loaderTypes)) {
786            $types = implode(', ', $this->_loaderTypes);
787
788            require_once 'Zend/Http/UserAgent/Exception.php';
789            throw new Zend_Http_UserAgent_Exception(sprintf(
790                'Expected one of "%s" for plugin loader type; received "%s"',
791                $types,
792                (string) $type
793            ));
794        }
795        return $type;
796    }
797
798    /**
799     * Run the identification sequence to match the right browser type according to the
800     * user agent
801     *
802     * @return Zend_Http_UserAgent_Result
803     */
804    protected function _matchUserAgent()
805    {
806        $type = self::DEFAULT_BROWSER_TYPE;
807
808        // If we have no identification sequence, just return the default type
809        if (empty($this->_config['identification_sequence'])) {
810            return $type;
811        }
812
813        // Get sequence against which to match
814        $sequence = explode(',', $this->_config['identification_sequence']);
815
816        // If a browser type is already configured, push that to the front of the list
817        if (null !== ($browserType = $this->getBrowserType())) {
818            array_unshift($sequence, $browserType);
819        }
820
821        // Append the default browser type to the list if not alread in the list
822        if (!in_array($type, $sequence)) {
823            $sequence[] = $type;
824        }
825
826        // Test each type until we find a match
827        foreach ($sequence as $browserType) {
828            $browserType = trim($browserType);
829            $className   = $this->_getUserAgentDevice($browserType);
830
831            // Attempt to match this device class
832            if ($this->_match($className)) {
833                $type = $browserType;
834                $this->_browserTypeClass[$type] = $className;
835                break;
836            }
837        }
838
839        return $type;
840    }
841
842    /**
843     * Creates device object instance
844     *
845     * @return void
846     */
847    protected function _createDevice()
848    {
849        $browserType = $this->getBrowserType();
850        $classname   = $this->_getUserAgentDevice($browserType);
851        $this->_device = new $classname($this->getUserAgent(), $this->getServer(), $this->getConfig());
852    }
853}