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 |
||
21 | View Code Duplication | class ValidateTest4IsEmailAddr extends \PHPUnit_Framework_TestCase |
|
22 | { |
||
23 | //------------------------------------------------------// |
||
24 | // テストメソッド定義 |
||
25 | //------------------------------------------------------// |
||
26 | /** |
||
27 | * setUp() |
||
28 | * |
||
29 | * テストに必要な準備を実施 |
||
30 | */ |
||
31 | protected function setUp() |
||
34 | |||
35 | /** |
||
36 | * test_IsEmailAddr_InvalidTextPart1() |
||
37 | * |
||
38 | * isEmailAddr()の挙動をテストする(メールアドレスじゃない文字列その1) |
||
39 | */ |
||
40 | public function test_IsEmailAddr_InvalidTextPart1() |
||
46 | |||
47 | /** |
||
48 | * test_IsEmailAddr_InvalidText() |
||
49 | * |
||
50 | * isEmailAddr()の挙動をテストする(メールアドレスじゃない文字列その2) |
||
51 | */ |
||
52 | public function test_IsEmailAddr_InvalidTextPart2() |
||
58 | |||
59 | /** |
||
60 | * test_IsEmailAddr_ValidTextPart1() |
||
61 | * |
||
62 | * isEmailAddr()の挙動をテストする(メールアドレスな文字列その1) |
||
63 | */ |
||
64 | public function test_IsEmailAddr_ValidTextPart1() |
||
70 | |||
71 | /** |
||
72 | * test_IsEmailAddr_ValidTextPart2() |
||
73 | * |
||
74 | * isEmailAddr()の挙動をテストする(メールアドレスな文字列その2) |
||
75 | */ |
||
76 | public function test_IsEmailAddr_ValidTextPart2() |
||
82 | } |