<?php

class Tag_Anchor extends Tag
{
	public function __construct($href, $contents=NULL, $attributes=array())
	{
		parent::__construct('a', $attributes, TAG_CLOSE);
		$this->attr('href', $href);
		if( !is_array($contents) && !is_object($contents))
			$this->text($contents);
		if( is_array($contents) )
			foreach($contents as $node)
				$this->addChild($node);
		if( $contents instanceof Tag )
			$this->addChild($contents);
	}

	public function text($value=NULL)
	{
		if( !is_null($value) )
		{
			$this->children = NULL;
			$this->text = $value;
		}
		else
		{
			return $this->text;
		}
	}
}
