[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Form/ -> TagCloseElement.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Form;
   4  
   5  /**
   6   * Class TagCloseElement
   7   *
   8   * Creates an HTML close tag. You have to make sure it has been opened
   9   * before or this will produce invalid HTML
  10   *
  11   * @package dokuwiki\Form
  12   */
  13  class TagCloseElement extends ValueElement
  14  {
  15      /**
  16       * @param string $tag
  17       * @param array $attributes
  18       */
  19      public function __construct($tag, $attributes = [])
  20      {
  21          parent::__construct('tagclose', $tag, $attributes);
  22      }
  23  
  24      /**
  25       * do not call this
  26       *
  27       * @param string $class
  28       * @return void
  29       * @throws \BadMethodCallException
  30       */
  31      public function addClass($class)
  32      {
  33          throw new \BadMethodCallException('You can\t add classes to closing tag');
  34      }
  35  
  36      /**
  37       * do not call this
  38       *
  39       * @param null|string $id
  40       * @return string
  41       * @throws \BadMethodCallException
  42       */
  43      public function id($id = null)
  44      {
  45          if ($id === null) {
  46              return '';
  47          } else {
  48              throw new \BadMethodCallException('You can\t add ID to closing tag');
  49          }
  50      }
  51  
  52      /**
  53       * do not call this
  54       *
  55       * @param string $name
  56       * @param null|string $value
  57       * @return string
  58       * @throws \BadMethodCallException
  59       */
  60      public function attr($name, $value = null)
  61      {
  62          if ($value === null) {
  63              return '';
  64          } else {
  65              throw new \BadMethodCallException('You can\t add attributes to closing tag');
  66          }
  67      }
  68  
  69      /**
  70       * do not call this
  71       *
  72       * @param array|null $attributes
  73       * @return array
  74       * @throws \BadMethodCallException
  75       */
  76      public function attrs($attributes = null)
  77      {
  78          if ($attributes === null) {
  79              return [];
  80          } else {
  81              throw new \BadMethodCallException('You can\t add attributes to closing tag');
  82          }
  83      }
  84  
  85      /**
  86       * The HTML representation of this element
  87       *
  88       * @return string
  89       */
  90      public function toHTML()
  91      {
  92          return '</' . $this->val() . '>';
  93      }
  94  }