library/QATools/QATools/BEM/PropertyDecorator/BEMPropertyDecorator.php
private function _assertAnnotationUsage(array $annotations, IElementLocator $locator)
	{
		if ( !$annotations || !($annotations[0] instanceof BEMAnnotation) ) {
			throw new AnnotationException(
				'BEM block/element must be specified as annotation',
				AnnotationException::TYPE_REQUIRED
			);
		}

		/** @var BEMAnnotation $annotation */
		$annotation = $annotations[0];

		if ( ($annotation->element && $annotation->block) || (!$annotation->element && !$annotation->block) ) {
			throw new AnnotationException(
				"Either 'block' or 'element' key with non-empty value must be specified in the annotation",
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
		elseif ( $annotation->element && !($locator->getSearchContext() instanceof IBlock) ) {
			throw new AnnotationException(
				'BEM element can only be used in Block sub-class (or any class, implementing IBlock interface) property',
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
		elseif ( $annotation->block && !($locator->getSearchContext() instanceof BEMPage) ) {
			throw new AnnotationException(
				'BEM block can only be used in BEMPage sub-class property',
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
	}
private function _assertAnnotationUsage(array $annotations, IElementLocator $locator)
	{
		if ( !$annotations || !($annotations[0] instanceof BEMAnnotation) ) {
			throw new AnnotationException(
				'BEM block/element must be specified as annotation',
				AnnotationException::TYPE_REQUIRED
			);
		}

		/** @var BEMAnnotation $annotation */
		$annotation = $annotations[0];

		if ( ($annotation->element && $annotation->block) || (!$annotation->element && !$annotation->block) ) {
			throw new AnnotationException(
				"Either 'block' or 'element' key with non-empty value must be specified in the annotation",
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
		elseif ( $annotation->element && !($locator->getSearchContext() instanceof IBlock) ) {
			throw new AnnotationException(
				'BEM element can only be used in Block sub-class (or any class, implementing IBlock interface) property',
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
		elseif ( $annotation->block && !($locator->getSearchContext() instanceof BEMPage) ) {
			throw new AnnotationException(
				'BEM block can only be used in BEMPage sub-class property',
				AnnotationException::TYPE_INCORRECT_USAGE
			);
		}
	}
private function _assertAnnotationUsage ( array $ annotations , IElementLocator $ locator ) { if ( ! $ annotations || ! ( $ annotations [ 0 ] instanceof BEMAnnotation ) ) { throw new AnnotationException ( 'BEM block/element must be specified as annotation' , AnnotationException :: TYPE_REQUIRED ) ; } /** @var BEMAnnotation $annotation */ $ annotation = $ annotations [ 0 ] ; if ( ( $ annotation -> element && $ annotation -> block ) || ( ! $ annotation -> element && ! $ annotation -> block ) ) { throw new AnnotationException ( "Either 'block' or 'element' key with non-empty value must be specified in the annotation" , AnnotationException :: TYPE_INCORRECT_USAGE ) ; } elseif ( $ annotation -> element && ! ( $ locator -> getSearchContext ( ) instanceof IBlock ) ) { throw new AnnotationException ( 'BEM element can only be used in Block sub-class (or any class, implementing IBlock interface) property' , AnnotationException :: TYPE_INCORRECT_USAGE ) ; } elseif ( $ annotation -> block && ! ( $ locator -> getSearchContext ( ) instanceof BEMPage ) ) { throw new AnnotationException ( 'BEM block can only be used in BEMPage sub-class property' , AnnotationException :: TYPE_INCORRECT_USAGE ) ; } }
Verifies, that annotations are being correctly used.

@param array           $annotations Annotations.
@param IElementLocator $locator     Locator.

@return void
@throws AnnotationException When annotation is being used incorrectly.
Verifies that annotations are being correctly used .