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 | View Code Duplication | class BeforeConfigurationEvent extends Event |
|
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var AdminInterface |
||
| 15 | */ |
||
| 16 | protected $admin; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | protected $actionName; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $actionConfiguration; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * BeforeConfigurationEvent constructor. |
||
| 30 | * |
||
| 31 | * @param $actionName |
||
| 32 | * @param $actionConfiguration |
||
| 33 | * @param AdminInterface $admin |
||
| 34 | */ |
||
| 35 | 5 | public function __construct($actionName, $actionConfiguration, AdminInterface $admin) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @return AdminInterface |
||
| 44 | */ |
||
| 45 | 2 | public function getAdmin() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 2 | public function getActionName() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | 5 | public function getActionConfiguration() |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @param array $actionConfiguration |
||
| 68 | */ |
||
| 69 | 2 | public function setActionConfiguration($actionConfiguration) |
|
| 73 | } |
||
| 74 |