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 MaintenanceComponent extends Component |
||
9 | { |
||
10 | /** |
||
11 | * Controller object |
||
12 | * |
||
13 | * @var \Cake\Controller\Controller |
||
14 | */ |
||
15 | protected $_controller; |
||
16 | |||
17 | /** |
||
18 | * The allowed routes. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $_allowedRoutes = [ |
||
23 | 'Pages.maintenance', |
||
24 | 'Users.login', |
||
25 | 'Users.logout' |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * Initialize properties. |
||
30 | * |
||
31 | * @param array $config The config data. |
||
32 | * |
||
33 | * @return void |
||
34 | */ |
||
35 | public function initialize(array $config) |
||
39 | |||
40 | /** |
||
41 | * Handle the maintenance mode. |
||
42 | * |
||
43 | * @return false|void |
||
44 | */ |
||
45 | public function handle() |
||
91 | } |
||
92 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.