Passed
Push — master ( 5988e7...23b4c3 )
by stéphane
02:08
created

Tag::checkNameValidity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Dallgoot\Yaml;
3
4
/**
5
 * TODO
6
 *
7
 * @author  Stéphane Rebai <[email protected]>
8
 * @license Apache 2.0
9
 * @link    TODO : url to specific online doc
10
 */
11
class Tag
12
{
13
    /** @var string */
14
    public $tagName;
15
    /** @var Node|null|string */
16
    public $value;
17
18
    /**
19
     * Tag constructor.
20
     * @param string $tagName the name of the tag like '!str' (WITHOUT the first "!")
21
     * @param mixed $value  any PHP variable type
22
     * @throws \Exception if $tagName is an invalid string or absent
23
     */
24
    public function __construct(string $tagName, $value)
25
    {
26
        if (empty($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
    /**
34
     * Should verify if the tag is correct
35
     *
36
     * @param      string  $providedName  The provided name
37
     * @todo is this required ???
38
     */
39
    // private function checkNameValidity(string $providedName)
40
    // {
41
        /* TODO  implement and throw Exception if invalid (setName method ???)
42
         *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).
43
        */
44
    // }
45
}
46