/**
  * Returns final selector to be used for element locating.
  *
  * @return array
  * @throws AnnotationException When required @find-by annotation is missing.
  */
 protected function getSelector()
 {
     /* @var $annotations FindByAnnotation[] */
     $annotations = $this->property->getAnnotationsFromPropertyOrClass('@find-by');
     $selector = $annotations ? $annotations[0]->getSelector() : array();
     if (!$selector) {
         $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);
     }
     return $selector;
 }
 /**
  * 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();
     foreach ($this->elementToProxyMapping as $element_class => $proxy_class) {
         if ($this->classMatches($data_type, $element_class)) {
             return $proxy_class;
         }
     }
     return false;
 }
Example #4
0
 /**
  * @dataProvider getDataTypeDataProvider
  */
 public function testGetDataType($data_type, $result)
 {
     $this->expectVarAnnotation($data_type);
     $this->assertSame($result, $this->property->getDataType());
 }