original_string: public static function instance($course, ?\context $context = null) {
  
          $courseid = $course;
          if (!is_scalar($courseid)) {
              $courseid = $course->id;
          }
  
          if (self::$cachedid === $courseid) {
              return self::$cachedinstance;
          }
  
          $cachedinstance = new \core_analytics\course($course, $context);
          self::$cachedinstance = $cachedinstance;
          self::$cachedid = (int)$courseid;
          return self::$cachedinstance;
      }
code: public static function instance($course, ?\context $context = null) {
  
          $courseid = $course;
          if (!is_scalar($courseid)) {
              $courseid = $course->id;
          }
  
          if (self::$cachedid === $courseid) {
              return self::$cachedinstance;
          }
  
          $cachedinstance = new \core_analytics\course($course, $context);
          self::$cachedinstance = $cachedinstance;
          self::$cachedid = (int)$courseid;
          return self::$cachedinstance;
      }
code_tokens: public static function instance ( $ course , ? \ context $ context = null ) { $ courseid = $ course ; if ( ! is_scalar ( $ courseid ) ) { $ courseid = $ course -> id ; } if ( self :: $ cachedid === $ courseid ) { return self :: $ cachedinstance ; } $ cachedinstance = new \ core_analytics \ course ( $ course , $ context ) ; self :: $ cachedinstance = $ cachedinstance ; self :: $ cachedid = ( int ) $ courseid ; return self :: $ cachedinstance ; }
docstring: Returns an analytics course instance.
  
  Lazy load of course data, students and teachers.
  
  @param int|\stdClass $course Course object or course id
  @param \context|null $context
  @return \core_analytics\course
docstring_tokens: Returns an analytics course instance .