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 // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowerCase |
||
| 14 | class WP_Test_Autoloader extends TestCase { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Setup runs before each test. |
||
| 18 | */ |
||
| 19 | public function setup() { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Tests whether enqueueing adds a class to the global array. |
||
| 27 | */ |
||
| 28 | View Code Duplication | public function test_enqueueing_adds_to_the_global_array() { |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Tests whether enqueueing adds the latest class version to the global array. |
||
| 39 | */ |
||
| 40 | View Code Duplication | public function test_enqueueing_adds_the_latest_version_to_the_global_array() { |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Tests whether enqueueing prioritizes the dev version of the class. |
||
| 53 | */ |
||
| 54 | View Code Duplication | public function test_enqueueing_always_adds_the_dev_version_to_the_global_array() { |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Tests whether enqueueing works with autoloading. |
||
| 68 | */ |
||
| 69 | public function test_enqueue_class_to_autoload_works_as_expected() { |
||
| 76 | } |
||
| 77 |