| Total Complexity | 3 |
| Total Lines | 16 |
| Duplicated Lines | 56.25 % |
| Changes | 0 | ||
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 |
||
| 8 | class Menu |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Shows all employees. |
||
| 12 | * |
||
| 13 | * @param Employee[] $employees employees to show |
||
| 14 | */ |
||
| 15 | public static function showEmployees(array $employees): void |
||
| 16 | { |
||
| 17 | echo "List of employees:"; |
||
| 18 | foreach ($employees as $employee) { |
||
| 19 | if ($employee instanceof Employee) { |
||
| 20 | echo PHP_EOL . "{$employee->getName()} - {$employee->getPosition()}"; |
||
| 21 | } |
||
| 22 | } |
||
| 23 | echo '.' . PHP_EOL; |
||
| 24 | } |
||
| 25 | } |