1 | <?php |
||
16 | class Endorphin extends AbstractProvider |
||
17 | { |
||
18 | /** |
||
19 | * Name of the provider |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name = 'Endorphin'; |
||
24 | |||
25 | /** |
||
26 | * Homepage of the provider |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $homepage = 'https://github.com/endorphin-studio/browser-detector'; |
||
31 | |||
32 | /** |
||
33 | * Composer package name |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $packageName = 'endorphin-studio/browser-detector'; |
||
38 | |||
39 | protected $detectionCapabilities = [ |
||
40 | |||
41 | 'browser' => [ |
||
42 | 'name' => true, |
||
43 | 'version' => true, |
||
44 | ], |
||
45 | |||
46 | 'renderingEngine' => [ |
||
47 | 'name' => false, |
||
48 | 'version' => false, |
||
49 | ], |
||
50 | |||
51 | 'operatingSystem' => [ |
||
52 | 'name' => true, |
||
53 | 'version' => true, |
||
54 | ], |
||
55 | |||
56 | 'device' => [ |
||
57 | 'model' => false, |
||
58 | 'brand' => false, |
||
59 | 'type' => true, |
||
60 | 'isMobile' => false, |
||
61 | 'isTouch' => false, |
||
62 | ], |
||
63 | |||
64 | 'bot' => [ |
||
65 | 'isBot' => true, |
||
66 | 'name' => true, |
||
67 | 'type' => true, |
||
68 | ], |
||
69 | ]; |
||
70 | |||
71 | protected $defaultValues = [ |
||
72 | |||
73 | 'general' => [ |
||
74 | '/^N\\\\A$/i', |
||
75 | ], |
||
76 | |||
77 | 'device' => [ |
||
78 | |||
79 | 'model' => [ |
||
80 | '/^Desktop/i', |
||
81 | ], |
||
82 | ], |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * Used for unitTests mocking |
||
87 | * |
||
88 | * @var EndorphinDetector\Detector |
||
89 | */ |
||
90 | private $parser; |
||
91 | |||
92 | /** |
||
93 | * |
||
94 | * @throws PackageNotLoadedException |
||
95 | */ |
||
96 | 14 | public function __construct() |
|
97 | { |
||
98 | 14 | if (! file_exists('vendor/' . $this->getPackageName() . '/composer.json')) { |
|
99 | 1 | throw new PackageNotLoadedException('You need to install the package ' . $this->getPackageName() . ' to use this provider'); |
|
100 | } |
||
101 | 13 | } |
|
102 | |||
103 | /** |
||
104 | * |
||
105 | * @param string $userAgent |
||
106 | * @return EndorphinDetector\DetectorResult |
||
107 | */ |
||
108 | 6 | public function getParser($userAgent) |
|
116 | |||
117 | /** |
||
118 | * |
||
119 | * @param EndorphinDetector\DetectorResult $resultRaw |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | 5 | private function hasResult(EndorphinDetector\DetectorResult $resultRaw) |
|
143 | |||
144 | /** |
||
145 | * |
||
146 | * @param Model\Bot $bot |
||
147 | * @param EndorphinDetector\Robot $resultRaw |
||
148 | */ |
||
149 | 1 | private function hydrateBot(Model\Bot $bot, EndorphinDetector\Robot $resultRaw) |
|
155 | |||
156 | /** |
||
157 | * |
||
158 | * @param Model\Browser $browser |
||
159 | * @param EndorphinDetector\Browser $resultRaw |
||
160 | */ |
||
161 | 3 | private function hydrateBrowser(Model\Browser $browser, EndorphinDetector\Browser $resultRaw) |
|
166 | |||
167 | /** |
||
168 | * |
||
169 | * @param Model\OperatingSystem $os |
||
170 | * @param EndorphinDetector\OS $resultRaw |
||
171 | */ |
||
172 | 3 | private function hydrateOperatingSystem(Model\OperatingSystem $os, EndorphinDetector\OS $resultRaw) |
|
177 | |||
178 | /** |
||
179 | * |
||
180 | * @param Model\Device $device |
||
181 | * @param EndorphinDetector\Device $resultRaw |
||
182 | */ |
||
183 | 3 | private function hydrateDevice(Model\Device $device, EndorphinDetector\Device $resultRaw) |
|
188 | |||
189 | 5 | public function parse($userAgent, array $headers = []) |
|
230 | } |
||
231 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.