GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BidirectionalityParser::parseClassing()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties;
4
5
use UCD\Unicode\Character\Properties\Bidirectionality;
6
use UCD\Unicode\Character\Properties\Bidirectionality\Bracket;
7
use UCD\Unicode\Character\Properties\Bidirectionality\BracketBidirectionality;
8
use UCD\Unicode\Character\Properties\Bidirectionality\Classing;
9
use UCD\Unicode\Character\Properties\Bidirectionality\Mirroring;
10
use UCD\Unicode\Codepoint;
11
12
class BidirectionalityParser extends BaseParser
13
{
14
    const BACKET_TYPE_NONE = 'n';
15
    const BRACKET_TYPE_OPEN = 'o';
16
17
    const ATTR_BIDIRECTIONALITY_CLASS = 'bc';
18
    const ATTR_MIRRORED = 'Bidi_M';
19
    const ATTR_MIRROR_GLYPH = 'bmg';
20
    const ATTR_BIDIRECTIONALITY_CONTROL = 'Bidi_C';
21
    const ATTR_PAIRED_BRACKET_TYPE = 'bpt';
22
    const ATTR_PAIRED_BRACKET = 'bpb';
23
24
    /**
25
     * @return mixed
26
     */
27
    protected function parse()
28
    {
29
        $class = $this->parseClassing();
30
        $mirroring = $this->parseMirroring();
31
        $isControl = $this->getBoolAttribute(self::ATTR_BIDIRECTIONALITY_CONTROL);
32
        $bracketType = $this->getAttribute(self::ATTR_PAIRED_BRACKET_TYPE);
33
34
        if ($bracketType === self::BACKET_TYPE_NONE) {
35
            return new Bidirectionality($class, $mirroring, $isControl);
36
        }
37
38
        $pairedWith = Codepoint::fromHex($this->getAttribute(self::ATTR_PAIRED_BRACKET));
39
40
        $bracket = ($bracketType === self::BRACKET_TYPE_OPEN)
41
            ? Bracket::createOpen($pairedWith)
42
            : Bracket::createClose($pairedWith);
43
44
        return new BracketBidirectionality($class, $mirroring, $isControl, $bracket);
45
    }
46
47
    /**
48
     * @return Classing
49
     */
50
    private function parseClassing()
51
    {
52
        return new Classing($this->getAttribute(self::ATTR_BIDIRECTIONALITY_CLASS));
53
    }
54
55
    /**
56
     * @return Mirroring
57
     */
58
    private function parseMirroring()
59
    {
60
        $isMirrored = $this->getBoolAttribute(self::ATTR_MIRRORED);
61
        $mirroredByValue = $this->getOptionalAttribute(self::ATTR_MIRROR_GLYPH);
62
63
        $mirroredBy = ($mirroredByValue !== null)
64
            ? Codepoint::fromHex($mirroredByValue)
65
            : null;
66
67
        return new Mirroring($isMirrored, $mirroredBy);
68
    }
69
}