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 | protected static $testRunId; |
||
27 | |||
28 | public function setMasterListener(MasterListenerInterface $listener) |
||
32 | |||
33 | View Code Duplication | public function addCharacteristic($type, $value) |
|
44 | |||
45 | public function getInvokedTest() |
||
49 | |||
50 | public function setTestName($name) |
||
54 | |||
55 | public function setTestStatus($status) |
||
59 | |||
60 | public function setTestId($testId) |
||
64 | |||
65 | public function logStep($stepId) |
||
69 | |||
70 | public function logAssertionSuccess(AbstractAssertion $assertion, array $extra) |
||
75 | |||
76 | public function logAssertionFailure(Exception $e, AbstractAssertion $assertion, array $extra) |
||
81 | |||
82 | View Code Duplication | public function createExtra($includeArray = []) |
|
98 | |||
99 | View Code Duplication | public function getTestRunId() |
|
116 | |||
117 | |||
118 | public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
||
123 | |||
124 | public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) |
||
129 | |||
130 | public function addIncompleteTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
135 | |||
136 | public function addRiskyTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
140 | |||
141 | public function addSkippedTest(\PHPUnit_Framework_Test $test, Exception $e, $time) |
||
146 | |||
147 | public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) |
||
151 | |||
152 | public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) |
||
156 | |||
157 | View Code Duplication | public function startTest(\PHPUnit_Framework_Test $test) |
|
168 | |||
169 | public function endTest(\PHPUnit_Framework_Test $test, $time) |
||
174 | |||
175 | |||
176 | } |
||
177 |