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 |
||
14 | class WP_Test_File_Loader extends TestCase { |
||
15 | /** |
||
16 | * Jetpack Package files. |
||
17 | * |
||
18 | * @var $jetpack_packages_files |
||
19 | */ |
||
20 | public static $jetpack_packages_files; |
||
21 | |||
22 | /** |
||
23 | * Test setup. |
||
24 | */ |
||
25 | public function setup() { |
||
31 | |||
32 | /** |
||
33 | * Test tear down. |
||
34 | */ |
||
35 | public function tearDown() { |
||
41 | |||
42 | /** |
||
43 | * Does enqueuing add to the global array? |
||
44 | */ |
||
45 | View Code Duplication | public function test_enqueueing_adds_to_the_global_array() { |
|
53 | |||
54 | /** |
||
55 | * Tests that latest version is added to the global array. |
||
56 | */ |
||
57 | View Code Duplication | public function test_enqueueing_adds_the_latest_version_to_the_global_array() { |
|
66 | |||
67 | /** |
||
68 | * Tests that dev version is added to array. |
||
69 | */ |
||
70 | View Code Duplication | public function test_enqueueing_always_adds_the_dev_version_to_the_global_array() { |
|
81 | |||
82 | /** |
||
83 | * Tests that a file is loaded. |
||
84 | */ |
||
85 | public function test_enqueued_file_is_actually_loaded() { |
||
99 | } |
||
100 |