original_string: public function load($class, $type = null)
      {
          if (!class_exists($class)) {
              throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
          }
  
          $class = new \ReflectionClass($class);
          if ($class->isAbstract()) {
              throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName()));
          }
  
          $globals = $this->getGlobals($class);
  
          $collection = new RouteCollection();
          $collection->addResource(new FileResource($class->getFileName()));
  
          foreach ($class->getMethods() as $method) {
              $this->defaultRouteIndex = 0;
              foreach ($this->reader->getMethodAnnotations($method) as $annot) {
                  if ($annot instanceof $this->routeAnnotationClass) {
                      $this->addRoute($collection, $annot, $globals, $class, $method);
                  }
              }
          }
  
          if (0 === $collection->count() && $class->hasMethod('__invoke')) {
              $globals = $this->resetGlobals();
              foreach ($this->reader->getClassAnnotations($class) as $annot) {
                  if ($annot instanceof $this->routeAnnotationClass) {
                      $this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
                  }
              }
          }
  
          return $collection;
      }
code: public function load($class, $type = null)
      {
          if (!class_exists($class)) {
              throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
          }
  
          $class = new \ReflectionClass($class);
          if ($class->isAbstract()) {
              throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName()));
          }
  
          $globals = $this->getGlobals($class);
  
          $collection = new RouteCollection();
          $collection->addResource(new FileResource($class->getFileName()));
  
          foreach ($class->getMethods() as $method) {
              $this->defaultRouteIndex = 0;
              foreach ($this->reader->getMethodAnnotations($method) as $annot) {
                  if ($annot instanceof $this->routeAnnotationClass) {
                      $this->addRoute($collection, $annot, $globals, $class, $method);
                  }
              }
          }
  
          if (0 === $collection->count() && $class->hasMethod('__invoke')) {
              $globals = $this->resetGlobals();
              foreach ($this->reader->getClassAnnotations($class) as $annot) {
                  if ($annot instanceof $this->routeAnnotationClass) {
                      $this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
                  }
              }
          }
  
          return $collection;
      }
code_tokens: public function load ( $ class , $ type = null ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class "%s" does not exist.' , $ class ) ) ; } $ class = new \ ReflectionClass ( $ class ) ; if ( $ class -> isAbstract ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Annotations from class "%s" cannot be read as it is abstract.' , $ class -> getName ( ) ) ) ; } $ globals = $ this -> getGlobals ( $ class ) ; $ collection = new RouteCollection ( ) ; $ collection -> addResource ( new FileResource ( $ class -> getFileName ( ) ) ) ; foreach ( $ class -> getMethods ( ) as $ method ) { $ this -> defaultRouteIndex = 0 ; foreach ( $ this -> reader -> getMethodAnnotations ( $ method ) as $ annot ) { if ( $ annot instanceof $ this -> routeAnnotationClass ) { $ this -> addRoute ( $ collection , $ annot , $ globals , $ class , $ method ) ; } } } if ( 0 === $ collection -> count ( ) && $ class -> hasMethod ( '__invoke' ) ) { $ globals = $ this -> resetGlobals ( ) ; foreach ( $ this -> reader -> getClassAnnotations ( $ class ) as $ annot ) { if ( $ annot instanceof $ this -> routeAnnotationClass ) { $ this -> addRoute ( $ collection , $ annot , $ globals , $ class , $ class -> getMethod ( '__invoke' ) ) ; } } } return $ collection ; }
docstring: Loads from annotations from a class.
  
  @param string      $class A class name
  @param string|null $type  The resource type
  
  @return RouteCollection A RouteCollection instance
  
  @throws \InvalidArgumentException When route can't be parsed
docstring_tokens: Loads from annotations from a class .