src/UI/HTML/Tag.php
public function setData( $key, $value = NULL, $strict = TRUE ){
		if( empty( $key ) )																			//  no valid data key defined
			throw new InvalidArgumentException( 'Data key is required' );							//  throw exception
		if( array_key_exists( $key, $this->data ) && $strict )										//  data key already has a value
			throw new RuntimeException( 'Data attribute "'.$key.'" is already set' );				//  throw exception
		if( !preg_match( '/^[a-z0-9:_-]+$/i', $key ) )												//  key is invalid
			throw new InvalidArgumentException( 'Invalid data key "'.$key.'"' );					//  throw exception

		if( $value === NULL || $value === FALSE ){													//  no value available
			if( array_key_exists( $key, $this->data ) )												//  data exists
				unset( $this->data[$key] );															//  remove attribute
		}
		else
		{
			if( is_string( $value ) || is_numeric( $value ) )										//  value is string or numeric
				if( preg_match( '/[^\\\]"/', $value ) )												//  detect injection
					throw new InvalidArgumentException( 'Invalid data attribute value' );			//  throw exception
			$this->attributes[$key]	= $value;														//  set attribute
		}
	}
public function setData( $key, $value = NULL, $strict = TRUE ){
		if( empty( $key ) )																			//  no valid data key defined
			throw new InvalidArgumentException( 'Data key is required' );							//  throw exception
		if( array_key_exists( $key, $this->data ) && $strict )										//  data key already has a value
			throw new RuntimeException( 'Data attribute "'.$key.'" is already set' );				//  throw exception
		if( !preg_match( '/^[a-z0-9:_-]+$/i', $key ) )												//  key is invalid
			throw new InvalidArgumentException( 'Invalid data key "'.$key.'"' );					//  throw exception

		if( $value === NULL || $value === FALSE ){													//  no value available
			if( array_key_exists( $key, $this->data ) )												//  data exists
				unset( $this->data[$key] );															//  remove attribute
		}
		else
		{
			if( is_string( $value ) || is_numeric( $value ) )										//  value is string or numeric
				if( preg_match( '/[^\\\]"/', $value ) )												//  detect injection
					throw new InvalidArgumentException( 'Invalid data attribute value' );			//  throw exception
			$this->attributes[$key]	= $value;														//  set attribute
		}
	}
public function setData ( $ key , $ value = NULL , $ strict = TRUE ) { if ( empty ( $ key ) ) //  no valid data key defined throw new InvalidArgumentException ( 'Data key is required' ) ; //  throw exception if ( array_key_exists ( $ key , $ this -> data ) && $ strict ) //  data key already has a value throw new RuntimeException ( 'Data attribute "' . $ key . '" is already set' ) ; //  throw exception if ( ! preg_match ( '/^[a-z0-9:_-]+$/i' , $ key ) ) //  key is invalid throw new InvalidArgumentException ( 'Invalid data key "' . $ key . '"' ) ; //  throw exception if ( $ value === NULL || $ value === FALSE ) { //  no value available if ( array_key_exists ( $ key , $ this -> data ) ) //  data exists unset ( $ this -> data [ $ key ] ) ; //  remove attribute } else { if ( is_string ( $ value ) || is_numeric ( $ value ) ) //  value is string or numeric if ( preg_match ( '/[^\\\]"/' , $ value ) ) //  detect injection throw new InvalidArgumentException ( 'Invalid data attribute value' ) ; //  throw exception $ this -> attributes [ $ key ] = $ value ; //  set attribute } }
Sets data attribute of tag.
@access		public
@param		string		$key			Key of data attribute
@param		string		$value			Value of data attribute
@param		boolean		$strict			Flag: deny to override data
@return		void
Sets data attribute of tag .