/** * @param string $userAgent * * @return null|string */ public function applyConclusiveMatch($userAgent) { $tolerance = Utils::indexOfAnyOrLength($userAgent, array('/', ' '), strpos($userAgent, 'Nokia')); if (Utils::checkIfStartsWithAnyOf($userAgent, array('Nokia/', 'Nokia '))) { $tolerance = strlen($userAgent); } return $this->getDeviceIDFromRIS($userAgent, $tolerance); }
/** * @param string $userAgent * * @return null|string */ public function applyConclusiveMatch($userAgent) { $tolerance = Utils::toleranceToRisDelimeter($userAgent); if ($tolerance !== false) { return $this->getDeviceIDFromRIS($userAgent, $tolerance); } //Return no match for UAs with no extractable Android version, model and that do not start with either Mozilla or Dalvik if (!Utils::checkIfStartsWithAnyOf($userAgent, array('Mozilla', 'Dalvik'))) { return WurflConstants::NO_MATCH; } if (self::getAndroidModel($userAgent, false) === null) { return $this->getDeviceIDFromRIS($userAgent, strlen($userAgent)); } // Standard RIS Matching $tolerance = Utils::indexOfAnyOrLength($userAgent, array(' Build/', ' AppleWebKit')); return $this->getDeviceIDFromRIS($userAgent, $tolerance); }
/** * @dataProvider indexOfAnyOrLengthDataProvider * * @param string $haystack * @param string $expected */ public function testIndexOfAnyOrLength($haystack, $expected) { $found = Utils::indexOfAnyOrLength($haystack, array(' ', '/'), 0); self::assertEquals($expected, $found); }