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 |
||
| 10 | class AdminBlockController extends Controller |
||
| 11 | { |
||
| 12 | private $_cmsParameter = 'alpixel_cms.blocks'; |
||
| 13 | private $_cmsContentParameter = null; |
||
| 14 | private $_blockDefaultClass = 'Alpixel\Bundle\CMSBundle\Entity\Block'; |
||
|
|
|||
| 15 | |||
| 16 | View Code Duplication | public function editContentAction() |
|
| 30 | |||
| 31 | public function listAction(Request $request = null) |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Set instances of admin in $_cmsContentParameter. |
||
| 54 | */ |
||
| 55 | protected function getInstancesAdmin() |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param $role array Role in cms.yml |
||
| 69 | * |
||
| 70 | * Check role define in different parameter of block or content_types cms.yml |
||
| 71 | */ |
||
| 72 | View Code Duplication | protected function checkRolesCMS(array $role) |
|
| 86 | |||
| 87 | /** |
||
| 88 | * Get content in cms.yml and set in $_cmsParameter. |
||
| 89 | * |
||
| 90 | * @return content of cms.yml |
||
| 91 | */ |
||
| 92 | protected function getCMSParameter() |
||
| 102 | } |
||
| 103 |
This check marks private properties in classes that are never used. Those properties can be removed.