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 |
||
13 | class WP_Test_File_Loader extends TestCase { |
||
14 | |||
15 | /** |
||
16 | * Setup runs before each test. |
||
17 | */ |
||
18 | public function setup() { |
||
23 | |||
24 | /** |
||
25 | * Tests whether enqueueing adds a file to the global array. |
||
26 | */ |
||
27 | View Code Duplication | public function test_enqueueing_adds_to_the_global_array() { |
|
35 | |||
36 | /** |
||
37 | * Tests whether enqueueing adds the latest file version to the global array. |
||
38 | */ |
||
39 | View Code Duplication | public function test_enqueueing_adds_the_latest_version_to_the_global_array() { |
|
48 | |||
49 | /** |
||
50 | * Tests whether enqueueing prioritizes the dev version of the file. |
||
51 | */ |
||
52 | View Code Duplication | public function test_enqueueing_always_adds_the_dev_version_to_the_global_array() { |
|
63 | |||
64 | /** |
||
65 | * Tests whether enqueueing works with autoloading. |
||
66 | */ |
||
67 | public function test_enqueued_file_is_actually_loaded() { |
||
81 | } |
||
82 |