Completed
Push — master ( c7418d...8b4244 )
by stéphane
04:44
created

Tag::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Dallgoot\Yaml;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
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
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
11
class Tag implements \JsonSerializable
12
{
13
    /** @var string */
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
    public $tagName;
15
    /** @var Node|null|string */
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
16
    public $value;
17
18
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $tagName should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $value should have a doc-comment as per coding-style.
Loading history...
19
     * Tag constructor.
20
     * @param $tagName
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style Documentation introduced by
Missing parameter name
Loading history...
21
     * @param $value
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter name
Loading history...
22
     * @throws \Exception if $tagName is an invalid string or absent
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
23
     */
24
    public function __construct(string $tagName, $value)
25
    {
26
        if (is_null($tagName)) {
0 ignored issues
show
introduced by
The condition is_null($tagName) is always false.
Loading history...
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)
0 ignored issues
show
Unused Code introduced by
The parameter $providedName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    private function checkNameValidity(/** @scrutinizer ignore-unused */ string $providedName)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The method checkNameValidity() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
Coding Style introduced by
Private method name "Tag::checkNameValidity" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
34
    {
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()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
41
    {
42
        return ["tagName" => $this->tagName, "value" => $this->value];
43
    }
44
}
45