original_string: protected function classify_value($value, $ranges) {
  
          // To automatically return calculated values from min to max values.
          $rangeweight = (static::get_max_value() - static::get_min_value()) / (count($ranges) - 1);
  
          foreach ($ranges as $key => $range) {
  
              $match = false;
  
              if (count($range) != 2) {
                  throw new \coding_exception('classify_value() $ranges array param should contain 2 items, the predicate ' .
                      'e.g. greater (gt), lower or equal (le)... and the value.');
              }
  
              list($predicate, $rangevalue) = $range;
  
              switch ($predicate) {
                  case 'eq':
                      if ($value == $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'ne':
                      if ($value != $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'lt':
                      if ($value < $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'le':
                      if ($value <= $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'gt':
                      if ($value > $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'ge':
                      if ($value >= $rangevalue) {
                          $match = true;
                      }
                      break;
                  default:
                      throw new \coding_exception('Unrecognised predicate ' . $predicate . '. Please use eq, ne, lt, le, ge or gt.');
              }
  
              // Calculate and return a linear calculated value for the provided value.
              if ($match) {
                  return round(static::get_min_value() + ($rangeweight * $key), 2);
              }
          }
  
          throw new \coding_exception('The provided value "' . $value . '" can not be fit into any of the provided ranges, you ' .
              'should provide ranges for all possible values.');
      }
code: protected function classify_value($value, $ranges) {
  
          // To automatically return calculated values from min to max values.
          $rangeweight = (static::get_max_value() - static::get_min_value()) / (count($ranges) - 1);
  
          foreach ($ranges as $key => $range) {
  
              $match = false;
  
              if (count($range) != 2) {
                  throw new \coding_exception('classify_value() $ranges array param should contain 2 items, the predicate ' .
                      'e.g. greater (gt), lower or equal (le)... and the value.');
              }
  
              list($predicate, $rangevalue) = $range;
  
              switch ($predicate) {
                  case 'eq':
                      if ($value == $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'ne':
                      if ($value != $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'lt':
                      if ($value < $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'le':
                      if ($value <= $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'gt':
                      if ($value > $rangevalue) {
                          $match = true;
                      }
                      break;
                  case 'ge':
                      if ($value >= $rangevalue) {
                          $match = true;
                      }
                      break;
                  default:
                      throw new \coding_exception('Unrecognised predicate ' . $predicate . '. Please use eq, ne, lt, le, ge or gt.');
              }
  
              // Calculate and return a linear calculated value for the provided value.
              if ($match) {
                  return round(static::get_min_value() + ($rangeweight * $key), 2);
              }
          }
  
          throw new \coding_exception('The provided value "' . $value . '" can not be fit into any of the provided ranges, you ' .
              'should provide ranges for all possible values.');
      }
code_tokens: protected function classify_value ( $ value , $ ranges ) { // To automatically return calculated values from min to max values. $ rangeweight = ( static :: get_max_value ( ) - static :: get_min_value ( ) ) / ( count ( $ ranges ) - 1 ) ; foreach ( $ ranges as $ key => $ range ) { $ match = false ; if ( count ( $ range ) != 2 ) { throw new \ coding_exception ( 'classify_value() $ranges array param should contain 2 items, the predicate ' . 'e.g. greater (gt), lower or equal (le)... and the value.' ) ; } list ( $ predicate , $ rangevalue ) = $ range ; switch ( $ predicate ) { case 'eq' : if ( $ value == $ rangevalue ) { $ match = true ; } break ; case 'ne' : if ( $ value != $ rangevalue ) { $ match = true ; } break ; case 'lt' : if ( $ value < $ rangevalue ) { $ match = true ; } break ; case 'le' : if ( $ value <= $ rangevalue ) { $ match = true ; } break ; case 'gt' : if ( $ value > $ rangevalue ) { $ match = true ; } break ; case 'ge' : if ( $ value >= $ rangevalue ) { $ match = true ; } break ; default : throw new \ coding_exception ( 'Unrecognised predicate ' . $ predicate . '. Please use eq, ne, lt, le, ge or gt.' ) ; } // Calculate and return a linear calculated value for the provided value. if ( $ match ) { return round ( static :: get_min_value ( ) + ( $ rangeweight * $ key ) , 2 ) ; } } throw new \ coding_exception ( 'The provided value "' . $ value . '" can not be fit into any of the provided ranges, you ' . 'should provide ranges for all possible values.' ) ; }
docstring: Classifies the provided value into the provided range according to the ranges predicates.
  
  Use:
  - eq as 'equal'
  - ne as 'not equal'
  - lt as 'lower than'
  - le as 'lower or equal than'
  - gt as 'greater than'
  - ge as 'greater or equal than'
  
  @throws \coding_exception
  @param int|float $value
  @param array $ranges e.g. [ ['lt', 20], ['ge', 20] ]
  @return float
docstring_tokens: Classifies the provided value into the provided range according to the ranges predicates .