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 |
||
13 | class LoggerPHPUnit5 extends \Zend\Log\Logger implements TestListener, MasterListenerAware, LoggerInterface |
||
|
|||
14 | { |
||
15 | |||
16 | protected $status = self::STATUS_PASSED; |
||
17 | |||
18 | protected $testName = self::NAME_DEFAULT; |
||
19 | |||
20 | protected $testId; |
||
21 | |||
22 | protected $invokedTest; |
||
23 | |||
24 | protected $selectorConfig = null; |
||
25 | |||
26 | public function setMasterListener(MasterListenerInterface $listener) |
||
30 | |||
31 | View Code Duplication | public function addCharacteristic($type, $value) |
|
42 | |||
43 | public function getInvokedTest() |
||
47 | |||
48 | public function setTestName($name) |
||
52 | |||
53 | public function setTestStatus($status) |
||
57 | |||
58 | public function setTestId($testId) |
||
62 | |||
63 | public function logStep($stepId) |
||
67 | |||
68 | public function logAssertionSuccess(AbstractAssertion $assertion, array $extra) |
||
73 | |||
74 | public function logAssertionFailure(Exception $e, AbstractAssertion $assertion, array $extra) |
||
79 | |||
80 | View Code Duplication | public function createExtra($includeArray = []) |
|
95 | |||
96 | public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
||
101 | |||
102 | public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) |
||
107 | |||
108 | public function addIncompleteTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
113 | |||
114 | public function addRiskyTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
118 | |||
119 | public function addSkippedTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
124 | |||
125 | public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) |
||
129 | |||
130 | public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) |
||
134 | |||
135 | View Code Duplication | public function startTest(\PHPUnit_Framework_Test $test) |
|
146 | |||
147 | public function endTest(\PHPUnit_Framework_Test $test, $time) |
||
152 | |||
153 | |||
154 | } |
||
155 |