library/QATools/QATools/HtmlElements/Element/LabeledElement.php
public function getLabel()
	{
		$label = null;
		$id = $this->getAttribute('id');

		if ( !is_null($id) ) {
			// Label with matching "for" attribute.
			$escaped_id = $this->getXpathEscaper()->escapeLiteral($id);
			$xpath_expressions = array(
				'preceding::label[@for = ' . $escaped_id . ']',
				'following::label[@for = ' . $escaped_id . ']',
			);
			$label = $this->getWrappedElement()->find('xpath', '(' . implode(' | ', $xpath_expressions) . ')[1]');
		}

		if ( is_null($label) ) {
			// Label wrapped around checkbox.
			$label = $this->getWrappedElement()->find('xpath', 'parent::label');
		}

		if ( is_null($label) ) {
			// Label right next to checkbox.
			$label = $this->getWrappedElement()->find('xpath', 'following-sibling::*[1][self::label]');
		}

		return $label;
	}
public function getLabel()
	{
		$label = null;
		$id = $this->getAttribute('id');

		if ( !is_null($id) ) {
			// Label with matching "for" attribute.
			$escaped_id = $this->getXpathEscaper()->escapeLiteral($id);
			$xpath_expressions = array(
				'preceding::label[@for = ' . $escaped_id . ']',
				'following::label[@for = ' . $escaped_id . ']',
			);
			$label = $this->getWrappedElement()->find('xpath', '(' . implode(' | ', $xpath_expressions) . ')[1]');
		}

		if ( is_null($label) ) {
			// Label wrapped around checkbox.
			$label = $this->getWrappedElement()->find('xpath', 'parent::label');
		}

		if ( is_null($label) ) {
			// Label right next to checkbox.
			$label = $this->getWrappedElement()->find('xpath', 'following-sibling::*[1][self::label]');
		}

		return $label;
	}
public function getLabel ( ) { $ label = null ; $ id = $ this -> getAttribute ( 'id' ) ; if ( ! is_null ( $ id ) ) { // Label with matching "for" attribute. $ escaped_id = $ this -> getXpathEscaper ( ) -> escapeLiteral ( $ id ) ; $ xpath_expressions = array ( 'preceding::label[@for = ' . $ escaped_id . ']' , 'following::label[@for = ' . $ escaped_id . ']' , ) ; $ label = $ this -> getWrappedElement ( ) -> find ( 'xpath' , '(' . implode ( ' | ' , $ xpath_expressions ) . ')[1]' ) ; } if ( is_null ( $ label ) ) { // Label wrapped around checkbox. $ label = $ this -> getWrappedElement ( ) -> find ( 'xpath' , 'parent::label' ) ; } if ( is_null ( $ label ) ) { // Label right next to checkbox. $ label = $ this -> getWrappedElement ( ) -> find ( 'xpath' , 'following-sibling::*[1][self::label]' ) ; } return $ label ; }
Finds label corresponding to current element.

@return NodeElement|null Element representing label or null if no label has been found.
Finds label corresponding to current element .