예제 #1
0
 /**
  * Adds an annotation to the properly container matching the collection type.
  * @param \Brickoo\Component\Annotation\Annotation $annotation
  * @throws \Brickoo\Component\Annotation\Exception\InvalidTargetException
  * @return \Brickoo\Component\Annotation\AnnotationReaderResult
  */
 public function addAnnotation(Annotation $annotation)
 {
     $target = $annotation->getTarget();
     if (!$this->isTargetValid($target)) {
         throw new InvalidTargetException($target);
     }
     $this->annotations[$target][] = $annotation;
     return $this;
 }
예제 #2
0
 /**
  * Returns the injection target (method,property) name.
  * @param \Brickoo\Component\Annotation\Annotation $annotation
  * @return string|null the target name otherwise null on failure
  */
 private function getInjectionTargetName(Annotation $annotation)
 {
     if ($annotation->getTarget() == Annotation::TARGET_CLASS) {
         return $annotation->getTargetLocation();
     }
     $targetLocation = null;
     if (preg_match(self::TARGET_NAME_REGEX, $annotation->getTargetLocation(), $matches)) {
         $targetLocation = $matches["target"];
     }
     return $targetLocation;
 }
예제 #3
0
 /**
  * @covers Brickoo\Component\Annotation\Annotation::__construct
  * @covers Brickoo\Component\Annotation\Annotation::getTarget
  */
 public function testGetTarget()
 {
     $target = Annotation::TARGET_CLASS;
     $annotation = new Annotation($target, "\\SomeClass", "Cache");
     $this->assertEquals($target, $annotation->getTarget());
 }