1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser; |
4
|
|
|
|
5
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\LetterCaseParser; |
6
|
|
|
use UCD\Unicode\Character; |
7
|
|
|
use UCD\Unicode\Character\Properties; |
8
|
|
|
use UCD\Unicode\Codepoint; |
9
|
|
|
|
10
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser; |
11
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\BidirectionalityParser; |
12
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\GeneralParser; |
13
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\NormalizationParser; |
14
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\NumericityParser; |
15
|
|
|
use UCD\Infrastructure\Repository\CharacterRepository\XMLRepository\ElementParser\Properties\ShapingParser; |
16
|
|
|
|
17
|
|
|
class CharacterParser implements CodepointAwareParser |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var GeneralParser |
21
|
|
|
*/ |
22
|
|
|
private $generalParser; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var LetterCaseParser |
26
|
|
|
*/ |
27
|
|
|
private $letterCaseParser; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var NormalizationParser |
31
|
|
|
*/ |
32
|
|
|
private $normalizationParser; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var NumericityParser |
36
|
|
|
*/ |
37
|
|
|
private $numericityParser; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var BidirectionalityParser |
41
|
|
|
*/ |
42
|
|
|
private $bidirectionalityParser; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var ShapingParser |
46
|
|
|
*/ |
47
|
|
|
private $shapingParser; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param GeneralParser $generalParser |
51
|
|
|
* @param LetterCaseParser $letterCaseParser |
52
|
|
|
* @param NormalizationParser $normalizationParser |
53
|
|
|
* @param NumericityParser $numericityParser |
54
|
|
|
* @param BidirectionalityParser $bidirectionalityParser |
55
|
|
|
* @param ShapingParser $shapingParser |
56
|
|
|
*/ |
57
|
|
|
public function __construct( |
58
|
|
|
GeneralParser $generalParser, |
59
|
|
|
LetterCaseParser $letterCaseParser, |
60
|
|
|
NormalizationParser $normalizationParser, |
61
|
|
|
NumericityParser $numericityParser, |
62
|
|
|
BidirectionalityParser $bidirectionalityParser, |
63
|
|
|
ShapingParser $shapingParser |
64
|
|
|
) { |
65
|
|
|
$this->generalParser = $generalParser; |
66
|
|
|
$this->letterCaseParser = $letterCaseParser; |
67
|
|
|
$this->normalizationParser = $normalizationParser; |
68
|
|
|
$this->numericityParser = $numericityParser; |
69
|
|
|
$this->bidirectionalityParser = $bidirectionalityParser; |
70
|
|
|
$this->shapingParser = $shapingParser; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param \DOMElement $element |
75
|
|
|
* @param Codepoint $codepoint |
76
|
|
|
* @return Character |
77
|
|
|
*/ |
78
|
|
|
public function parseElement(\DOMElement $element, Codepoint $codepoint) |
79
|
|
|
{ |
80
|
|
|
$general = $this->generalParser->parseElement($element, $codepoint); |
81
|
|
|
$case = $this->letterCaseParser->parseElement($element, $codepoint); |
82
|
|
|
$normalization = $this->normalizationParser->parseElement($element, $codepoint); |
83
|
|
|
$numericity = $this->numericityParser->parseElement($element, $codepoint); |
84
|
|
|
$bidirectionality = $this->bidirectionalityParser->parseElement($element, $codepoint); |
85
|
|
|
$shaping = $this->shapingParser->parseElement($element, $codepoint); |
86
|
|
|
$properties = new Properties($general, $case, $numericity, $normalization, $bidirectionality, $shaping); |
87
|
|
|
|
88
|
|
|
return new Character($codepoint, $properties); |
89
|
|
|
} |
90
|
|
|
} |