00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 final class SgmlOpenTag extends SgmlTag
00017 {
00018 private $attributes = array();
00019 private $empty = false;
00020
00024 public static function create()
00025 {
00026 return new self;
00027 }
00028
00032 public function setEmpty($isEmpty)
00033 {
00034 Assert::isBoolean($isEmpty);
00035
00036 $this->empty = $isEmpty;
00037
00038 return $this;
00039 }
00040
00041 public function isEmpty()
00042 {
00043 return $this->empty;
00044 }
00045
00049 public function setAttribute($name, $value)
00050 {
00051 $this->attributes[$name] = $value;
00052
00053 return $this;
00054 }
00055
00056 public function hasAttribute($name)
00057 {
00058 $name = strtolower($name);
00059
00060 return isset($this->attributes[$name]);
00061 }
00062
00063 public function getAttribute($name)
00064 {
00065 $name = strtolower($name);
00066
00067 if (!isset($this->attributes[$name]))
00068 throw new WrongArgumentException(
00069 "attribute '{$name}' does not exist"
00070 );
00071
00072 return $this->attributes[$name];
00073 }
00074
00078 public function dropAttribute($name)
00079 {
00080 $name = strtolower($name);
00081
00082 if (!isset($this->attributes[$name]))
00083 throw new WrongArgumentException(
00084 "attribute '{$name}' does not exist"
00085 );
00086
00087 unset($this->attributes[$name]);
00088
00089 return $this;
00090 }
00091
00092 public function getAttributesList()
00093 {
00094 return $this->attributes;
00095 }
00096
00100 public function dropAttributesList()
00101 {
00102 $this->attributes = array();
00103
00104 return $this;
00105 }
00106 }