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.
Completed
Pull Request — master (#10)
by no
07:39 queued 04:02
created
src/ChildElementMatcher.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -8,60 +8,60 @@
 block discarded – undo
8 8
 
9 9
 class ChildElementMatcher extends TypeSafeDiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher|null
13
-	 */
14
-	private $matcher;
11
+    /**
12
+     * @var Matcher|null
13
+     */
14
+    private $matcher;
15 15
 
16
-	public static function havingChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
18
-	}
16
+    public static function havingChild( Matcher $elementMatcher = null ) {
17
+        return new static( $elementMatcher );
18
+    }
19 19
 
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
22
-		$this->matcher = $matcher;
23
-	}
20
+    public function __construct( Matcher $matcher = null ) {
21
+        parent::__construct( \DOMNode::class );
22
+        $this->matcher = $matcher;
23
+    }
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
29
-		}
30
-	}
25
+    public function describeTo( Description $description ) {
26
+        $description->appendText( 'having child ' );
27
+        if ( $this->matcher ) {
28
+            $description->appendDescriptionOf( $this->matcher );
29
+        }
30
+    }
31 31
 
32
-	/**
33
-	 * @param \DOMDocument|\DOMNode $item
34
-	 * @param Description $mismatchDescription
35
-	 *
36
-	 * @return bool
37
-	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
32
+    /**
33
+     * @param \DOMDocument|\DOMNode $item
34
+     * @param Description $mismatchDescription
35
+     *
36
+     * @return bool
37
+     */
38
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
+        if ( $item instanceof \DOMDocument ) {
40
+            $directChildren = iterator_to_array( $item->documentElement->childNodes );
41 41
 
42
-			$body = array_shift( $directChildren );
43
-			$directChildren = $body->childNodes;
44
-		} else {
45
-			$directChildren = $item->childNodes;
46
-		}
42
+            $body = array_shift( $directChildren );
43
+            $directChildren = $body->childNodes;
44
+        } else {
45
+            $directChildren = $item->childNodes;
46
+        }
47 47
 
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'having no children' );
50
-			return false;
51
-		}
48
+        if ( $directChildren->length === 0 ) {
49
+            $mismatchDescription->appendText( 'having no children' );
50
+            return false;
51
+        }
52 52
 
53
-		if ( !$this->matcher ) {
54
-			return $directChildren->length > 0;
55
-		}
53
+        if ( !$this->matcher ) {
54
+            return $directChildren->length > 0;
55
+        }
56 56
 
57
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
59
-				return true;
60
-			}
61
-		}
57
+        foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
+            if ( $this->matcher && $this->matcher->matches( $child ) ) {
59
+                return true;
60
+            }
61
+        }
62 62
 
63
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
64
-		return false;
65
-	}
63
+        $mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
64
+        return false;
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	private $matcher;
15 15
 
16
-	public static function havingChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
16
+	public static function havingChild(Matcher $elementMatcher = null) {
17
+		return new static($elementMatcher);
18 18
 	}
19 19
 
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
20
+	public function __construct(Matcher $matcher = null) {
21
+		parent::__construct(\DOMNode::class);
22 22
 		$this->matcher = $matcher;
23 23
 	}
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
25
+	public function describeTo(Description $description) {
26
+		$description->appendText('having child ');
27
+		if ($this->matcher) {
28
+			$description->appendDescriptionOf($this->matcher);
29 29
 		}
30 30
 	}
31 31
 
@@ -35,32 +35,32 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return bool
37 37
 	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
38
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
39
+		if ($item instanceof \DOMDocument) {
40
+			$directChildren = iterator_to_array($item->documentElement->childNodes);
41 41
 
42
-			$body = array_shift( $directChildren );
42
+			$body = array_shift($directChildren);
43 43
 			$directChildren = $body->childNodes;
44 44
 		} else {
45 45
 			$directChildren = $item->childNodes;
46 46
 		}
47 47
 
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'having no children' );
48
+		if ($directChildren->length === 0) {
49
+			$mismatchDescription->appendText('having no children');
50 50
 			return false;
51 51
 		}
52 52
 
53
-		if ( !$this->matcher ) {
53
+		if (!$this->matcher) {
54 54
 			return $directChildren->length > 0;
55 55
 		}
56 56
 
57
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
57
+		foreach (new XmlNodeRecursiveIterator($directChildren) as $child) {
58
+			if ($this->matcher && $this->matcher->matches($child)) {
59 59
 				return true;
60 60
 			}
61 61
 		}
62 62
 
63
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
63
+		$mismatchDescription->appendText('having no children ')->appendDescriptionOf($this->matcher);
64 64
 		return false;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/TagMatcher.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 abstract class TagMatcher extends TypeSafeDiagnosingMatcher {
8 8
 
9
-	public function __construct() {
10
-		parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
11
-	}
9
+    public function __construct() {
10
+        parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
11
+    }
12 12
 
13 13
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 abstract class TagMatcher extends TypeSafeDiagnosingMatcher {
8 8
 
9 9
 	public function __construct() {
10
-		parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
10
+		parent::__construct(self::TYPE_OBJECT, \DOMElement::class);
11 11
 	}
12 12
 
13 13
 }
Please login to merge, or discard this patch.
src/HtmlMatcher.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -8,94 +8,94 @@
 block discarded – undo
8 8
 
9 9
 class HtmlMatcher extends DiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
13
-	 * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
14
-	 */
15
-	const XML_UNKNOWN_TAG_ERROR_CODE = 801;
16
-
17
-	/**
18
-	 * @var Matcher
19
-	 */
20
-	private $elementMatcher;
21
-
22
-	/**
23
-	 * @param Matcher $elementMatcher
24
-	 *
25
-	 * @return HtmlMatcher
26
-	 */
27
-	public static function htmlPiece( Matcher $elementMatcher = null ) {
28
-		return new static( $elementMatcher );
29
-	}
30
-
31
-	private function __construct( Matcher $elementMatcher = null ) {
32
-		$this->elementMatcher = $elementMatcher;
33
-	}
34
-
35
-	public function describeTo( Description $description ) {
36
-		$description->appendText( 'valid html piece ' );
37
-		if ( $this->elementMatcher ) {
38
-			$description->appendDescriptionOf( $this->elementMatcher );
39
-		}
40
-	}
41
-
42
-	protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
43
-		$internalErrors = libxml_use_internal_errors( true );
44
-		$document = new \DOMDocument();
45
-
46
-		$html = $this->escapeScriptTagContents( $html );
47
-
48
-		if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
49
-			$mismatchDescription->appendText( 'there was some parsing error' );
50
-			return false;
51
-		}
52
-
53
-		$errors = libxml_get_errors();
54
-		libxml_clear_errors();
55
-		libxml_use_internal_errors( $internalErrors );
56
-
57
-		$result = true;
58
-		/** @var \LibXMLError $error */
59
-		foreach ( $errors as $error ) {
60
-			if ( $this->isUnknownTagError( $error ) ) {
61
-				continue;
62
-			}
63
-
64
-			$mismatchDescription->appendText( 'there was parsing error: ' )
65
-				->appendText( trim( $error->message ) )
66
-				->appendText( ' on line ' )
67
-				->appendText( $error->line );
68
-			$result = false;
69
-		}
70
-
71
-		if ( $result === false ) {
72
-			return $result;
73
-		}
74
-		$mismatchDescription->appendText( 'valid html piece ' );
75
-
76
-		if ( $this->elementMatcher ) {
77
-			$result = $this->elementMatcher->matches( $document );
78
-			$this->elementMatcher->describeMismatch( $document, $mismatchDescription );
79
-		}
80
-
81
-		$mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
82
-
83
-		return $result;
84
-	}
85
-
86
-	private function isUnknownTagError( \LibXMLError $error ) {
87
-		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
88
-	}
89
-
90
-	/**
91
-	 * @param string $html
92
-	 *
93
-	 * @return string HTML
94
-	 */
95
-	private function escapeScriptTagContents( $html ) {
96
-		return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', function ( $matches ) {
97
-			return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
98
-		}, $html );
99
-	}
11
+    /**
12
+     * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
13
+     * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
14
+     */
15
+    const XML_UNKNOWN_TAG_ERROR_CODE = 801;
16
+
17
+    /**
18
+     * @var Matcher
19
+     */
20
+    private $elementMatcher;
21
+
22
+    /**
23
+     * @param Matcher $elementMatcher
24
+     *
25
+     * @return HtmlMatcher
26
+     */
27
+    public static function htmlPiece( Matcher $elementMatcher = null ) {
28
+        return new static( $elementMatcher );
29
+    }
30
+
31
+    private function __construct( Matcher $elementMatcher = null ) {
32
+        $this->elementMatcher = $elementMatcher;
33
+    }
34
+
35
+    public function describeTo( Description $description ) {
36
+        $description->appendText( 'valid html piece ' );
37
+        if ( $this->elementMatcher ) {
38
+            $description->appendDescriptionOf( $this->elementMatcher );
39
+        }
40
+    }
41
+
42
+    protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
43
+        $internalErrors = libxml_use_internal_errors( true );
44
+        $document = new \DOMDocument();
45
+
46
+        $html = $this->escapeScriptTagContents( $html );
47
+
48
+        if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
49
+            $mismatchDescription->appendText( 'there was some parsing error' );
50
+            return false;
51
+        }
52
+
53
+        $errors = libxml_get_errors();
54
+        libxml_clear_errors();
55
+        libxml_use_internal_errors( $internalErrors );
56
+
57
+        $result = true;
58
+        /** @var \LibXMLError $error */
59
+        foreach ( $errors as $error ) {
60
+            if ( $this->isUnknownTagError( $error ) ) {
61
+                continue;
62
+            }
63
+
64
+            $mismatchDescription->appendText( 'there was parsing error: ' )
65
+                ->appendText( trim( $error->message ) )
66
+                ->appendText( ' on line ' )
67
+                ->appendText( $error->line );
68
+            $result = false;
69
+        }
70
+
71
+        if ( $result === false ) {
72
+            return $result;
73
+        }
74
+        $mismatchDescription->appendText( 'valid html piece ' );
75
+
76
+        if ( $this->elementMatcher ) {
77
+            $result = $this->elementMatcher->matches( $document );
78
+            $this->elementMatcher->describeMismatch( $document, $mismatchDescription );
79
+        }
80
+
81
+        $mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
82
+
83
+        return $result;
84
+    }
85
+
86
+    private function isUnknownTagError( \LibXMLError $error ) {
87
+        return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
88
+    }
89
+
90
+    /**
91
+     * @param string $html
92
+     *
93
+     * @return string HTML
94
+     */
95
+    private function escapeScriptTagContents( $html ) {
96
+        return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', function ( $matches ) {
97
+            return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
98
+        }, $html );
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,66 +24,66 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return HtmlMatcher
26 26
 	 */
