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 |
||
| 5 | class ParagraphTextTest extends FormTestCase { |
||
| 6 | |||
| 7 | /** @test */ |
||
| 8 | public function it_can_be_rendered() |
||
| 14 | |||
| 15 | /** @test */ |
||
| 16 | View Code Duplication | public function it_renders_a_default_value() |
|
| 23 | |||
| 24 | /** @test */ |
||
| 25 | View Code Duplication | public function it_renders_model_values() |
|
| 33 | |||
| 34 | /** @test */ |
||
| 35 | View Code Duplication | public function it_can_fill_model_values() |
|
| 45 | |||
| 46 | /** @test */ |
||
| 47 | View Code Duplication | public function it_escapes_value() |
|
| 54 | |||
| 55 | /** @test */ |
||
| 56 | public function it_provides_expected_values() |
||
| 63 | |||
| 64 | /** @test */ |
||
| 65 | public function it_provides_expected_default_values() |
||
| 72 | |||
| 73 | /** @test */ |
||
| 74 | public function it_validates_required() |
||
| 80 | |||
| 81 | } |
||
| 82 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: