Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
7 / 7
MobileDetectHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
7 / 7
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 __invoke
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
<?php
namespace Neilime\MobileDetect\View\Helper;
use Zend\View\Helper\AbstractHelper;
class MobileDetectHelper extends AbstractHelper
{
    /**
     * @var \Mobile_Detect
     */
    protected $mobileDetect;
    /**
     * @param \Mobile_Detect $mobileDetect
     */
    public function __construct(\Mobile_Detect $mobileDetect)
    {
        $this->mobileDetect = $mobileDetect;
    }
    /**
     * Retrieve Mobile-detect service
     *
     * @param \Zend\Http\Headers $oHeaders
     *
     * @return \Mobile_Detect
     */
    public function __invoke(\Zend\Http\Headers $oHeaders = null)
    {
        if ($oHeaders) {
            $this->mobileDetect->setHttpHeaders($oHeaders->toArray());
            $this->mobileDetect->setUserAgent($oHeaders->get('user-agent')->getFieldValue());
        }
        return $this->mobileDetect;
    }
}