FOSSology  4.4.0
Open Source License Compliance by Open Source Software
SimpleHtmlElement.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Html;
9 
11 {
12 
13  private $name;
14  private $attributes;
15 
16  function __construct($name, $attributes = array())
17  {
18  $this->name = $name;
19  $this->attributes = $attributes;
20  }
21 
26  function setAttribute($name, $value)
27  {
28  $this->attributes[$name] = $value;
29  }
30 
31  function getOpeningText()
32  {
33  $openingText = "<" . $this->name;
34  foreach ($this->attributes as $name => $value) {
35  $openingText .= " $name=\"$value\"";
36  }
37  return $openingText . ">";
38  }
39 
40  function getClosingText()
41  {
42  return "</$this->name>";
43  }
44 }