DeviceDetector::afterDetection()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * @author Serhii Nekhaienko <[email protected]>
4
 * @license GPL
5
 * @copyright Serhii Nekhaienko &copy 2020
6
 * @version 2.0.0
7
 * @project endorphin-studio/browser-detector-detection
8
 */
9
10
namespace EndorphinStudio\Detector\Detection;
11
12
/**
13
 * Detector for device
14
 * Class DeviceDetector
15
 * @package EndorphinStudio\Detector\Detection
16
 */
17
class DeviceDetector extends BrowserDetector
18
{
19
    /**
20
     * @var string Key in config
21
     */
22
    protected $configKey = 'device';
23
24
    protected function afterDetection()
25
    {
26
        if (
27
            \array_key_exists('originalInfo', $this->additionalInfo) &&
28
            \array_key_exists('hasModel', $this->additionalInfo['originalInfo']) &&
29
            $this->additionalInfo['originalInfo']['hasModel'] === true) {
30
            // detect model
31
            $detector = new ModelDetector();
32
            $detector->init($this->detector);
33
            $detector->detect($this->additionalInfo);
34
        }
35
        parent::afterDetection();
36
    }
37
}