original_string: public static function user_top() {
          $children = self::top()->get_children();
          if (count($children) == 1) {
              // User has access to only one category on the top level. Return this category as "user top category".
              return reset($children);
          }
          if (count($children) > 1) {
              // User has access to more than one category on the top level. Return the top as "user top category".
              // In this case user actually may not have capability 'moodle/category:viewcourselist' on the top level.
              return self::top();
          }
          // User can not access any categories on the top level.
          // TODO MDL-10965 find ANY/ALL categories in the tree where user has access to.
          return self::get(0, IGNORE_MISSING);
      }
code: public static function user_top() {
          $children = self::top()->get_children();
          if (count($children) == 1) {
              // User has access to only one category on the top level. Return this category as "user top category".
              return reset($children);
          }
          if (count($children) > 1) {
              // User has access to more than one category on the top level. Return the top as "user top category".
              // In this case user actually may not have capability 'moodle/category:viewcourselist' on the top level.
              return self::top();
          }
          // User can not access any categories on the top level.
          // TODO MDL-10965 find ANY/ALL categories in the tree where user has access to.
          return self::get(0, IGNORE_MISSING);
      }
code_tokens: public static function user_top ( ) { $ children = self :: top ( ) -> get_children ( ) ; if ( count ( $ children ) == 1 ) { // User has access to only one category on the top level. Return this category as "user top category". return reset ( $ children ) ; } if ( count ( $ children ) > 1 ) { // User has access to more than one category on the top level. Return the top as "user top category". // In this case user actually may not have capability 'moodle/category:viewcourselist' on the top level. return self :: top ( ) ; } // User can not access any categories on the top level. // TODO MDL-10965 find ANY/ALL categories in the tree where user has access to. return self :: get ( 0 , IGNORE_MISSING ) ; }
docstring: Returns the top-most category for the current user
  
  Examples:
  1. User can browse courses everywhere - return self::top() - pseudo-category with id=0
  2. User does not have capability to browse courses on the system level but
  has it in ONE course category - return this course category
  3. User has capability to browse courses in two course categories - return self::top()
  
  @return core_course_category|null
docstring_tokens: Returns the top - most category for the current user