/**
  * Asserts that required annotations are present.
  *
  * @param array $annotations Annotations to test.
  *
  * @return void
  *
  * @throws AnnotationException Thrown if none or wrong annotations given.
  */
 protected function assertAnnotationClass(array $annotations)
 {
     if (!$annotations) {
         $parameters = array((string) $this->property, $this->property->getDataType());
         $message = '@find-by must be specified in the property "%s" DocBlock or in class "%s" DocBlock';
         throw new AnnotationException(vsprintf($message, $parameters), AnnotationException::TYPE_REQUIRED);
     }
     foreach ($annotations as $annotation) {
         if (!$annotation instanceof FindByAnnotation) {
             $parameters = array((string) $this->property, $this->property->getDataType());
             $message = '@find-by must be specified in the property "%s" DocBlock or in class "%s" DocBlock';
             throw new AnnotationException(vsprintf($message, $parameters), AnnotationException::TYPE_REQUIRED);
         }
     }
 }
 /**
  * Checks, that given class is BEM Element or it's descendant.
  *
  * @param Property $property Property.
  *
  * @return boolean
  */
 private function _isBEMElement(Property $property)
 {
     return $this->classMatches($property->getDataType(), $this->_elementInterface);
 }
 /**
  * Returns proxy class, that can be used alongside with element class of a property.
  *
  * @param Property $property Property.
  *
  * @return string
  */
 protected function getProxyClass(Property $property)
 {
     $data_type = $property->getDataType();
     if ($data_type) {
         foreach ($this->elementToProxyMapping as $element_class => $proxy_class) {
             if ($this->classMatches($data_type, $element_class)) {
                 return $proxy_class;
             }
         }
     }
     return '';
 }
示例#4
0
 /**
  * @dataProvider getDataTypeDataProvider
  */
 public function testGetDataType($data_type, $result)
 {
     $this->expectVarAnnotation($data_type);
     $this->assertSame($result, $this->property->getDataType());
 }