| 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 |
||
| 17 | class Menu |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Shows all employees. |
||
| 21 | * |
||
| 22 | * @param Employee[] $employees employees to show |
||
| 23 | */ |
||
| 24 | public static function showEmployees(array $employees): void |
||
| 25 | { |
||
| 26 | echo "List of employees:"; |
||
| 27 | foreach ($employees as $employee) { |
||
| 28 | if ($employee instanceof Employee) { |
||
| 29 | echo PHP_EOL . "{$employee->getName()} - {$employee->getPosition()}"; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | echo '.' . PHP_EOL; |
||
| 33 | } |
||
| 34 | } |