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 |
||
3 | class ActivityController extends Zend_Controller_Action |
||
4 | { |
||
5 | 3 | public function init(): void |
|
6 | { |
||
7 | // Init the Context Switch Action helper |
||
8 | 3 | $contextSwitch = $this->_helper->contextSwitch(); |
|
9 | |||
10 | // Add the new context |
||
11 | 3 | $contextSwitch->setContexts([ |
|
12 | 3 | 'rss' => ['suffix' => 'rss'], |
|
13 | ]); |
||
14 | |||
15 | 3 | $contextSwitch->addActionContext('index', 'rss')->initContext(); |
|
16 | 3 | } |
|
17 | |||
18 | 3 | public function indexAction(): void |
|
41 | 3 | } |
|
42 | } |
||
43 |