/** * Sorts the validated data from $this->devices into their respective UserAgentMatcher tables ($this->tables) * based on the UserAgentMatcher that matches the device's user agent * @return bool Success */ public function sort() { $this->timesort = microtime(true); foreach ($this->devices as $id => &$device) { $this->wurfl->httpRequest = new TeraWurflHttpRequest(array('HTTP_USER_AGENT' => $device['user_agent'])); // This will return something like "Nokia", "Motorola", or "CatchAll" $matcher = UserAgentMatcherFactory::userAgentType($this->wurfl, $this->wurfl->httpRequest); // TeraWurfl_Nokia $device['user_agent'] = $this->wurfl->httpRequest->user_agent->normalized; $uatable = TeraWurflConfig::$TABLE_PREFIX . '_' . $matcher; if (!isset($this->tables[$uatable])) { $this->tables[$uatable] = array(); } $this->tables[$uatable][$device['id']] = $device; } // Destroy the devices array $this->devices = array(); return true; }