| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class Tag implements \JsonSerializable |
||
| 12 | { |
||
| 13 | /** @var string */ |
||
| 14 | public $tagName; |
||
| 15 | /** @var Node|null|string */ |
||
| 16 | public $value; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Tag constructor. |
||
| 20 | * @param $tagName |
||
| 21 | * @param $value |
||
| 22 | * @throws \Exception if $tagName is an invalid string or absent |
||
| 23 | */ |
||
| 24 | public function __construct(string $tagName, $value) |
||
| 25 | { |
||
| 26 | if (is_null($tagName)) { |
||
| 27 | throw new \Exception(self::class.": a tag MUST have a name", 1); |
||
| 28 | } |
||
| 29 | $this->tagName = $tagName; |
||
| 30 | $this->value = $value; |
||
| 31 | } |
||
| 32 | |||
| 33 | private function checkNameValidity(string $providedName) |
||
| 35 | /* TODO implement and throw Exception if invalid (setName method ???) |
||
| 36 | *The suffix must not contain any “!” character. This would cause the tag shorthand to be interpreted as having a named tag handle. In addition, the suffix must not contain the “[”, “]”, “{”, “}” and “,” characters. These characters would cause ambiguity with flow collection structures. If the suffix needs to specify any of the above restricted characters, they must be escaped using the “%” character. This behavior is consistent with the URI character escaping rules (specifically, section 2.3 of RFC2396). |
||
| 37 | */ |
||
| 38 | } |
||
| 39 | |||
| 40 | public function jsonSerialize() |
||
| 45 |