public static function getNextPermutation($number) {
    $length = strlen($number);
    $pieces = str_split($number);
    // Find non-increasing suffix
    $i = $length - 1;
    while ($i > 0 && $pieces[$i - 1] >= $pieces[$i]) {
      $i--;
    }
    if ($i <= 0) {
      return FALSE;
    }

    // Find successor to pivot.
    $j = $length - 1;
    while ($pieces[$j] <= $pieces[$i - 1]) {
      $j--;
    }
    $temp = $pieces[$i - 1];
    $pieces[$i - 1] = $pieces[$j];
    $pieces[$j] = $temp;

    // Reverse suffix
    $j = $length - 1;
    while ($i < $j) {
      $temp = $pieces[$i];
      $pieces[$i] = $pieces[$j];
      $pieces[$j] = $temp;
      $i++;
      $j--;
    }
    return implode('', $pieces);
  }