<?php

class Attribute{
	/**
	 * @access private
	 * @var    string	 
	 */	 	
	var $name;
	
	/**
	 * @access private
	 * @var    string	 
	 */	 	
	var $value;
	
	/**
	 * Constructor
	 * 
	 * @param string $name
	 * @param string $value	 	 	 
	 */	 	
	function Attribute($name, $value){
		$this->setAttributeName($name);
		$this->setAttributeValue($value);
	}
	
	/**
	 * Returns Attribute Name
	 * 
	 * @return string	 	 
	 */	 	
	function getAttributeName(){
		return $this->name;
	}
	
	/**
	 * Sets Attribute Name
	 * 
	 * @param string $name	 	 
	 */	 	
	function setAttributeName($name){
		$this->name = $name;
	}
	
	/**
	 * Returns Attribute Value
	 * 
	 * @return string	 	 
	 */	 	
	function getAttributeValue(){
		return $this->value;
	}
	
	/**
	 * Sets Attribute Value
	 * 
	 * @param string $value	 	 
	 */	 	
	function setAttributeValue($value){
		$this->value = $value;
	}
	
	/**
	 * Exports Into String
	 * 
	 * @return string	 	 
	 */	 	
	function toString(){
		return sprintf('%s="%s"', $this->getAttributeName(), $this->getAttributeValue());
	}
	
	/**
	 * @static
	 */	 	
	function getAttributePattern(){
		return '`([a-zA-Z-_]+)="([^"]+)"`';		
	}
	
	/**
	 * @static
	 */	 	
	function &loadAttribute($strTag){
		$objAttr = null;
		$matches = array();
		if(preg_match(Attribute::getAttributePattern(), $strTag, $matches)){
			/*
			 * Array
			 *(
    	 *  [0] => id="IntroMenuText"
       *  [1] => id
       *  [2] => IntroMenuText
       *)
			 */			 
			$name = $matches[1];
			$value = $matches[2];
			$objAttr = &new Attribute($name, $value);
		}
		return $objAttr;
	}
}

?>