/**
  * Loads from annotations from a class.
  *
  * @param string $class A class name
  * @param string $type  The resource type
  *
  * @return SecurityPolicyRules A Rules instance
  *
  * @throws \InvalidArgumentException When annotations can't be parsed
  */
 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));
     }
     $rules = new SecurityPolicyRules();
     $rules->addResource(new FileResource($class->getFileName()));
     foreach ($class->getMethods() as $method) {
         foreach ($this->reader->getMethodAnnotations($method) as $annot) {
             if ($annot instanceof $this->annotationClass) {
                 $methodName = $method->getName();
                 $rules->addMethod($class->getName(), $methodName);
             }
         }
     }
     foreach ($class->getProperties() as $property) {
         foreach ($this->reader->getPropertyAnnotations($property) as $annot) {
             if ($annot instanceof $this->annotationClass) {
                 $rules->addProperty($class->getName(), $property->getName());
             }
         }
     }
     return $rules;
 }