Complex classes like WhatIsMyBrowserCom often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WhatIsMyBrowserCom, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 17 | class WhatIsMyBrowserCom extends AbstractHttpProvider  | 
            ||
| 18 | { | 
            ||
| 19 | /**  | 
            ||
| 20 | * Name of the provider  | 
            ||
| 21 | *  | 
            ||
| 22 | * @var string  | 
            ||
| 23 | */  | 
            ||
| 24 | protected $name = 'WhatIsMyBrowserCom';  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * Homepage of the provider  | 
            ||
| 28 | *  | 
            ||
| 29 | * @var string  | 
            ||
| 30 | */  | 
            ||
| 31 | protected $homepage = 'https://www.whatismybrowser.com/';  | 
            ||
| 32 | |||
| 33 | protected $detectionCapabilities = [  | 
            ||
| 34 | |||
| 35 | 'browser' => [  | 
            ||
| 36 | 'name' => true,  | 
            ||
| 37 | 'version' => true,  | 
            ||
| 38 | ],  | 
            ||
| 39 | |||
| 40 | 'renderingEngine' => [  | 
            ||
| 41 | 'name' => true,  | 
            ||
| 42 | 'version' => true,  | 
            ||
| 43 | ],  | 
            ||
| 44 | |||
| 45 | 'operatingSystem' => [  | 
            ||
| 46 | 'name' => true,  | 
            ||
| 47 | 'version' => true,  | 
            ||
| 48 | ],  | 
            ||
| 49 | |||
| 50 | 'device' => [  | 
            ||
| 51 | 'model' => true,  | 
            ||
| 52 | 'brand' => true,  | 
            ||
| 53 | |||
| 54 | 'type' => true,  | 
            ||
| 55 | 'isMobile' => false,  | 
            ||
| 56 | 'isTouch' => false,  | 
            ||
| 57 | ],  | 
            ||
| 58 | |||
| 59 | 'bot' => [  | 
            ||
| 60 | 'isBot' => true,  | 
            ||
| 61 | 'name' => true,  | 
            ||
| 62 | 'type' => true,  | 
            ||
| 63 | ],  | 
            ||
| 64 | ];  | 
            ||
| 65 | |||
| 66 | protected $defaultValues = [  | 
            ||
| 67 | |||
| 68 | 'general' => [],  | 
            ||
| 69 | |||
| 70 | 'browser' => [  | 
            ||
| 71 | 'name' => [  | 
            ||
| 72 | '/^Unknown Mobile Browser$/i',  | 
            ||
| 73 | '/^Unknown browser$/i',  | 
            ||
| 74 | '/^Webkit based browser$/i',  | 
            ||
| 75 | '/^a UNIX based OS$/i',  | 
            ||
| 76 | ],  | 
            ||
| 77 | ],  | 
            ||
| 78 | |||
| 79 | 'operatingSystem' => [  | 
            ||
| 80 | 'name' => [  | 
            ||
| 81 | '/^Smart TV$/i',  | 
            ||
| 82 | ],  | 
            ||
| 83 | ],  | 
            ||
| 84 | |||
| 85 | 'device' => [  | 
            ||
| 86 | 'model' => [  | 
            ||
| 87 | // HTC generic or large parser error (over 1000 found)  | 
            ||
| 88 | '/^HTC$/i',  | 
            ||
| 89 | '/^Mobile$/i',  | 
            ||
| 90 | '/^Android Phone$/i',  | 
            ||
| 91 | '/^Android Tablet$/i',  | 
            ||
| 92 | '/^Tablet$/i',  | 
            ||
| 93 | ],  | 
            ||
| 94 | ],  | 
            ||
| 95 | ];  | 
            ||
| 96 | |||
| 97 | private static $uri = 'http://api.whatismybrowser.com/api/v1/user_agent_parse';  | 
            ||
| 98 | |||
| 99 | private $apiKey;  | 
            ||
| 100 | |||
| 101 | 26 | public function __construct(Client $client, $apiKey)  | 
            |
| 107 | |||
| 108 | 1 | public function getVersion()  | 
            |
| 112 | |||
| 113 | /**  | 
            ||
| 114 | *  | 
            ||
| 115 | * @param string $userAgent  | 
            ||
| 116 | * @param array $headers  | 
            ||
| 117 | * @return stdClass  | 
            ||
| 118 | * @throws Exception\RequestException  | 
            ||
| 119 | */  | 
            ||
| 120 | 19 | protected function getResult($userAgent, array $headers)  | 
            |
| 188 | |||
| 189 | /**  | 
            ||
| 190 | *  | 
            ||
| 191 | * @param stdClass $resultRaw  | 
            ||
| 192 | *  | 
            ||
| 193 | * @return bool  | 
            ||
| 194 | */  | 
            ||
| 195 | 11 | private function hasResult(stdClass $resultRaw)  | 
            |
| 219 | |||
| 220 | /**  | 
            ||
| 221 | *  | 
            ||
| 222 | * @param stdClass $resultRaw  | 
            ||
| 223 | * @return boolean  | 
            ||
| 224 | */  | 
            ||
| 225 | 8 | private function isBot(stdClass $resultRaw)  | 
            |
| 233 | |||
| 234 | /**  | 
            ||
| 235 | *  | 
            ||
| 236 | * @param Model\Bot $bot  | 
            ||
| 237 | * @param stdClass $resultRaw  | 
            ||
| 238 | */  | 
            ||
| 239 | 1 | private function hydrateBot(Model\Bot $bot, stdClass $resultRaw)  | 
            |
| 251 | |||
| 252 | /**  | 
            ||
| 253 | *  | 
            ||
| 254 | * @param Model\Browser $browser  | 
            ||
| 255 | * @param stdClass $resultRaw  | 
            ||
| 256 | */  | 
            ||
| 257 | 7 | private function hydrateBrowser(Model\Browser $browser, stdClass $resultRaw)  | 
            |
| 267 | |||
| 268 | /**  | 
            ||
| 269 | *  | 
            ||
| 270 | * @param Model\RenderingEngine $engine  | 
            ||
| 271 | * @param stdClass $resultRaw  | 
            ||
| 272 | */  | 
            ||
| 273 | 7 | private function hydrateRenderingEngine(Model\RenderingEngine $engine, stdClass $resultRaw)  | 
            |
| 283 | |||
| 284 | /**  | 
            ||
| 285 | *  | 
            ||
| 286 | * @param Model\OperatingSystem $os  | 
            ||
| 287 | * @param stdClass $resultRaw  | 
            ||
| 288 | */  | 
            ||
| 289 | 7 | private function hydrateOperatingSystem(Model\OperatingSystem $os, stdClass $resultRaw)  | 
            |
| 299 | |||
| 300 | /**  | 
            ||
| 301 | *  | 
            ||
| 302 | * @param Model\UserAgent $device  | 
            ||
| 303 | * @param stdClass $resultRaw  | 
            ||
| 304 | */  | 
            ||
| 305 | 7 | private function hydrateDevice(Model\Device $device, stdClass $resultRaw)  | 
            |
| 319 | |||
| 320 | 19 | public function parse($userAgent, array $headers = [])  | 
            |
| 356 | }  | 
            ||
| 357 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.