27
-	public static function htmlPiece( Matcher $elementMatcher = null ) {
28
-		return new static( $elementMatcher );
27
+	public static function htmlPiece(Matcher $elementMatcher = null) {
28
+		return new static($elementMatcher);
29 29
 	}
30 30
 
31
-	private function __construct( Matcher $elementMatcher = null ) {
31
+	private function __construct(Matcher $elementMatcher = null) {
32 32
 		$this->elementMatcher = $elementMatcher;
33 33
 	}
34 34
 
35
-	public function describeTo( Description $description ) {
36
-		$description->appendText( 'valid html piece ' );
37
-		if ( $this->elementMatcher ) {
38
-			$description->appendDescriptionOf( $this->elementMatcher );
35
+	public function describeTo(Description $description) {
36
+		$description->appendText('valid html piece ');
37
+		if ($this->elementMatcher) {
38
+			$description->appendDescriptionOf($this->elementMatcher);
39 39
 		}
40 40
 	}
41 41
 
42
-	protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
43
-		$internalErrors = libxml_use_internal_errors( true );
42
+	protected function matchesWithDiagnosticDescription($html, Description $mismatchDescription) {
43
+		$internalErrors = libxml_use_internal_errors(true);
44 44
 		$document = new \DOMDocument();
45 45
 
46
-		$html = $this->escapeScriptTagContents( $html );
46
+		$html = $this->escapeScriptTagContents($html);
47 47
 
48
-		if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
49
-			$mismatchDescription->appendText( 'there was some parsing error' );
48
+		if (!@$document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'))) {
49
+			$mismatchDescription->appendText('there was some parsing error');
50 50
 			return false;
51 51
 		}
52 52
 
53 53
 		$errors = libxml_get_errors();
54 54
 		libxml_clear_errors();
55
-		libxml_use_internal_errors( $internalErrors );
55
+		libxml_use_internal_errors($internalErrors);
56 56
 
57 57
 		$result = true;
58 58
 		/** @var \LibXMLError $error */
59
-		foreach ( $errors as $error ) {
60
-			if ( $this->isUnknownTagError( $error ) ) {
59
+		foreach ($errors as $error) {
60
+			if ($this->isUnknownTagError($error)) {
61 61
 				continue;
62 62
 			}
63 63
 
64
-			$mismatchDescription->appendText( 'there was parsing error: ' )
65
-				->appendText( trim( $error->message ) )
66
-				->appendText( ' on line ' )
67
-				->appendText( $error->line );
64
+			$mismatchDescription->appendText('there was parsing error: ')
65
+				->appendText(trim($error->message))
66
+				->appendText(' on line ')
67
+				->appendText($error->line);
68 68
 			$result = false;
69 69
 		}
70 70
 
71
-		if ( $result === false ) {
71
+		if ($result === false) {
72 72
 			return $result;
73 73
 		}
74
-		$mismatchDescription->appendText( 'valid html piece ' );
74
+		$mismatchDescription->appendText('valid html piece ');
75 75
 
76
-		if ( $this->elementMatcher ) {
77
-			$result = $this->elementMatcher->matches( $document );
78
-			$this->elementMatcher->describeMismatch( $document, $mismatchDescription );
76
+		if ($this->elementMatcher) {
77
+			$result = $this->elementMatcher->matches($document);
78
+			$this->elementMatcher->describeMismatch($document, $mismatchDescription);
79 79
 		}
80 80
 
81
-		$mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
81
+		$mismatchDescription->appendText("\nActual html:\n")->appendText($html);
82 82
 
83 83
 		return $result;
84 84
 	}
85 85
 
86
-	private function isUnknownTagError( \LibXMLError $error ) {
86
+	private function isUnknownTagError(\LibXMLError $error) {
87 87
 		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
88 88
 	}
89 89
 
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return string HTML
94 94
 	 */
95
-	private function escapeScriptTagContents( $html ) {
96
-		return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', function ( $matches ) {
97
-			return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
98
-		}, $html );
95
+	private function escapeScriptTagContents($html) {
96
+		return preg_replace_callback('#(<script.*>)(.*)(</script>)#isU', function($matches) {
97
+			return $matches[1] . str_replace('</', '<\/', $matches[2]) . $matches[3];
98
+		}, $html);
99 99
 	}
100 100
 
101 101
 }
Please login to merge, or discard this patch.
src/ClassMatcher.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -8,41 +8,41 @@
 block discarded – undo
8 8
 
9 9
 class ClassMatcher extends TagMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $classMatcher;
15
-
16
-	public static function withClass( $class ) {
17
-		return new static( Util::wrapValueWithIsEqual( $class ) );
18
-	}
19
-
20
-	public function __construct( Matcher $class ) {
21
-		parent::__construct();
22
-		$this->classMatcher = $class;
23
-	}
24
-
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'with class ' )->appendDescriptionOf( $this->classMatcher );
27
-	}
28
-
29
-	/**
30
-	 * @param \DOMElement $item
31
-	 * @param Description $mismatchDescription
32
-	 *
33
-	 * @return bool
34
-	 */
35
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
36
-		$classAttribute = $item->getAttribute( 'class' );
37
-
38
-		$classes = preg_split( '/\s+/u', $classAttribute );
39
-		foreach ( $classes as $class ) {
40
-			if ( $this->classMatcher->matches( $class ) ) {
41
-				return true;
42
-			}
43
-		}
44
-
45
-		return false;
46
-	}
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $classMatcher;
15
+
16
+    public static function withClass( $class ) {
17
+        return new static( Util::wrapValueWithIsEqual( $class ) );
18
+    }
19
+
20
+    public function __construct( Matcher $class ) {
21
+        parent::__construct();
22
+        $this->classMatcher = $class;
23
+    }
24
+
25
+    public function describeTo( Description $description ) {
26
+        $description->appendText( 'with class ' )->appendDescriptionOf( $this->classMatcher );
27
+    }
28
+
29
+    /**
30
+     * @param \DOMElement $item
31
+     * @param Description $mismatchDescription
32
+     *
33
+     * @return bool
34
+     */
35
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
36
+        $classAttribute = $item->getAttribute( 'class' );
37
+
38
+        $classes = preg_split( '/\s+/u', $classAttribute );
39
+        foreach ( $classes as $class ) {
40
+            if ( $this->classMatcher->matches( $class ) ) {
41
+                return true;
42
+            }
43
+        }
44
+
45
+        return false;
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	private $classMatcher;
15 15
 
16
-	public static function withClass( $class ) {
17
-		return new static( Util::wrapValueWithIsEqual( $class ) );
16
+	public static function withClass($class) {
17
+		return new static(Util::wrapValueWithIsEqual($class));
18 18
 	}
19 19
 
20
-	public function __construct( Matcher $class ) {
20
+	public function __construct(Matcher $class) {
21 21
 		parent::__construct();
22 22
 		$this->classMatcher = $class;
23 23
 	}
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'with class ' )->appendDescriptionOf( $this->classMatcher );
25
+	public function describeTo(Description $description) {
26
+		$description->appendText('with class ')->appendDescriptionOf($this->classMatcher);
27 27
 	}
28 28
 
29 29
 	/**
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return bool
34 34
 	 */
35
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
36
-		$classAttribute = $item->getAttribute( 'class' );
35
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
36
+		$classAttribute = $item->getAttribute('class');
37 37
 
38
-		$classes = preg_split( '/\s+/u', $classAttribute );
39
-		foreach ( $classes as $class ) {
40
-			if ( $this->classMatcher->matches( $class ) ) {
38
+		$classes = preg_split('/\s+/u', $classAttribute);
39
+		foreach ($classes as $class) {
40
+			if ($this->classMatcher->matches($class)) {
41 41
 				return true;
42 42
 			}
43 43
 		}
Please login to merge, or discard this patch.
src/AttributeMatcher.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -8,75 +8,75 @@
 block discarded – undo
8 8
 
9 9
 class AttributeMatcher extends TagMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $attributeNameMatcher;
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $attributeNameMatcher;
15 15
 
16
-	/**
17
-	 * @var Matcher|null
18
-	 */
19
-	private $valueMatcher;
16
+    /**
17
+     * @var Matcher|null
18
+     */
19
+    private $valueMatcher;
20 20
 
21
-	public static function withAttribute( $attributeName ) {
22
-		return new static( Util::wrapValueWithIsEqual( $attributeName ) );
23
-	}
21
+    public static function withAttribute( $attributeName ) {
22
+        return new static( Util::wrapValueWithIsEqual( $attributeName ) );
23
+    }
24 24
 
25
-	/**
26
-	 * AttributeMatcher constructor.
27
-	 * @param \Hamcrest\Matcher $attributeNameMatcher
28
-	 */
29
-	public function __construct( Matcher $attributeNameMatcher ) {
30
-		parent::__construct();
25
+    /**
26
+     * AttributeMatcher constructor.
27
+     * @param \Hamcrest\Matcher $attributeNameMatcher
28
+     */
29
+    public function __construct( Matcher $attributeNameMatcher ) {
30
+        parent::__construct();
31 31
 
32
-		$this->attributeNameMatcher = $attributeNameMatcher;
33
-	}
32
+        $this->attributeNameMatcher = $attributeNameMatcher;
33
+    }
34 34
 
35
-	/**
36
-	 * @param Matcher|mixed $value
37
-	 * @return AttributeMatcher
38
-	 */
39
-	public function havingValue( $value ) {
40
-		// TODO: Throw exception if value is set
41
-		$result = clone $this;
42
-		$result->valueMatcher = Util::wrapValueWithIsEqual( $value );
35
+    /**
36
+     * @param Matcher|mixed $value
37
+     * @return AttributeMatcher
38
+     */
39
+    public function havingValue( $value ) {
40
+        // TODO: Throw exception if value is set
41
+        $result = clone $this;
42
+        $result->valueMatcher = Util::wrapValueWithIsEqual( $value );
43 43
 
44
-		return $result;
45
-	}
44
+        return $result;
45
+    }
46 46
 
47
-	public function describeTo( Description $description ) {
48
-		$description->appendText( 'with attribute ' )
49
-			->appendDescriptionOf( $this->attributeNameMatcher );
50
-		if ( $this->valueMatcher ) {
51
-			$description->appendText( ' having value ' )
52
-				->appendDescriptionOf( $this->valueMatcher );
53
-		}
54
-	}
47
+    public function describeTo( Description $description ) {
48
+        $description->appendText( 'with attribute ' )
49
+            ->appendDescriptionOf( $this->attributeNameMatcher );
50
+        if ( $this->valueMatcher ) {
51
+            $description->appendText( ' having value ' )
52
+                ->appendDescriptionOf( $this->valueMatcher );
53
+        }
54
+    }
55 55
 
56
-	/**
57
-	 * @param \DOMElement $item
58
-	 * @param Description $mismatchDescription
59
-	 *
60
-	 * @return bool
61
-	 */
62
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
63
-		/** @var \DOMAttr $attribute */
64
-		foreach ( $item->attributes as $attribute ) {
65
-			if ( $this->valueMatcher ) {
66
-				if (
67
-					$this->attributeNameMatcher->matches( $attribute->name )
68
-					&& $this->valueMatcher->matches( $attribute->value )
69
-				) {
70
-					return true;
71
-				}
72
-			} else {
73
-				if ( $this->attributeNameMatcher->matches( $attribute->name ) ) {
74
-					return true;
75
-				}
76
-			}
77
-		}
56
+    /**
57
+     * @param \DOMElement $item
58
+     * @param Description $mismatchDescription
59
+     *
60
+     * @return bool
61
+     */
62
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
63
+        /** @var \DOMAttr $attribute */
64
+        foreach ( $item->attributes as $attribute ) {
65
+            if ( $this->valueMatcher ) {
66
+                if (
67
+                    $this->attributeNameMatcher->matches( $attribute->name )
68
+                    && $this->valueMatcher->matches( $attribute->value )
69
+                ) {
70
+                    return true;
71
+                }
72
+            } else {
73
+                if ( $this->attributeNameMatcher->matches( $attribute->name ) ) {
74
+                    return true;
75
+                }
76
+            }
77
+        }
78 78
 
79
-		return false;
80
-	}
79
+        return false;
80
+    }
81 81
 
82 82
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	 */
19 19
 	private $valueMatcher;
20 20
 
21
-	public static function withAttribute( $attributeName ) {
22
-		return new static( Util::wrapValueWithIsEqual( $attributeName ) );
21
+	public static function withAttribute($attributeName) {
22
+		return new static(Util::wrapValueWithIsEqual($attributeName));
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * AttributeMatcher constructor.
27 27
 	 * @param \Hamcrest\Matcher $attributeNameMatcher
28 28
 	 */
29
-	public function __construct( Matcher $attributeNameMatcher ) {
29
+	public function __construct(Matcher $attributeNameMatcher) {
30 30
 		parent::__construct();
31 31
 
32 32
 		$this->attributeNameMatcher = $attributeNameMatcher;
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
 	 * @param Matcher|mixed $value
37 37
 	 * @return AttributeMatcher
38 38
 	 */
39
-	public function havingValue( $value ) {
39
+	public function havingValue($value) {
40 40
 		// TODO: Throw exception if value is set
41 41
 		$result = clone $this;
42
-		$result->valueMatcher = Util::wrapValueWithIsEqual( $value );
42
+		$result->valueMatcher = Util::wrapValueWithIsEqual($value);
43 43
 
44 44
 		return $result;
45 45
 	}
46 46
 
47
-	public function describeTo( Description $description ) {
48
-		$description->appendText( 'with attribute ' )
49
-			->appendDescriptionOf( $this->attributeNameMatcher );
50
-		if ( $this->valueMatcher ) {
51
-			$description->appendText( ' having value ' )
52
-				->appendDescriptionOf( $this->valueMatcher );
47
+	public function describeTo(Description $description) {
48
+		$description->appendText('with attribute ')
49
+			->appendDescriptionOf($this->attributeNameMatcher);
50
+		if ($this->valueMatcher) {
51
+			$description->appendText(' having value ')
52
+				->appendDescriptionOf($this->valueMatcher);
53 53
 		}
54 54
 	}
55 55
 
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return bool
61 61
 	 */
62
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
62
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
63 63
 		/** @var \DOMAttr $attribute */
64
-		foreach ( $item->attributes as $attribute ) {
65
-			if ( $this->valueMatcher ) {
64
+		foreach ($item->attributes as $attribute) {
65
+			if ($this->valueMatcher) {
66 66
 				if (
67
-					$this->attributeNameMatcher->matches( $attribute->name )
68
-					&& $this->valueMatcher->matches( $attribute->value )
67
+					$this->attributeNameMatcher->matches($attribute->name)
68
+					&& $this->valueMatcher->matches($attribute->value)
69 69
 				) {
70 70
 					return true;
71 71
 				}
72 72
 			} else {
73
-				if ( $this->attributeNameMatcher->matches( $attribute->name ) ) {
73
+				if ($this->attributeNameMatcher->matches($attribute->name)) {
74 74
 					return true;
75 75
 				}
76 76
 			}
Please login to merge, or discard this patch.
src/ComplexTagMatcher.php 2 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -10,187 +10,187 @@
 block discarded – undo
10 10
 
11 11
 class ComplexTagMatcher extends TagMatcher {
12 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
-	 * @return self
32
-	 */
33
-	public static function tagMatchingOutline( $htmlOutline ) {
34
-		return new self( $htmlOutline );
35
-	}
36
-
37
-	public function __construct( $tagHtmlRepresentation ) {
38
-		parent::__construct();
39
-
40
-		$this->tagHtmlOutline = $tagHtmlRepresentation;
41
-		$this->matcher = $this->createMatcherFromHtml( $tagHtmlRepresentation );
42
-	}
43
-
44
-	public function describeTo( Description $description ) {
45
-		$description->appendText( 'tag matching outline `' )
46
-			->appendText( $this->tagHtmlOutline )
47
-			->appendText( '` ' );
48
-	}
49
-
50
-	/**
51
-	 * @param \DOMElement $item
52
-	 * @param Description $mismatchDescription
53
-	 *
54
-	 * @return bool
55
-	 */
56
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
57
-		$result = $this->matcher->matches( $item );
58
-		if ( !$result ) {
59
-			$mismatchDescription->appendText( 'was `' )
60
-				->appendText( $this->elementToString( $item ) )
61
-				->appendText( '`' );
62
-		}
63
-		return $result;
64
-	}
65
-
66
-	private function createMatcherFromHtml( $htmlOutline ) {
67
-		$document = $this->parseHtml( $htmlOutline );
68
-		$targetTag = $this->getSingleTagFromThe( $document );
69
-
70
-		$this->assertTagDoesNotContainChildren( $targetTag );
71
-
72
-		$attributeMatchers = $this->createAttributeMatchers( $htmlOutline, $targetTag );
73
-		$classMatchers = $this->createClassMatchers( $targetTag );
74
-
75
-		return AllOf::allOf(
76
-			new TagNameMatcher( IsEqual::equalTo( $targetTag->tagName ) ),
77
-			call_user_func_array( [ AllOf::class, 'allOf' ], $attributeMatchers ),
78
-			call_user_func_array( [ AllOf::class, 'allOf' ], $classMatchers )
79
-		);
80
-	}
81
-
82
-	private function isUnknownTagError( \LibXMLError $error ) {
83
-		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
84
-	}
85
-
86
-	private function isBooleanAttribute( $inputHtml, $attributeName ) {
87
-		$quotedName = preg_quote( $attributeName, '/' );
88
-
89
-		$attributeHasValueAssigned = preg_match( "/\b{$quotedName}\s*=/ui", $inputHtml );
90
-		return !$attributeHasValueAssigned;
91
-	}
92
-
93
-	/**
94
-	 * @param $html
95
-	 *
96
-	 * @return \DOMDocument
97
-	 * @throws \InvalidArgumentException
98
-	 */
99
-	private function parseHtml( $html ) {
100
-		$internalErrors = libxml_use_internal_errors( true );
101
-		$document = new \DOMDocument();
102
-
103
-		if ( !@$document->loadHTML( $html ) ) {
104
-			throw new \InvalidArgumentException( "There was some parsing error of `$html`" );
105
-		}
106
-
107
-		$errors = libxml_get_errors();
108
-		libxml_clear_errors();
109
-		libxml_use_internal_errors( $internalErrors );
110
-
111
-		/** @var \LibXMLError $error */
112
-		foreach ( $errors as $error ) {
113
-			if ( $this->isUnknownTagError( $error ) ) {
114
-				continue;
115
-			}
116
-
117
-			throw new \InvalidArgumentException(
118
-				'There was parsing error: ' . trim( $error->message ) . ' on line ' . $error->line
119
-			);
120
-		}
121
-
122
-		return $document;
123
-	}
124
-
125
-	/**
126
-	 * @param \DOMDocument $document
127
-	 *
128
-	 * @return \DOMElement
129
-	 * @throws \InvalidArgumentException
130
-	 */
131
-	private function getSingleTagFromThe( \DOMDocument $document ) {
132
-		$directChildren = iterator_to_array( $document->documentElement->childNodes );
133
-
134
-		$body = array_shift( $directChildren );
135
-		$directChildren = iterator_to_array( $body->childNodes );
136
-
137
-		if ( count( $directChildren ) !== 1 ) {
138
-			throw new InvalidArgumentException( 'Expected exactly 1 tag description, got ' . count( $directChildren ) );
139
-		}
140
-
141
-		return $directChildren[0];
142
-	}
143
-
144
-	private function assertTagDoesNotContainChildren( \DOMElement $targetTag ) {
145
-		if ( $targetTag->childNodes->length > 0 ) {
146
-			throw new InvalidArgumentException( 'Nested elements are not allowed' );
147
-		}
148
-	}
149
-
150
-	/**
151
-	 * @param string $inputHtml
152
-	 * @param $targetTag
153
-	 * @return AttributeMatcher[]
154
-	 */
155
-	private function createAttributeMatchers( $inputHtml, \DOMElement $targetTag ) {
156
-		$attributeMatchers = [];
157
-		/** @var \DOMAttr $attribute */
158
-		foreach ( $targetTag->attributes as $attribute ) {
159
-			if ( $attribute->name === 'class' ) {
160
-				continue;
161
-			}
162
-
163
-			$attributeMatcher = new AttributeMatcher( IsEqual::equalTo( $attribute->name ) );
164
-			if ( !$this->isBooleanAttribute( $inputHtml, $attribute->name ) ) {
165
-				$attributeMatcher = $attributeMatcher->havingValue( IsEqual::equalTo( $attribute->value ) );
166
-			}
167
-
168
-			$attributeMatchers[] = $attributeMatcher;
169
-		}
170
-		return $attributeMatchers;
171
-	}
172
-
173
-	/**
174
-	 * @param \DOMElement $targetTag
175
-	 * @return ClassMatcher[]
176
-	 */
177
-	private function createClassMatchers( $targetTag ) {
178
-		$classMatchers = [];
179
-		$classValue = $targetTag->getAttribute( 'class' );
180
-		foreach ( explode( ' ', $classValue ) as $expectedClass ) {
181
-			if ( $expectedClass === '' ) {
182
-				continue;
183
-			}
184
-			$classMatchers[] = new ClassMatcher( IsEqual::equalTo( $expectedClass ) );
185
-		}
186
-		return $classMatchers;
187
-	}
188
-
189
-	private function elementToString( \DOMElement $element ) {
190
-		$newDocument = new \DOMDocument();
191
-		$cloned = $element->cloneNode( true );
192
-		$newDocument->appendChild( $newDocument->importNode( $cloned, true ) );
193
-		return trim( $newDocument->saveHTML() );
194
-	}
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
+     * @return self
32
+     */
33
+    public static function tagMatchingOutline( $htmlOutline ) {
34
+        return new self( $htmlOutline );
35
+    }
36
+
37
+    public function __construct( $tagHtmlRepresentation ) {
38
+        parent::__construct();
39
+
40
+        $this->tagHtmlOutline = $tagHtmlRepresentation;
41
+        $this->matcher = $this->createMatcherFromHtml( $tagHtmlRepresentation );
42
+    }
43
+
44
+    public function describeTo( Description $description ) {
45
+        $description->appendText( 'tag matching outline `' )
46
+            ->appendText( $this->tagHtmlOutline )
47
+            ->appendText( '` ' );
48
+    }
49
+
50
+    /**
51
+     * @param \DOMElement $item
52
+     * @param Description $mismatchDescription
53
+     *
54
+     * @return bool
55
+     */
56
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
57
+        $result = $this->matcher->matches( $item );
58
+        if ( !$result ) {
59
+            $mismatchDescription->appendText( 'was `' )
60
+                ->appendText( $this->elementToString( $item ) )
61
+                ->appendText( '`' );
62
+        }
63
+        return $result;
64
+    }
65
+
66
+    private function createMatcherFromHtml( $htmlOutline ) {
67
+        $document = $this->parseHtml( $htmlOutline );
68
+        $targetTag = $this->getSingleTagFromThe( $document );
69
+
70
+        $this->assertTagDoesNotContainChildren( $targetTag );
71
+
72
+        $attributeMatchers = $this->createAttributeMatchers( $htmlOutline, $targetTag );
73
+        $classMatchers = $this->createClassMatchers( $targetTag );
74
+
75
+        return AllOf::allOf(
76
+            new TagNameMatcher( IsEqual::equalTo( $targetTag->tagName ) ),
77
+            call_user_func_array( [ AllOf::class, 'allOf' ], $attributeMatchers ),
78
+            call_user_func_array( [ AllOf::class, 'allOf' ], $classMatchers )
79
+        );
80
+    }
81
+
82
+    private function isUnknownTagError( \LibXMLError $error ) {
83
+        return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
84
+    }
85
+
86
+    private function isBooleanAttribute( $inputHtml, $attributeName ) {
87
+        $quotedName = preg_quote( $attributeName, '/' );
88
+
89
+        $attributeHasValueAssigned = preg_match( "/\b{$quotedName}\s*=/ui", $inputHtml );
90
+        return !$attributeHasValueAssigned;
91
+    }
92
+
93
+    /**
94
+     * @param $html
95
+     *
96
+     * @return \DOMDocument
97
+     * @throws \InvalidArgumentException
98
+     */
99
+    private function parseHtml( $html ) {
100
+        $internalErrors = libxml_use_internal_errors( true );
101
+        $document = new \DOMDocument();
102
+
103
+        if ( !@$document->loadHTML( $html ) ) {
104
+            throw new \InvalidArgumentException( "There was some parsing error of `$html`" );
105
+        }
106
+
107
+        $errors = libxml_get_errors();
108
+        libxml_clear_errors();
109
+        libxml_use_internal_errors( $internalErrors );
110
+
111
+        /** @var \LibXMLError $error */
112
+        foreach ( $errors as $error ) {
113
+            if ( $this->isUnknownTagError( $error ) ) {
114
+                continue;
115
+            }
116
+
117
+            throw new \InvalidArgumentException(
118
+                'There was parsing error: ' . trim( $error->message ) . ' on line ' . $error->line
119
+            );
120
+        }
121
+
122
+        return $document;
123
+    }
124
+
125
+    /**
126
+     * @param \DOMDocument $document
127
+     *
128
+     * @return \DOMElement
129
+     * @throws \InvalidArgumentException
130
+     */
131
+    private function getSingleTagFromThe( \DOMDocument $document ) {
132
+        $directChildren = iterator_to_array( $document->documentElement->childNodes );
133
+
134
+        $body = array_shift( $directChildren );
135
+        $directChildren = iterator_to_array( $body->childNodes );
136
+
137
+        if ( count( $directChildren ) !== 1 ) {
138
+            throw new InvalidArgumentException( 'Expected exactly 1 tag description, got ' . count( $directChildren ) );
139
+        }
140
+
141
+        return $directChildren[0];
142
+    }
143
+
144
+    private function assertTagDoesNotContainChildren( \DOMElement $targetTag ) {
145
+        if ( $targetTag->childNodes->length > 0 ) {
146
+            throw new InvalidArgumentException( 'Nested elements are not allowed' );
147
+        }
148
+    }
149
+
150
+    /**
151
+     * @param string $inputHtml
152
+     * @param $targetTag
153
+     * @return AttributeMatcher[]
154
+     */
155
+    private function createAttributeMatchers( $inputHtml, \DOMElement $targetTag ) {
156
+        $attributeMatchers = [];
157
+        /** @var \DOMAttr $attribute */
158
+        foreach ( $targetTag->attributes as $attribute ) {
159
+            if ( $attribute->name === 'class' ) {
160
+                continue;
161
+            }
162
+
163
+            $attributeMatcher = new AttributeMatcher( IsEqual::equalTo( $attribute->name ) );
164
+            if ( !$this->isBooleanAttribute( $inputHtml, $attribute->name ) ) {
165
+                $attributeMatcher = $attributeMatcher->havingValue( IsEqual::equalTo( $attribute->value ) );
166
+            }
167
+
168
+            $attributeMatchers[] = $attributeMatcher;
169
+        }
170
+        return $attributeMatchers;
171
+    }
172
+
173
+    /**
174
+     * @param \DOMElement $targetTag
175
+     * @return ClassMatcher[]
176
+     */
177
+    private function createClassMatchers( $targetTag ) {
178
+        $classMatchers = [];
179
+        $classValue = $targetTag->getAttribute( 'class' );
180
+        foreach ( explode( ' ', $classValue ) as $expectedClass ) {
181
+            if ( $expectedClass === '' ) {
182
+                continue;
183
+            }
184
+            $classMatchers[] = new ClassMatcher( IsEqual::equalTo( $expectedClass ) );
185
+        }
186
+        return $classMatchers;
187
+    }
188
+
189
+    private function elementToString( \DOMElement $element ) {
190
+        $newDocument = new \DOMDocument();
191
+        $cloned = $element->cloneNode( true );
192
+        $newDocument->appendChild( $newDocument->importNode( $cloned, true ) );
193
+        return trim( $newDocument->saveHTML() );
194
+    }
195 195
 
196 196
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@  discard block
 block discarded – undo
30 30
 	 * @param string $htmlOutline
31 31
 	 * @return self
32 32
 	 */
33
-	public static function tagMatchingOutline( $htmlOutline ) {
34
-		return new self( $htmlOutline );
33
+	public static function tagMatchingOutline($htmlOutline) {
34
+		return new self($htmlOutline);
35 35
 	}
36 36
 
37
-	public function __construct( $tagHtmlRepresentation ) {
37
+	public function __construct($tagHtmlRepresentation) {
38 38
 		parent::__construct();
39 39
 
40 40
 		$this->tagHtmlOutline = $tagHtmlRepresentation;
41
-		$this->matcher = $this->createMatcherFromHtml( $tagHtmlRepresentation );
41
+		$this->matcher = $this->createMatcherFromHtml($tagHtmlRepresentation);
42 42
 	}
43 43
 
44
-	public function describeTo( Description $description ) {
45
-		$description->appendText( 'tag matching outline `' )
46
-			->appendText( $this->tagHtmlOutline )
47
-			->appendText( '` ' );
44
+	public function describeTo(Description $description) {
45
+		$description->appendText('tag matching outline `')
46
+			->appendText($this->tagHtmlOutline)
47
+			->appendText('` ');
48 48
 	}
49 49
 
50 50
 	/**
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return bool
55 55
 	 */
56
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
57
-		$result = $this->matcher->matches( $item );
58
-		if ( !$result ) {
59
-			$mismatchDescription->appendText( 'was `' )
60
-				->appendText( $this->elementToString( $item ) )
61
-				->appendText( '`' );
56
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
57
+		$result = $this->matcher->matches($item);
58
+		if (!$result) {
59
+			$mismatchDescription->appendText('was `')
60
+				->appendText($this->elementToString($item))
61
+				->appendText('`');
62 62
 		}
63 63
 		return $result;
64 64
 	}
65 65
 
66
-	private function createMatcherFromHtml( $htmlOutline ) {
67
-		$document = $this->parseHtml( $htmlOutline );
68
-		$targetTag = $this->getSingleTagFromThe( $document );
66
+	private function createMatcherFromHtml($htmlOutline) {
67
+		$document = $this->parseHtml($htmlOutline);
68
+		$targetTag = $this->getSingleTagFromThe($document);
69 69
 
70
-		$this->assertTagDoesNotContainChildren( $targetTag );
70
+		$this->assertTagDoesNotContainChildren($targetTag);
71 71
 
72
-		$attributeMatchers = $this->createAttributeMatchers( $htmlOutline, $targetTag );
73
-		$classMatchers = $this->createClassMatchers( $targetTag );
72
+		$attributeMatchers = $this->createAttributeMatchers($htmlOutline, $targetTag);
73
+		$classMatchers = $this->createClassMatchers($targetTag);
74 74
 
75 75
 		return AllOf::allOf(
76
-			new TagNameMatcher( IsEqual::equalTo( $targetTag->tagName ) ),
77
-			call_user_func_array( [ AllOf::class, 'allOf' ], $attributeMatchers ),
78
-			call_user_func_array( [ AllOf::class, 'allOf' ], $classMatchers )
76
+			new TagNameMatcher(IsEqual::equalTo($targetTag->tagName)),
77
+			call_user_func_array([AllOf::class, 'allOf'], $attributeMatchers),
78
+			call_user_func_array([AllOf::class, 'allOf'], $classMatchers)
79 79
 		);
80 80
 	}
81 81
 
82
-	private function isUnknownTagError( \LibXMLError $error ) {
82
+	private function isUnknownTagError(\LibXMLError $error) {
83 83
 		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
84 84
 	}
85 85
 
86
-	private function isBooleanAttribute( $inputHtml, $attributeName ) {
87
-		$quotedName = preg_quote( $attributeName, '/' );
86
+	private function isBooleanAttribute($inputHtml, $attributeName) {
87
+		$quotedName = preg_quote($attributeName, '/');
88 88
 
89
-		$attributeHasValueAssigned = preg_match( "/\b{$quotedName}\s*=/ui", $inputHtml );
89
+		$attributeHasValueAssigned = preg_match("/\b{$quotedName}\s*=/ui", $inputHtml);
90 90
 		return !$attributeHasValueAssigned;
91 91
 	}
92 92
 
@@ -96,26 +96,26 @@  discard block
 block discarded – undo
96 96
 	 * @return \DOMDocument
97 97
 	 * @throws \InvalidArgumentException
98 98
 	 */
99
-	private function parseHtml( $html ) {
100
-		$internalErrors = libxml_use_internal_errors( true );
99
+	private function parseHtml($html) {
100
+		$internalErrors = libxml_use_internal_errors(true);
101 101
 		$document = new \DOMDocument();
102 102
 
103
-		if ( !@$document->loadHTML( $html ) ) {
104
-			throw new \InvalidArgumentException( "There was some parsing error of `$html`" );
103
+		if (!@$document->loadHTML($html)) {
104
+			throw new \InvalidArgumentException("There was some parsing error of `$html`");
105 105
 		}
106 106
 
107 107
 		$errors = libxml_get_errors();
108 108
 		libxml_clear_errors();
109
-		libxml_use_internal_errors( $internalErrors );
109
+		libxml_use_internal_errors($internalErrors);
110 110
 
111 111
 		/** @var \LibXMLError $error */
112
-		foreach ( $errors as $error ) {
113
-			if ( $this->isUnknownTagError( $error ) ) {
112
+		foreach ($errors as $error) {
113
+			if ($this->isUnknownTagError($error)) {
114 114
 				continue;
115 115
 			}
116 116
 
117 117
 			throw new \InvalidArgumentException(
118
-				'There was parsing error: ' . trim( $error->message ) . ' on line ' . $error->line
118
+				'There was parsing error: ' . trim($error->message) . ' on line ' . $error->line
119 119
 			);
120 120
 		}
121 121
 
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 	 * @return \DOMElement
129 129
 	 * @throws \InvalidArgumentException
130 130
 	 */
131
-	private function getSingleTagFromThe( \DOMDocument $document ) {
132
-		$directChildren = iterator_to_array( $document->documentElement->childNodes );
131
+	private function getSingleTagFromThe(\DOMDocument $document) {
132
+		$directChildren = iterator_to_array($document->documentElement->childNodes);
133 133
 
134
-		$body = array_shift( $directChildren );
135
-		$directChildren = iterator_to_array( $body->childNodes );
134
+		$body = array_shift($directChildren);
135
+		$directChildren = iterator_to_array($body->childNodes);
136 136
 
137
-		if ( count( $directChildren ) !== 1 ) {
138
-			throw new InvalidArgumentException( 'Expected exactly 1 tag description, got ' . count( $directChildren ) );
137
+		if (count($directChildren) !== 1) {
138
+			throw new InvalidArgumentException('Expected exactly 1 tag description, got ' . count($directChildren));
139 139
 		}
140 140
 
141 141
 		return $directChildren[0];
142 142
 	}
143 143
 
144
-	private function assertTagDoesNotContainChildren( \DOMElement $targetTag ) {
145
-		if ( $targetTag->childNodes->length > 0 ) {
146
-			throw new InvalidArgumentException( 'Nested elements are not allowed' );
144
+	private function assertTagDoesNotContainChildren(\DOMElement $targetTag) {
145
+		if ($targetTag->childNodes->length > 0) {
146
+			throw new InvalidArgumentException('Nested elements are not allowed');
147 147
 		}
148 148
 	}
149 149
 
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
 	 * @param $targetTag
153 153
 	 * @return AttributeMatcher[]
154 154
 	 */
155
-	private function createAttributeMatchers( $inputHtml, \DOMElement $targetTag ) {
155
+	private function createAttributeMatchers($inputHtml, \DOMElement $targetTag) {
156 156
 		$attributeMatchers = [];
157 157
 		/** @var \DOMAttr $attribute */
158
-		foreach ( $targetTag->attributes as $attribute ) {
159
-			if ( $attribute->name === 'class' ) {
158
+		foreach ($targetTag->attributes as $attribute) {
159
+			if ($attribute->name === 'class') {
160 160
 				continue;
161 161
 			}
162 162
 
163
-			$attributeMatcher = new AttributeMatcher( IsEqual::equalTo( $attribute->name ) );
164
-			if ( !$this->isBooleanAttribute( $inputHtml, $attribute->name ) ) {
165
-				$attributeMatcher = $attributeMatcher->havingValue( IsEqual::equalTo( $attribute->value ) );
163
+			$attributeMatcher = new AttributeMatcher(IsEqual::equalTo($attribute->name));
164
+			if (!$this->isBooleanAttribute($inputHtml, $attribute->name)) {
165
+				$attributeMatcher = $attributeMatcher->havingValue(IsEqual::equalTo($attribute->value));
166 166
 			}
167 167
 
168 168
 			$attributeMatchers[] = $attributeMatcher;
@@ -174,23 +174,23 @@  discard block
 block discarded – undo
174 174
 	 * @param \DOMElement $targetTag
175 175
 	 * @return ClassMatcher[]
176 176
 	 */
177
-	private function createClassMatchers( $targetTag ) {
177
+	private function createClassMatchers($targetTag) {
178 178
 		$classMatchers = [];
179
-		$classValue = $targetTag->getAttribute( 'class' );
180
-		foreach ( explode( ' ', $classValue ) as $expectedClass ) {
181
-			if ( $expectedClass === '' ) {
179
+		$classValue = $targetTag->getAttribute('class');
180
+		foreach (explode(' ', $classValue) as $expectedClass) {
181
+			if ($expectedClass === '') {
182 182
 				continue;
183 183
 			}
184
-			$classMatchers[] = new ClassMatcher( IsEqual::equalTo( $expectedClass ) );
184
+			$classMatchers[] = new ClassMatcher(IsEqual::equalTo($expectedClass));
185 185
 		}
186 186
 		return $classMatchers;
187 187
 	}
188 188
 
189
-	private function elementToString( \DOMElement $element ) {
189
+	private function elementToString(\DOMElement $element) {
190 190
 		$newDocument = new \DOMDocument();
191
-		$cloned = $element->cloneNode( true );
192
-		$newDocument->appendChild( $newDocument->importNode( $cloned, true ) );
193
-		return trim( $newDocument->saveHTML() );
191
+		$cloned = $element->cloneNode(true);
192
+		$newDocument->appendChild($newDocument->importNode($cloned, true));
193
+		return trim($newDocument->saveHTML());
194 194
 	}
195 195
 
196 196
 }
Please login to merge, or discard this patch.
src/TagNameMatcher.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class TagNameMatcher extends TagMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $tagNameMatcher;
15
-
16
-	public static function withTagName( $tagName ) {
17
-		return new static( Util::wrapValueWithIsEqual( $tagName ) );
18
-	}
19
-
20
-	public function __construct( Matcher $tagNameMatcher ) {
21
-		parent::__construct();
22
-		$this->tagNameMatcher = $tagNameMatcher;
23
-	}
24
-
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'with tag name ' )
27
-			->appendDescriptionOf( $this->tagNameMatcher );
28
-	}
29
-
30
-	/**
31
-	 * @param \DOMElement $item
32
-	 * @param Description $mismatchDescription
33
-	 *
34
-	 * @return bool
35
-	 */
36
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
37
-		$mismatchDescription->appendText( 'tag name ' );
38
-		$this->tagNameMatcher->describeMismatch( $item->tagName, $mismatchDescription );
39
-		return $this->tagNameMatcher->matches( $item->tagName );
40
-	}
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $tagNameMatcher;
15
+
16
+    public static function withTagName( $tagName ) {
17
+        return new static( Util::wrapValueWithIsEqual( $tagName ) );
18
+    }
19
+
20
+    public function __construct( Matcher $tagNameMatcher ) {
21
+        parent::__construct();
22
+        $this->tagNameMatcher = $tagNameMatcher;
23
+    }
24
+
25
+    public function describeTo( Description $description ) {
26
+        $description->appendText( 'with tag name ' )
27
+            ->appendDescriptionOf( $this->tagNameMatcher );
28
+    }
29
+
30
+    /**
31
+     * @param \DOMElement $item
32
+     * @param Description $mismatchDescription
33
+     *
34
+     * @return bool
35
+     */
36
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
37
+        $mismatchDescription->appendText( 'tag name ' );
38
+        $this->tagNameMatcher->describeMismatch( $item->tagName, $mismatchDescription );
39
+        return $this->tagNameMatcher->matches( $item->tagName );
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	private $tagNameMatcher;
15 15
 
16
-	public static function withTagName( $tagName ) {
17
-		return new static( Util::wrapValueWithIsEqual( $tagName ) );
16
+	public static function withTagName($tagName) {
17
+		return new static(Util::wrapValueWithIsEqual($tagName));
18 18
 	}
19 19
 
20
-	public function __construct( Matcher $tagNameMatcher ) {
20
+	public function __construct(Matcher $tagNameMatcher) {
21 21
 		parent::__construct();
22 22
 		$this->tagNameMatcher = $tagNameMatcher;
23 23
 	}
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'with tag name ' )
27
-			->appendDescriptionOf( $this->tagNameMatcher );
25
+	public function describeTo(Description $description) {
26
+		$description->appendText('with tag name ')
27
+			->appendDescriptionOf($this->tagNameMatcher);
28 28
 	}
29 29
 
30 30
 	/**
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return bool
35 35
 	 */
36
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
37
-		$mismatchDescription->appendText( 'tag name ' );
38
-		$this->tagNameMatcher->describeMismatch( $item->tagName, $mismatchDescription );
39
-		return $this->tagNameMatcher->matches( $item->tagName );
36
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
37
+		$mismatchDescription->appendText('tag name ');
38
+		$this->tagNameMatcher->describeMismatch($item->tagName, $mismatchDescription);
39
+		return $this->tagNameMatcher->matches($item->tagName);
40 40
 	}
41 41
 
42 42
 }
Please login to merge, or discard this patch.
src/functions.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -3,87 +3,87 @@
 block discarded – undo
3 3
 use Hamcrest\Matcher;
4 4
 
5 5
 if ( !function_exists( 'htmlPiece' ) ) {
6
-	/**
7
-	 * @param mixed $elementMatcher
8
-	 *
9
-	 * @return \WMDE\HamcrestHtml\HtmlMatcher
10
-	 */
11
-	function htmlPiece( Matcher $elementMatcher = null ) {
12
-		return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece( $elementMatcher );
13
-	}
6
+    /**
7
+     * @param mixed $elementMatcher
8
+     *
9
+     * @return \WMDE\HamcrestHtml\HtmlMatcher
10
+     */
11
+    function htmlPiece( Matcher $elementMatcher = null ) {
12
+        return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece( $elementMatcher );
13
+    }
14 14
 }
15 15
 
16 16
 if ( !function_exists( 'havingRootElement' ) ) {
17
-	function havingRootElement( Matcher $matcher = null ) {
18
-		return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement( $matcher );
19
-	}
17
+    function havingRootElement( Matcher $matcher = null ) {
18
+        return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement( $matcher );
19
+    }
20 20
 }
21 21
 
22 22
 if ( !function_exists( 'havingDirectChild' ) ) {
23
-	function havingDirectChild( Matcher $elementMatcher = null ) {
24
-		return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild( $elementMatcher );
25
-	}
23
+    function havingDirectChild( Matcher $elementMatcher = null ) {
24
+        return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild( $elementMatcher );
25
+    }
26 26
 }
27 27
 
28 28
 if ( !function_exists( 'havingChild' ) ) {
29
-	function havingChild( Matcher $elementMatcher = null ) {
30
-		return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild( $elementMatcher );
31
-	}
29
+    function havingChild( Matcher $elementMatcher = null ) {
30
+        return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild( $elementMatcher );
31
+    }
32 32
 }
33 33
 
34 34
 if ( !function_exists( 'withTagName' ) ) {
35
-	/**
36
-	 * @param Matcher|string $tagName
37
-	 *
38
-	 * @return \WMDE\HamcrestHtml\TagNameMatcher
39
-	 */
40
-	function withTagName( $tagName ) {
41
-		return \WMDE\HamcrestHtml\TagNameMatcher::withTagName( $tagName );
42
-	}
35
+    /**
36
+     * @param Matcher|string $tagName
37
+     *
38
+     * @return \WMDE\HamcrestHtml\TagNameMatcher
39
+     */
40
+    function withTagName( $tagName ) {
41
+        return \WMDE\HamcrestHtml\TagNameMatcher::withTagName( $tagName );
42
+    }
43 43
 }
44 44
 
45 45
 if ( !function_exists( 'withAttribute' ) ) {
46
-	/**
47
-	 * @param Matcher|string $attributeName
48
-	 *
49
-	 * @return \WMDE\HamcrestHtml\AttributeMatcher
50
-	 */
51
-	function withAttribute( $attributeName ) {
52
-		return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute( $attributeName );
53
-	}
46
+    /**
47
+     * @param Matcher|string $attributeName
48
+     *
49
+     * @return \WMDE\HamcrestHtml\AttributeMatcher
50
+     */
51
+    function withAttribute( $attributeName ) {
52
+        return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute( $attributeName );
53
+    }
54 54
 }
55 55
 
56 56
 if ( !function_exists( 'withClass' ) ) {
57
-	/**
58
-	 * @param Matcher|string $class
59
-	 *
60
-	 * @return \WMDE\HamcrestHtml\ClassMatcher
61
-	 */
62
-	function withClass( $class ) {
63
-		// TODO don't allow to call with empty string
57
+    /**
58
+     * @param Matcher|string $class
59
+     *
60
+     * @return \WMDE\HamcrestHtml\ClassMatcher
61
+     */
62
+    function withClass( $class ) {
63
+        // TODO don't allow to call with empty string
64 64
 
65
-		return \WMDE\HamcrestHtml\ClassMatcher::withClass( $class );
66
-	}
65
+        return \WMDE\HamcrestHtml\ClassMatcher::withClass( $class );
66
+    }
67 67
 }
68 68
 
69 69
 if ( !function_exists( 'havingTextContents' ) ) {
70
-	/**
71
-	 * @param Matcher|string $text
72
-	 *
73
-	 * @return \WMDE\HamcrestHtml\TextContentsMatcher
74
-	 */
75
-	function havingTextContents( $text ) {
76
-		return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents( $text );
77
-	}
70
+    /**
71
+     * @param Matcher|string $text
72
+     *
73
+     * @return \WMDE\HamcrestHtml\TextContentsMatcher
74
+     */
75
+    function havingTextContents( $text ) {
76
+        return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents( $text );
77
+    }
78 78
 }
79 79
 
80 80
 if ( !function_exists( 'tagMatchingOutline' ) ) {
81
-	/**
82
-	 * @param string $htmlOutline
83
-	 *
84
-	 * @return \WMDE\HamcrestHtml\ComplexTagMatcher
85
-	 */
86
-	function tagMatchingOutline( $htmlOutline ) {
87
-		return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
88
-	}
81
+    /**
82
+     * @param string $htmlOutline
83
+     *
84
+     * @return \WMDE\HamcrestHtml\ComplexTagMatcher
85
+     */
86
+    function tagMatchingOutline( $htmlOutline ) {
87
+        return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -2,88 +2,88 @@
 block discarded – undo
2 2
 
3 3
 use Hamcrest\Matcher;
4 4
 
5
-if ( !function_exists( 'htmlPiece' ) ) {
5
+if (!function_exists('htmlPiece')) {
6 6
 	/**
7 7
 	 * @param mixed $elementMatcher
8 8
 	 *
9 9
 	 * @return \WMDE\HamcrestHtml\HtmlMatcher
10 10
 	 */
11
-	function htmlPiece( Matcher $elementMatcher = null ) {
12
-		return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece( $elementMatcher );
11
+	function htmlPiece(Matcher $elementMatcher = null) {
12
+		return \WMDE\HamcrestHtml\HtmlMatcher::htmlPiece($elementMatcher);
13 13
 	}
14 14
 }
15 15
 
16
-if ( !function_exists( 'havingRootElement' ) ) {
17
-	function havingRootElement( Matcher $matcher = null ) {
18
-		return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement( $matcher );
16
+if (!function_exists('havingRootElement')) {
17
+	function havingRootElement(Matcher $matcher = null) {
18
+		return \WMDE\HamcrestHtml\RootElementMatcher::havingRootElement($matcher);
19 19
 	}
20 20
 }
21 21
 
22
-if ( !function_exists( 'havingDirectChild' ) ) {
23
-	function havingDirectChild( Matcher $elementMatcher = null ) {
24
-		return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild( $elementMatcher );
22
+if (!function_exists('havingDirectChild')) {
23
+	function havingDirectChild(Matcher $elementMatcher = null) {
24
+		return \WMDE\HamcrestHtml\DirectChildElementMatcher::havingDirectChild($elementMatcher);
25 25
 	}
26 26
 }
27 27
 
28
-if ( !function_exists( 'havingChild' ) ) {
29
-	function havingChild( Matcher $elementMatcher = null ) {
30
-		return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild( $elementMatcher );
28
+if (!function_exists('havingChild')) {
29
+	function havingChild(Matcher $elementMatcher = null) {
30
+		return \WMDE\HamcrestHtml\ChildElementMatcher::havingChild($elementMatcher);
31 31
 	}
32 32
 }
33 33
 
34
-if ( !function_exists( 'withTagName' ) ) {
34
+if (!function_exists('withTagName')) {
35 35
 	/**
36 36
 	 * @param Matcher|string $tagName
37 37
 	 *
38 38
 	 * @return \WMDE\HamcrestHtml\TagNameMatcher
39 39
 	 */
40
-	function withTagName( $tagName ) {
41
-		return \WMDE\HamcrestHtml\TagNameMatcher::withTagName( $tagName );
40
+	function withTagName($tagName) {
41
+		return \WMDE\HamcrestHtml\TagNameMatcher::withTagName($tagName);
42 42
 	}
43 43
 }
44 44
 
45
-if ( !function_exists( 'withAttribute' ) ) {
45
+if (!function_exists('withAttribute')) {
46 46
 	/**
47 47
 	 * @param Matcher|string $attributeName
48 48
 	 *
49 49
 	 * @return \WMDE\HamcrestHtml\AttributeMatcher
50 50
 	 */
51
-	function withAttribute( $attributeName ) {
52
-		return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute( $attributeName );
51
+	function withAttribute($attributeName) {
52
+		return \WMDE\HamcrestHtml\AttributeMatcher::withAttribute($attributeName);
53 53
 	}
54 54
 }
55 55
 
56
-if ( !function_exists( 'withClass' ) ) {
56
+if (!function_exists('withClass')) {
57 57
 	/**
58 58
 	 * @param Matcher|string $class
59 59
 	 *
60 60
 	 * @return \WMDE\HamcrestHtml\ClassMatcher
61 61
 	 */
62
-	function withClass( $class ) {
62
+	function withClass($class) {
63 63
 		// TODO don't allow to call with empty string
64 64
 
65
-		return \WMDE\HamcrestHtml\ClassMatcher::withClass( $class );
65
+		return \WMDE\HamcrestHtml\ClassMatcher::withClass($class);
66 66
 	}
67 67
 }
68 68
 
69
-if ( !function_exists( 'havingTextContents' ) ) {
69
+if (!function_exists('havingTextContents')) {
70 70
 	/**
71 71
 	 * @param Matcher|string $text
72 72
 	 *
73 73
 	 * @return \WMDE\HamcrestHtml\TextContentsMatcher
74 74
 	 */
75
-	function havingTextContents( $text ) {
76
-		return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents( $text );
75
+	function havingTextContents($text) {
76
+		return \WMDE\HamcrestHtml\TextContentsMatcher::havingTextContents($text);
77 77
 	}
78 78
 }
79 79
 
80
-if ( !function_exists( 'tagMatchingOutline' ) ) {
80
+if (!function_exists('tagMatchingOutline')) {
81 81
 	/**
82 82
 	 * @param string $htmlOutline
83 83
 	 *
84 84
 	 * @return \WMDE\HamcrestHtml\ComplexTagMatcher
85 85
 	 */
86
-	function tagMatchingOutline( $htmlOutline ) {
87
-		return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
86
+	function tagMatchingOutline($htmlOutline) {
87
+		return \WMDE\HamcrestHtml\ComplexTagMatcher::tagMatchingOutline($htmlOutline);
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
src/RootElementMatcher.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -8,62 +8,62 @@
 block discarded – undo
8 8
 
9 9
 class RootElementMatcher extends TypeSafeDiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $tagMatcher;
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $tagMatcher;
15 15
 
16
-	/**
17
-	 * @param Matcher|null $tagMatcher
18
-	 *
19
-	 * @return static
20
-	 */
21
-	public static function havingRootElement( Matcher $tagMatcher = null ) {
22
-		return new static( $tagMatcher );
23
-	}
16
+    /**
17
+     * @param Matcher|null $tagMatcher
18
+     *
19
+     * @return static
20
+     */
21
+    public static function havingRootElement( Matcher $tagMatcher = null ) {
22
+        return new static( $tagMatcher );
23
+    }
24 24
 
25
-	public function __construct( Matcher $tagMatcher = null ) {
26
-		parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
27
-		$this->tagMatcher = $tagMatcher;
28
-	}
25
+    public function __construct( Matcher $tagMatcher = null ) {
26
+        parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
27
+        $this->tagMatcher = $tagMatcher;
28
+    }
29 29
 
30
-	public function describeTo( Description $description ) {
31
-		$description->appendText( 'having root element ' );
32
-		if ( $this->tagMatcher ) {
33
-			$description->appendDescriptionOf( $this->tagMatcher );
34
-		}
35
-	}
30
+    public function describeTo( Description $description ) {
31
+        $description->appendText( 'having root element ' );
32
+        if ( $this->tagMatcher ) {
33
+            $description->appendDescriptionOf( $this->tagMatcher );
34
+        }
35
+    }
36 36
 
37
-	/**
38
-	 * @param \DOMDocument $item
39
-	 * @param Description $mismatchDescription
40
-	 *
41
-	 * @return bool
42
-	 */
43
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
-		$DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
37
+    /**
38
+     * @param \DOMDocument $item
39
+     * @param Description $mismatchDescription
40
+     *
41
+     * @return bool
42
+     */
43
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
+        $DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
45 45
 
46
-		$body = array_shift( $DOMNodeList );
47
-		$DOMNodeList = iterator_to_array( $body->childNodes );
48
-		if ( count( $DOMNodeList ) > 1 ) {
49
-			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
51
-			return false;
52
-		}
46
+        $body = array_shift( $DOMNodeList );
47
+        $DOMNodeList = iterator_to_array( $body->childNodes );
48
+        if ( count( $DOMNodeList ) > 1 ) {
49
+            // TODO Test this description
50
+            $mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
51
+            return false;
52
+        }
53 53
 
54
-		$target = array_shift( $DOMNodeList );
55
-		if ( !$target ) {
56
-			// TODO Reproduce?
57
-			$mismatchDescription->appendText( 'having no root elements ' );
58
-			return false;
59
-		}
60
-		if ( $this->tagMatcher ) {
61
-			$mismatchDescription->appendText( 'root element ' );
62
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
-			return $this->tagMatcher->matches( $target );
64
-		}
54
+        $target = array_shift( $DOMNodeList );
55
+        if ( !$target ) {
56
+            // TODO Reproduce?
57
+            $mismatchDescription->appendText( 'having no root elements ' );
58
+            return false;
59
+        }
60
+        if ( $this->tagMatcher ) {
61
+            $mismatchDescription->appendText( 'root element ' );
62
+            $this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
+            return $this->tagMatcher->matches( $target );
64
+        }
65 65
 
66
-		return (bool)$target;
67
-	}
66
+        return (bool)$target;
67
+    }
68 68
 
69 69
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return static
20 20
 	 */
21
-	public static function havingRootElement( Matcher $tagMatcher = null ) {
22
-		return new static( $tagMatcher );
21
+	public static function havingRootElement(Matcher $tagMatcher = null) {
22
+		return new static($tagMatcher);
23 23
 	}
24 24
 
25
-	public function __construct( Matcher $tagMatcher = null ) {
26
-		parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
25
+	public function __construct(Matcher $tagMatcher = null) {
26
+		parent::__construct(self::TYPE_OBJECT, \DOMDocument::class);
27 27
 		$this->tagMatcher = $tagMatcher;
28 28
 	}
29 29
 
30
-	public function describeTo( Description $description ) {
31
-		$description->appendText( 'having root element ' );
32
-		if ( $this->tagMatcher ) {
33
-			$description->appendDescriptionOf( $this->tagMatcher );
30
+	public function describeTo(Description $description) {
31
+		$description->appendText('having root element ');
32
+		if ($this->tagMatcher) {
33
+			$description->appendDescriptionOf($this->tagMatcher);
34 34
 		}
35 35
 	}
36 36
 
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return bool
42 42
 	 */
43
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
-		$DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
43
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
44
+		$DOMNodeList = iterator_to_array($item->documentElement->childNodes);
45 45
 
46
-		$body = array_shift( $DOMNodeList );
47
-		$DOMNodeList = iterator_to_array( $body->childNodes );
48
-		if ( count( $DOMNodeList ) > 1 ) {
46
+		$body = array_shift($DOMNodeList);
47
+		$DOMNodeList = iterator_to_array($body->childNodes);
48
+		if (count($DOMNodeList) > 1) {
49 49
 			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
50
+			$mismatchDescription->appendText('having ' . count($DOMNodeList) . ' root elements ');
51 51
 			return false;
52 52
 		}
53 53
 
54
-		$target = array_shift( $DOMNodeList );
55
-		if ( !$target ) {
54
+		$target = array_shift($DOMNodeList);
55
+		if (!$target) {
56 56
 			// TODO Reproduce?
57
-			$mismatchDescription->appendText( 'having no root elements ' );
57
+			$mismatchDescription->appendText('having no root elements ');
58 58
 			return false;
59 59
 		}
60
-		if ( $this->tagMatcher ) {
61
-			$mismatchDescription->appendText( 'root element ' );
62
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
-			return $this->tagMatcher->matches( $target );
60
+		if ($this->tagMatcher) {
61
+			$mismatchDescription->appendText('root element ');
62
+			$this->tagMatcher->describeMismatch($target, $mismatchDescription);
63
+			return $this->tagMatcher->matches($target);
64 64
 		}
65 65
 
66 66
 		return (bool)$target;
Please login to merge, or discard this patch.