protected function doParse($string)
    {
        $userAgent = array(
            'string' => $this->cleanString($string),
            'browser_name' => null,
            'browser_version' => null,
            'browser_engine' => null,
            'operating_system' => null,
            'device' => 'Other'
        );

        if (empty($userAgent['string'])) {
            return $userAgent;
        }

        $browsers = $this->definition->getKnownBrowsers();
        $bots = $this->definition->getKnownBots();
        $userAgents = $browsers + $bots;

        // Find the right name/version phrase (or return empty array if none found)
        foreach ($userAgents as $name => $regexes) {
            if ($matches = $this->matchBrowser($regexes, $userAgent['string'])) {
                if (isset($matches[3])) {
                    $name = str_replace('*', strtolower($matches[2]), $name);
                }

                $userAgent['browser_name'] = $name;
                $userAgent['browser_version'] = end($matches);

                break;
            }
        }

        // Find browser engine
        $engines = $this->definition->getKnownEngines();
        if ($result = $this->find($engines, $userAgent['string'])) {
            $userAgent['browser_engine'] = $result;
        }

        // Find operating system
        $operatingSystems = $this->definition->getKnownOperatingSystems();
        if ($result = $this->find($operatingSystems, $userAgent['string'])) {
            $userAgent['operating_system'] = $result;
        }

        // Find device name
        $devices = $this->definition->getKnownDevices();
        if ($result = $this->find($devices, $userAgent['string'], true)) {
            $userAgent['device'] = $result;
        }

        return $userAgent;
    }