<?php
/**
 * @file
 * Auto Generated Code - DO NOT EDIT
 *
 * See http://51degrees.mobi/Support/Documentation/PHP#AutoGeneratedSourceCode for more details.*
 */

/**
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0.
 *
 * If a copy of the MPL was not distributed with this file, You can obtain one
 * at http://mozilla.org/MPL/2.0/.
 *
 * This Source Code Form is "Incompatible With Secondary Licenses", as defined
 * by the Mozilla Public License, v. 2.0.
 */

/**
 * Calculates the matching score between the two strings for this handler.
 *
 * &$target string
 *   The string we're trying to find the closest value to.
 * $test string
 *   The string that we're testing against.
 * $ls integer
 *   The lowest score we've found so far.
 * return integer
 *   The score between the two strings.
 */
function E81($target, $test, $ls) {
  $score = 0;
  fiftyone_degrees_calculate_segment_score($target[0], $test[0], $ls, 1, $score);
  if ($score == PHP_INT_MAX) {
    return PHP_INT_MAX;
  }
  fiftyone_degrees_calculate_segment_score($target[1], $test[1], $ls, 1, $score);
  if ($score == PHP_INT_MAX) {
    return PHP_INT_MAX;
  }
  fiftyone_degrees_calculate_segment_score($target[2], $test[2], $ls, 5, $score);
  if ($score == PHP_INT_MAX) {
    return PHP_INT_MAX;
  }
  fiftyone_degrees_calculate_segment_score($target[3], $test[3], $ls, 5, $score);
  if ($score == PHP_INT_MAX) {
    return PHP_INT_MAX;
  }
  fiftyone_degrees_calculate_segment_score($target[4], $test[4], $ls, 5, $score);
  if ($score == PHP_INT_MAX) {
    return PHP_INT_MAX;
  }
  return $score;
}

/**
 * Returns the details of the devices that are closest to the
 * useragent string provided.
 *
 * $useragent string
 *   The useragent we're trying to find.
 * return array
 *   An array of device details for the closest devices.
 */
function _H81($useragent) {

  $ls = PHP_INT_MAX;
  $dl = array();

  // Calculate the segments for the useragent.
  $segments = array(
    0 => fiftyone_degrees_preg_match_all('#(?<=Mozilla/)[\\d\\.]+#', $useragent),
    1 => fiftyone_degrees_preg_match_all('#(?<=Skyfire/)[\\d\\.]+#', $useragent),
    2 => fiftyone_degrees_preg_match_all('#(?<=AppleWebKit/)[\\d\\.]+#', $useragent),
    3 => fiftyone_degrees_preg_match_all('#(?<=Safari/)[\\d\\.]+#', $useragent),
    4 => fiftyone_degrees_preg_match_all('#(?<=Version/)[\\d\\.]+#', $useragent));
  $ns = E81($segments, array(0 => array(0 => '5.0'), 1 => array(0 => '2.0'), 2 => array(0 => '530.17'), 3 => array(0 => '530.17'), 4 => array(0 => '4.0')), $ls);
  if ($ns <= $ls) {
    if ($ns < $ls) {
      unset($dl);
    }
    $dl[] = array(18088,17295,18325,18092, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7;en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0');
    $ls = $ns;
  }
  $ns = E81($segments, array(0 => array(0 => '5.0'), 1 => array(0 => '2.0'), 2 => array(0 => '530.17'), 3 => array(0 => '530.17'), 4 => array(0 => '4.0')), $ls);
  if ($ns <= $ls) {
    if ($ns < $ls) {
      unset($dl);
    }
    $dl[] = array(18088,17295,18325,18092, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0');
    $ls = $ns;
  }
  $ns = E81($segments, array(0 => array(0 => '5.0'), 1 => array(0 => '2.0'), 2 => array(0 => '530.17'), 3 => array(0 => '530.17'), 4 => array(0 => '4.0')), $ls);
  if ($ns <= $ls) {
    if ($ns < $ls) {
      unset($dl);
    }
    $dl[] = array(18088,17295,18325,18092, 'Mozilla/5.0(Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0');
    $ls = $ns;
  }
  $ns = E81($segments, array(0 => array(0 => '5.0'), 1 => array(0 => '2.0'), 2 => array(0 => '530.18'), 3 => array(0 => '528.17'), 4 => array(0 => '4.0')), $ls);
  if ($ns <= $ls) {
    if ($ns < $ls) {
      unset($dl);
    }
    $dl[] = array(18088,17295,18325,18092, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) AppleWebKit/530.18 (KHTML, like Gecko) Version/4.0 Safari/528.17 Skyfire/2.0');
    $ls = $ns;
  }
  $ns = E81($segments, array(0 => array(0 => '5.0'), 1 => array(0 => '2.0'), 2 => array(0 => '530.17'), 3 => array(0 => '530.17'), 4 => array(0 => '4.0')), $ls);
  if ($ns <= $ls) {
    if ($ns < $ls) {
      unset($dl);
    }
    $dl[] = array(18088,17017,18325,18092, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X10_5_7; en-us) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17 Skyfire/2.0');
    $ls = $ns;
  }
  return $dl;
}
