code: private function getLevelPercent($value, $levels)
      {
          $result = 0;
          foreach ($levels as $level => $percent) {
              if ($value < $level) {
                  break;
              }
              $result = $percent;
          }
          return $result;
      }
docs: Get percent for the first level that is greater then given $value.
  
  @param int $value PV/TV/... value to get level's percent
  @param array $levels asc ordered array with levels & percents ([$level => $percent])
  
  @return number