Passed
Push — master ( f81cc4...5281ab )
by stéphane
04:50
created

Tagged   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
1
<?php
2
namespace Dallgoot\Yaml;
3
4
// use \ReflectionMethod as RM;
5
6
/**
7
 * The Yaml\Tag class is an object type that encapsulates current
8
 * value which is tagged but no methods have been declared
9
 * by user (or standard) to transform it.
10
 * To register a method (Closure) for a specfici tag see Yaml\TagFactory
11
 *
12
 * @author  Stéphane Rebai <[email protected]>
13
 * @license Apache 2.0
14
 * @link    https://github.com/dallgoot/yaml
15
 * @see     TagFactory
16
 */
17
final class Tagged
18
{
19
    /** @var string */
20
    public $tagName;
21
    /** @var mixed */
22
    public $value;
23
24
    private const NO_NAME = '%s Error: a tag MUST have a name';
25
26 2
    public function __construct(string $tagName, $value)
27
    {
28 2
        if (empty($tagName)) {
29 1
            throw new \Exception(sprintf(self::NO_NAME, __METHOD__));
30
        }
31 2
        $this->tagName = $tagName;
32 2
        $this->value   = $value;
33 2
    }
34
35
    /**
36
     * Should verify if the tag is correct
37
     *
38
     * @param string $providedName The provided name
39
     * @todo  is this required ???
40
     */
41
    // private function checkNameValidity(string $providedName)
42
    // {
43
        /* TODO  implement and throw Exception if invalid (setName method ???)
44
         *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).
45
46
         regex (([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
47
        */
48
    // }
49
}