1 | <?php |
||
11 | class ComplexTagMatcher extends TagMatcher { |
||
12 | |||
13 | /** |
||
14 | * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors |
||
15 | * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257 |
||
16 | */ |
||
17 | const XML_UNKNOWN_TAG_ERROR_CODE = 801; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $tagHtmlOutline; |
||
23 | |||
24 | /** |
||
25 | * @var Matcher |
||
26 | */ |
||
27 | private $matcher; |
||
28 | |||
29 | /** |
||
30 | * @param string $htmlOutline |
||
31 | * |
||
32 | * @return self |
||
33 | */ |
||
34 | 13 | public static function tagMatchingOutline( $htmlOutline ) { |
|
37 | |||
38 | /** |
||
39 | * @param string $tagHtmlRepresentation |
||
40 | */ |
||
41 | 13 | public function __construct( $tagHtmlRepresentation ) { |
|
47 | |||
48 | 6 | public function describeTo( Description $description ) { |
|
53 | |||
54 | /** |
||
55 | * @param \DOMElement $item |
||
56 | * @param Description $mismatchDescription |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | 12 | protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) { |
|
70 | |||
71 | /** |
||
72 | * @param string $htmlOutline |
||
73 | * |
||
74 | * @return Matcher |
||
75 | */ |
||
76 | 13 | private function createMatcherFromHtml( $htmlOutline ) { |
|
91 | |||
92 | /** |
||
93 | * @param \LibXMLError $error |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | private function isUnknownTagError( \LibXMLError $error ) { |
||
100 | |||
101 | /** |
||
102 | * @param string $inputHtml |
||
103 | * @param string $attributeName |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | 5 | private function isBooleanAttribute( $inputHtml, $attributeName ) { |
|
113 | |||
114 | /** |
||
115 | * @param string $html |
||
116 | * |
||
117 | * @return \DOMDocument |
||
118 | * @throws \InvalidArgumentException |
||
119 | */ |
||
120 | 13 | private function parseHtml( $html ) { |
|
146 | |||
147 | /** |
||
148 | * @param \DOMDocument $document |
||
149 | * |
||
150 | * @return \DOMElement |
||
151 | * @throws \InvalidArgumentException |
||
152 | */ |
||
153 | 12 | private function getSingleTagFromThe( \DOMDocument $document ) { |
|
164 | |||
165 | 11 | private function assertTagDoesNotContainChildren( \DOMElement $targetTag ) { |
|
170 | |||
171 | /** |
||
172 | * @param string $inputHtml |
||
173 | * @param \DOMElement $targetTag |
||
174 | * |
||
175 | * @return AttributeMatcher[] |
||
176 | */ |
||
177 | 10 | private function createAttributeMatchers( $inputHtml, \DOMElement $targetTag ) { |
|
194 | |||
195 | /** |
||
196 | * @param \DOMElement $targetTag |
||
197 | * |
||
198 | * @return ClassMatcher[] |
||
199 | */ |
||
200 | 10 | private function createClassMatchers( \DOMElement $targetTag ) { |
|
211 | |||
212 | /** |
||
213 | * @param \DOMElement $element |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | 7 | private function elementToString( \DOMElement $element ) { |
|
223 | |||
224 | } |
||
225 |