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 MasterListener implements TestListener, MasterListenerInterface |
||
|
|
|||
| 13 | { |
||
| 14 | |||
| 15 | protected $replay = []; |
||
| 16 | protected $listeners = []; |
||
| 17 | protected $result; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param $class |
||
| 21 | * @return \PHPUnit_Framework_TestListener |
||
| 22 | */ |
||
| 23 | |||
| 24 | public function getListener($class) |
||
| 32 | |||
| 33 | public function clear() |
||
| 39 | |||
| 40 | View Code Duplication | public function addListener( $listener) |
|
| 55 | |||
| 56 | View Code Duplication | public function play($method, $args, \PHPUnit_Framework_TestListener $instance = null) |
|
| 66 | |||
| 67 | public function bindToResult(\PHPUnit_Framework_TestResult $result) |
||
| 74 | |||
| 75 | public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
||
| 83 | |||
| 84 | View Code Duplication | public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
| 92 | |||
| 93 | public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
||
| 101 | |||
| 102 | public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
||
| 110 | |||
| 111 | public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
||
| 119 | |||
| 120 | View Code Duplication | public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
| 128 | |||
| 129 | View Code Duplication | public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
| 137 | |||
| 138 | View Code Duplication | public function startTest(PHPUnit_Framework_Test $test) |
|
| 146 | |||
| 147 | View Code Duplication | public function endTest(PHPUnit_Framework_Test $test, $time) |
|
| 155 | |||
| 156 | } |
||
| 157 |