/** * 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; }
/** * @covers Brickoo\Component\Annotation\Annotation::__construct * @covers Brickoo\Component\Annotation\Annotation::getTargetLocation */ public function testGetTargetLocation() { $targetLocation = "\\SomeClass"; $annotation = new Annotation(Annotation::TARGET_CLASS, $targetLocation, "Cache"); $this->assertEquals($targetLocation, $annotation->getTargetLocation()); }