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 defined('BASEPATH') or exit('No direct script access allowed'); |
||
| 3 | class GetKey extends AJAX_Controller { |
||
| 4 | 2 | public function __construct() { |
|
| 10 | |||
| 11 | /** |
||
| 12 | * Used to generate the API Key the userscript can use. |
||
| 13 | * |
||
| 14 | * REQ_PARAMS: N/A |
||
| 15 | * METHOD: POST |
||
| 16 | * URL: /ajax/get_apikey |
||
| 17 | */ |
||
| 18 | 2 | View Code Duplication | public function index() : void { |
| 34 | |||
| 35 | View Code Duplication | public function restore() : void { |
|
| 51 | } |
||
| 52 |