Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 12 | class XmlValidXsdRule extends StandardRule |
||
| 13 | { |
||
| 14 | private $xsdFiles; |
||
| 15 | |||
| 16 | protected $contentTypes = array('text/xml', 'application/xml'); |
||
| 17 | |||
| 18 | public function init($xsdFiles) |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param ResponseInterface $response |
||
| 25 | * @throws ValidationFailedException |
||
| 26 | */ |
||
| 27 | protected function doValidation(ResponseInterface $response) |
||
| 53 | } |
||
| 54 |
If you suppress an error, we recommend checking for the error condition explicitly: