aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Form/TagCloseElement.php
blob: 20579a16dccc4423fb55be7b7c40609c3a27fa5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php

namespace dokuwiki\Form;

/**
 * Class TagCloseElement
 *
 * Creates an HTML close tag. You have to make sure it has been opened
 * before or this will produce invalid HTML
 *
 * @package dokuwiki\Form
 */
class TagCloseElement extends ValueElement
{
    /**
     * @param string $tag
     * @param array $attributes
     */
    public function __construct($tag, $attributes = [])
    {
        parent::__construct('tagclose', $tag, $attributes);
    }

    /**
     * do not call this
     *
     * @param string $class
     * @return void
     * @throws \BadMethodCallException
     */
    public function addClass($class)
    {
        throw new \BadMethodCallException('You can\t add classes to closing tag');
    }

    /**
     * do not call this
     *
     * @param null|string $id
     * @return string
     * @throws \BadMethodCallException
     */
    public function id($id = null)
    {
        if ($id === null) {
            return '';
        } else {
            throw new \BadMethodCallException('You can\t add ID to closing tag');
        }
    }

    /**
     * do not call this
     *
     * @param string $name
     * @param null|string $value
     * @return string
     * @throws \BadMethodCallException
     */
    public function attr($name, $value = null)
    {
        if ($value === null) {
            return '';
        } else {
            throw new \BadMethodCallException('You can\t add attributes to closing tag');
        }
    }

    /**
     * do not call this
     *
     * @param array|null $attributes
     * @return array
     * @throws \BadMethodCallException
     */
    public function attrs($attributes = null)
    {
        if ($attributes === null) {
            return [];
        } else {
            throw new \BadMethodCallException('You can\t add attributes to closing tag');
        }
    }

    /**
     * The HTML representation of this element
     *
     * @return string
     */
    public function toHTML()
    {
        return '</' . $this->val() . '>';
    }
}