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 | ||
| 19 | class VersionLoadingFromManifestTest extends TestCase { | ||
| 20 | |||
| 21 | /** | ||
| 22 | * A manifest handler. | ||
| 23 | * | ||
| 24 | * @var Manifest_Reader | ||
| 25 | */ | ||
| 26 | private $manifest_handler; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * Setup runs before each test. | ||
| 30 | * | ||
| 31 | * @before | ||
| 32 | */ | ||
| 33 | 	public function set_up() { | ||
| 36 | |||
| 37 | /** | ||
| 38 | * Tests that the classmap manifest from a single plugin can be handled correctly. | ||
| 39 | */ | ||
| 40 | View Code Duplication | 	public function test_classmap() { | |
| 59 | |||
| 60 | /** | ||
| 61 | * Tests that the PSR-4 manifest from a single plugin can be handled correctly. | ||
| 62 | */ | ||
| 63 | View Code Duplication | 	public function test_psr4() { | |
| 82 | |||
| 83 | /** | ||
| 84 | * Tests that the filemap manifest from a single plugin can be handled correctly. | ||
| 85 | * | ||
| 86 | * @preserveGlobalState disabled | ||
| 87 | * @runInSeparateProcess | ||
| 88 | */ | ||
| 89 | View Code Duplication | 	public function test_filemap() { | |
| 109 | } | ||
| 110 |