php/mixins/LabelElement.php
public function setLabel( $label ) {
		$this->labelValue = (string)$label !== '' ? $label : null;

		$this->label->clearContent();
		if ( $this->labelValue !== null ) {
			if ( is_string( $this->labelValue ) && trim( $this->labelValue ) === '' ) {
				$this->label->appendContent( new HtmlSnippet( '&nbsp;' ) );
			} else {
				$this->label->appendContent( $label );
			}
		}

		$visibleLabel = $this->labelValue !== null && !$this->invisibleLabel;
		$this->toggleClasses( [ 'oo-ui-labelElement' ], $visibleLabel );

		return $this;
	}
public function setLabel( $label ) {
		$this->labelValue = (string)$label !== '' ? $label : null;

		$this->label->clearContent();
		if ( $this->labelValue !== null ) {
			if ( is_string( $this->labelValue ) && trim( $this->labelValue ) === '' ) {
				$this->label->appendContent( new HtmlSnippet( '&nbsp;' ) );
			} else {
				$this->label->appendContent( $label );
			}
		}

		$visibleLabel = $this->labelValue !== null && !$this->invisibleLabel;
		$this->toggleClasses( [ 'oo-ui-labelElement' ], $visibleLabel );

		return $this;
	}
public function setLabel ( $ label ) { $ this -> labelValue = ( string ) $ label !== '' ? $ label : null ; $ this -> label -> clearContent ( ) ; if ( $ this -> labelValue !== null ) { if ( is_string ( $ this -> labelValue ) && trim ( $ this -> labelValue ) === '' ) { $ this -> label -> appendContent ( new HtmlSnippet ( '&nbsp;' ) ) ; } else { $ this -> label -> appendContent ( $ label ) ; } } $ visibleLabel = $ this -> labelValue !== null && ! $ this -> invisibleLabel ; $ this -> toggleClasses ( [ 'oo-ui-labelElement' ] , $ visibleLabel ) ; return $ this ; }
Set the label.

An empty string will result in the label being hidden. A string containing only whitespace will
be converted to a single `&nbsp;`.

@param string|HtmlSnippet|null $label Label text
@return $this
Set the label .