Example #1
0
 /** @covers Brickoo\Component\Annotation\Annotation::hasValues */
 public function testHasValues()
 {
     $annotationValues = ["path" => "/"];
     $annotation1 = new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Cache");
     $this->assertFalse($annotation1->hasValues());
     $annotation2 = new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Cache", $annotationValues);
     $this->assertTrue($annotation2->hasValues());
 }
 /**
  * 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;
 }
 /**
  * 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;
 }