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 |
||
11 | class RpcTest extends WebTestCase |
||
12 | { |
||
13 | public function getValidArgumentVariants() |
||
23 | |||
24 | public function getInvalidArgumentVariants() |
||
32 | |||
33 | /** |
||
34 | * @dataProvider getValidArgumentVariants |
||
35 | * |
||
36 | * @param array $args |
||
37 | * |
||
38 | * @throws InvalidMethodParametersException |
||
39 | */ |
||
40 | 3 | View Code Duplication | public function testValidController(array $args) |
47 | |||
48 | /** |
||
49 | * @dataProvider getInvalidArgumentVariants |
||
50 | * |
||
51 | * @param array $args |
||
52 | * |
||
53 | * @expectedException \Bankiru\Api\Rpc\Exception\InvalidMethodParametersException |
||
54 | */ |
||
55 | 3 | public function testInvalidController(array $args) |
|
60 | |||
61 | public function getExceptionTestData() |
||
76 | |||
77 | /** |
||
78 | * @dataProvider getExceptionTestData |
||
79 | * |
||
80 | * @param string $endpoint |
||
81 | * @param array $args |
||
82 | * @param string $exception FQCN |
||
83 | */ |
||
84 | 2 | public function testException($endpoint, $args, $exception) |
|
102 | |||
103 | protected static function getKernelClass() |
||
107 | } |
||
108 |