@@ -45,32 +45,31 @@ public function setValidatorUri(string $validatorUri): self
4545 return $ this ;
4646 }
4747
48-
4948 /**
50- * @param string $uri
5149 * @param resource $context
50+ *
5251 * @throws Exception
53- * @return string
5452 */
5553 protected function sendRequest (string $ uri , $ context = null ): string
5654 {
5755 $ data = \file_get_contents ($ uri , null , $ context );
58- if ($ data === false ) {
56+ if (false === $ data ) {
5957 throw new Exception ('Error send request ' );
6058 }
6159
6260 return $ data ;
6361 }
64-
62+
6563 /**
66- * Validates a given URI
64+ * Validates a given URI.
6765 *
6866 * Executes the validator using the current parameters and returns a Response
6967 * object on success.
7068 *
7169 * @param string $uri The address to the page to validate ex: http://example.com/
7270 *
7371 * @throws Exception
72+ *
7473 * @return Response object HTMLValidator\Response
7574 */
7675 public function validateUri (string $ uri ): Response
@@ -84,47 +83,49 @@ public function validateUri(string $uri): Response
8483 'http ' => [
8584 'method ' => 'GET ' ,
8685 'header ' => 'User-Agent: HTMLValidator ' ,
87- ]
86+ ],
8887 ]);
8988
90- $ data = $ this ->sendRequest ($ this ->validatorUri . '? ' . $ query , $ context );
89+ $ data = $ this ->sendRequest ($ this ->validatorUri . '? ' . $ query , $ context );
9190
9291 return $ this ->parseSOAP12Response ($ data );
9392 }
94-
93+
9594 /**
96- * Validates the local file
95+ * Validates the local file.
9796 *
9897 * Requests validation on the local file, from an instance of the W3C validator.
9998 *
100- * @param string $file file to be validated.
99+ * @param string $file file to be validated
101100 *
102101 * @throws Exception
102+ *
103103 * @return Response object HTMLValidator\Response
104104 */
105105 public function validateFile (string $ file ): Response
106106 {
107- if (\file_exists ($ file ) !== true ) {
107+ if (true !== \file_exists ($ file )) {
108108 throw new Exception ('File not found ' );
109109 }
110- if (\is_readable ($ file ) !== true ) {
110+ if (true !== \is_readable ($ file )) {
111111 throw new Exception ('File not readable ' );
112112 }
113113
114114 $ data = \file_get_contents ($ file );
115- if ($ data === false ) {
115+ if (false === $ data ) {
116116 throw new Exception ('Failed get file ' );
117117 }
118118
119119 return $ this ->validateFragment ($ data );
120120 }
121-
121+
122122 /**
123- * Validate an html string
123+ * Validate an html string.
124124 *
125125 * @param string $html full html document fragment
126126 *
127127 * @throws Exception
128+ *
128129 * @return Response object HTMLValidator\Response
129130 */
130131 public function validateFragment (string $ html ): Response
@@ -139,30 +140,30 @@ public function validateFragment(string $html): Response
139140 'method ' => 'POST ' ,
140141 'header ' => "Content-Type: application/x-www-form-urlencoded \r\nUser-Agent: HTMLValidator " ,
141142 'content ' => $ query ,
142- ]
143+ ],
143144 ]);
144145
145146 $ data = $ this ->sendRequest ($ this ->validatorUri , $ context );
146147
147148 return $ this ->parseSOAP12Response ($ data );
148149 }
149-
150+
150151 /**
151- * Parse an XML response from the validator
152+ * Parse an XML response from the validator.
152153 *
153154 * This function parses a SOAP 1.2 response xml string from the validator.
154155 *
155- * @param string $xml The raw soap12 XML response from the validator.
156+ * @param string $xml the raw soap12 XML response from the validator
156157 *
157158 * @throws Exception
158- * @return Response object HTMLValidator\Response
159159 *
160+ * @return Response object HTMLValidator\Response
160161 */
161162 protected function parseSOAP12Response (string $ xml ): Response
162163 {
163164 $ doc = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
164165
165- if ($ doc ->loadXML ($ xml ) === false ) {
166+ if (false === $ doc ->loadXML ($ xml )) {
166167 throw new Exception ('Failed load xml ' );
167168 }
168169
@@ -172,13 +173,13 @@ protected function parseSOAP12Response(string $xml): Response
172173 foreach (['uri ' , 'checkedby ' , 'doctype ' , 'charset ' ] as $ var ) {
173174 $ element = $ doc ->getElementsByTagName ($ var );
174175 if ($ element ->length ) {
175- $ response ->{'set ' . \ucfirst ($ var )}($ element ->item (0 )->nodeValue );
176+ $ response ->{'set ' . \ucfirst ($ var )}($ element ->item (0 )->nodeValue );
176177 }
177178 }
178179
179180 // Handle the bool element validity
180181 $ element = $ doc ->getElementsByTagName ('validity ' );
181- if ($ element ->length && $ element ->item (0 )->nodeValue === ' true ' ) {
182+ if ($ element ->length && ' true ' === $ element ->item (0 )->nodeValue ) {
182183 $ response ->setValidity (true );
183184 } else {
184185 $ response ->setValidity (false );
0 commit comments