original_string: public function for_slot($slot, $variant = null) {
          if ($variant === null) {
              if (!isset($this->questionstats[$slot])) {
                  throw new \coding_exception('Reference to unknown slot ' . $slot);
              } else {
                  return $this->questionstats[$slot];
              }
          } else {
              if (!isset($this->questionstats[$slot]->variantstats[$variant])) {
                  throw new \coding_exception('Reference to unknown slot ' . $slot . ' variant ' . $variant);
              } else {
                  return $this->questionstats[$slot]->variantstats[$variant];
              }
          }
      }
code: public function for_slot($slot, $variant = null) {
          if ($variant === null) {
              if (!isset($this->questionstats[$slot])) {
                  throw new \coding_exception('Reference to unknown slot ' . $slot);
              } else {
                  return $this->questionstats[$slot];
              }
          } else {
              if (!isset($this->questionstats[$slot]->variantstats[$variant])) {
                  throw new \coding_exception('Reference to unknown slot ' . $slot . ' variant ' . $variant);
              } else {
                  return $this->questionstats[$slot]->variantstats[$variant];
              }
          }
      }
code_tokens: public function for_slot ( $ slot , $ variant = null ) { if ( $ variant === null ) { if ( ! isset ( $ this -> questionstats [ $ slot ] ) ) { throw new \ coding_exception ( 'Reference to unknown slot ' . $ slot ) ; } else { return $ this -> questionstats [ $ slot ] ; } } else { if ( ! isset ( $ this -> questionstats [ $ slot ] -> variantstats [ $ variant ] ) ) { throw new \ coding_exception ( 'Reference to unknown slot ' . $ slot . ' variant ' . $ variant ) ; } else { return $ this -> questionstats [ $ slot ] -> variantstats [ $ variant ] ; } } }
docstring: Get position stats instance for a slot and optional variant no.
  
  @param int  $slot The slot no.
  @param int|null $variant if provided then we want the object which stores a variant of a position's stats.
  @return calculated|calculated_for_subquestion An instance of the class storing the calculated position stats.
  @throws \coding_exception if there is an attempt to respond to a non-existant set of stats.
docstring_tokens: Get position stats instance for a slot and optional variant no .