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 |
||
| 3 | class MeetingCest extends CestCase |
||
| 4 | { |
||
| 5 | |||
| 6 | private $simpleMeeting = [ |
||
| 7 | 'fields' => [ |
||
| 8 | 'place' => 'Testovací - simple', |
||
| 9 | 'start_date' => '2016-10-13', |
||
| 10 | 'end_date' => '2016-10-14', |
||
| 11 | 'open_reg' => '2016-10-13 00:00:00', |
||
| 12 | 'close_reg' => '2016-10-14 00:00:00', |
||
| 13 | ], |
||
| 14 | ]; |
||
| 15 | |||
| 16 | private $fullMeeting = [ |
||
| 17 | 'fields' => [ |
||
| 18 | 'place' => 'Testovací - full', |
||
| 19 | 'start_date' => '2016-10-13', |
||
| 20 | 'end_date' => '2016-10-14', |
||
| 21 | 'open_reg' => '2016-10-13 00:00:00', |
||
| 22 | 'close_reg' => '2016-10-14 00:00:00', |
||
| 23 | 'cost' => 500, |
||
| 24 | 'advance' => 300, |
||
| 25 | 'numbering' => 'x2016', |
||
| 26 | 'contact' => 'Tester', |
||
| 27 | 'email' => '[email protected]', |
||
| 28 | 'gsm' => '123456789', |
||
| 29 | ], |
||
| 30 | ]; |
||
| 31 | |||
| 32 | public function _before(AcceptanceTester $I) |
||
| 44 | |||
| 45 | public function _after(AcceptanceTester $I) |
||
| 48 | |||
| 49 | // tests |
||
| 50 | public function ensure_that_meeting_works(\AcceptanceTester $I) |
||
| 56 | |||
| 57 | View Code Duplication | public function ensure_that_meeting_listing_works(\AcceptanceTester $I) |
|
| 65 | |||
| 66 | View Code Duplication | public function ensure_that_meeting_creating_works(\AcceptanceTester $I) |
|
| 75 | |||
| 76 | View Code Duplication | public function it_should_create_simple_meeting(\AcceptanceTester $I) |
|
| 87 | |||
| 88 | View Code Duplication | public function it_should_create_full_meeting(\AcceptanceTester $I) |
|
| 99 | |||
| 100 | } |
||
| 101 |
This check marks parameter names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.