SgmlOpenTag.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2007-2008 by Ivan Y. Khvostishkov                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00015     final class SgmlOpenTag extends SgmlTag
00016     {
00017         private $attributes = array();
00018         private $empty      = false;
00019         
00023         public static function create()
00024         {
00025             return new self;
00026         }
00027         
00031         public function setEmpty($isEmpty)
00032         {
00033             Assert::isBoolean($isEmpty);
00034             
00035             $this->empty = $isEmpty;
00036             
00037             return $this;
00038         }
00039         
00040         public function isEmpty()
00041         {
00042             return $this->empty;
00043         }
00044         
00048         public function setAttribute($name, $value)
00049         {
00050             $this->attributes[$name] = $value;
00051             
00052             return $this;
00053         }
00054         
00055         public function hasAttribute($name)
00056         {
00057             $name = strtolower($name);
00058             
00059             return isset($this->attributes[$name]);
00060         }
00061         
00062         public function getAttribute($name)
00063         {
00064             $name = strtolower($name);
00065             
00066             if (!isset($this->attributes[$name]))
00067                 throw new WrongArgumentException(
00068                     "attribute '{$name}' does not exist"
00069                 );
00070             
00071             return $this->attributes[$name];
00072         }
00073         
00077         public function dropAttribute($name)
00078         {
00079             $name = strtolower($name);
00080             
00081             if (!isset($this->attributes[$name]))
00082                 throw new WrongArgumentException(
00083                     "attribute '{$name}' does not exist"
00084                 );
00085             
00086             unset($this->attributes[$name]);
00087             
00088             return $this;
00089         }
00090         
00091         public function getAttributesList()
00092         {
00093             return $this->attributes;
00094         }
00095         
00099         public function dropAttributesList()
00100         {
00101             $this->attributes = array();
00102             
00103             return $this;
00104         }
00105     }
00106 ?>