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 |
||
| 27 | trait ClientTrait |
||
| 28 | { |
||
| 29 | private $session; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @see ClientInterface |
||
| 33 | */ |
||
| 34 | public function initialize(Session $session) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Most of the time, there is nothing to be done at shutdown. |
||
| 41 | * @see ClientInterface |
||
| 42 | */ |
||
| 43 | public function shutdown() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * getSession |
||
| 49 | * |
||
| 50 | * All subclasses of Client have to use this method to access the session. |
||
| 51 | * |
||
| 52 | * @access protected |
||
| 53 | * @throws FoundationException if Session is not set. |
||
| 54 | * @return Session |
||
| 55 | */ |
||
| 56 | View Code Duplication | protected function getSession() |
|
| 69 | } |
||
| 70 |