GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#1)
by
unknown
05:33
created

DeviceDetect::getDeviceDetector()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace CrossKnowledge\DeviceDetectBundle\Services;
4
5
use Symfony\Component\HttpFoundation\RequestStack;
6
use \Doctrine\Common\Cache\CacheProvider;
7
8
class DeviceDetect
9
{
10
    /** @var RequestStack */
11
    protected $requestStack;
12
13
    /** @var \DeviceDetector\DeviceDetector */
14
    protected $deviceDetector;
15
16
    /** @var Cache */
17
    protected $cacheManager;
18
19
    /** @var  [] */
20
    protected $deviceDetectorOptions;
21
22
    public function __construct(RequestStack $stack, CacheProvider $cache, $deviceDetectorOptions)
23
    {
24
        $this->cacheManager = $cache;
0 ignored issues
show
Documentation Bug introduced by
It seems like $cache of type object<Doctrine\Common\Cache\CacheProvider> is incompatible with the declared type object<CrossKnowledge\De...tBundle\Services\Cache> of property $cacheManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25
        $this->requestStack = $stack;
26
        $this->setOptions($deviceDetectorOptions);
27
28
        if (null !== $this->requestStack && $this->requestStack->getCurrentRequest()) {
29
            $userAgent = $this->requestStack->getCurrentRequest()->headers->get('User-Agent');
30
        } else {
31
            $userAgent = '';
32
        }
33
34
        $this->deviceDetector = new \DeviceDetector\DeviceDetector($userAgent);
35
        $this->deviceDetector->setCache($this->getCacheManager());
36
37
        if (!empty($this->deviceDetectorOptions['discard_bot_information'])) {
38
            $this->deviceDetector->discardBotInformation();
39
        }
40
41
        if (!empty($this->deviceDetectorOptions['skip_bot_detection'])) {
42
            $this->deviceDetector->skipBotDetection();
43
        }
44
45
        $this->deviceDetector->parse();
46
    }
47
48
    public function isTablet()
49
    {
50
        return $this->deviceDetector->isTablet();
51
    }
52
53
    public function isMobile()
54
    {
55
        if ($this->deviceDetector->isTablet()) {
56
            return false;
57
        }
58
59
        return $this->deviceDetector->isMobile();
60
    }
61
62
    public function isDesktop()
63
    {
64
        return $this->deviceDetector->isDesktop();
65
    }
66
67
    public function getCacheManager()
68
    {
69
        return $this->cacheManager;
70
    }
71
72
    public function setOptions($deviceDetectorOptions)
73
    {
74
        $this->deviceDetectorOptions = $deviceDetectorOptions;
75
    }
76
77
    public function getDeviceDetector()
78
    {
79
        return $this->deviceDetector;
80
    }
81
}
82