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  | 
            ||
| 37 | class InventoryController extends AbstractController  | 
            ||
| 38 | { | 
            ||
| 39 | /**  | 
            ||
| 40 | * Lists all Inventory entities.  | 
            ||
| 41 | *  | 
            ||
| 42 |      * @Route("/", name="inventory") | 
            ||
| 43 |      * @Method("GET") | 
            ||
| 44 | * @Template()  | 
            ||
| 45 | *  | 
            ||
| 46 | * @param \Symfony\Component\HttpFoundation\Request $request Paginate request  | 
            ||
| 47 | * @return array  | 
            ||
| 48 | */  | 
            ||
| 49 | public function indexAction(Request $request)  | 
            ||
| 63 | |||
| 64 | /**  | 
            ||
| 65 | * Finds and displays a Inventory entity.  | 
            ||
| 66 | *  | 
            ||
| 67 |      * @Route("/{id}/show", name="inventory_show", requirements={"id"="\d+"}) | 
            ||
| 68 |      * @Method("GET") | 
            ||
| 69 | * @Template()  | 
            ||
| 70 | *  | 
            ||
| 71 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to display  | 
            ||
| 72 | * @return array  | 
            ||
| 73 | */  | 
            ||
| 74 | public function showAction(Inventory $inventory)  | 
            ||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * Create Create form.  | 
            ||
| 92 | *  | 
            ||
| 93 | * @param string $route Route of action form  | 
            ||
| 94 | * @return \Symfony\Component\Form\Form  | 
            ||
| 95 | */  | 
            ||
| 96 | protected function createCreateForm($route)  | 
            ||
| 105 | |||
| 106 | /**  | 
            ||
| 107 | * Creates a new Inventory entity.  | 
            ||
| 108 | *  | 
            ||
| 109 |      * @Route("/create", name="inventory_create") | 
            ||
| 110 |      * @Method("PUT") | 
            ||
| 111 | *  | 
            ||
| 112 | * @param \Symfony\Component\HttpFoundation\Request $request  | 
            ||
| 113 | * @return \Symfony\Component\HttpFoundation\RedirectResponse  | 
            ||
| 114 | */  | 
            ||
| 115 | public function createAction(Request $request)  | 
            ||
| 147 | |||
| 148 | /**  | 
            ||
| 149 | * Displays a form to edit an existing Inventory entity.  | 
            ||
| 150 | *  | 
            ||
| 151 |      * @Route("/{id}/edit", name="inventory_edit", requirements={"id"="\d+"}) | 
            ||
| 152 |      * @Method("GET") | 
            ||
| 153 | * @Template()  | 
            ||
| 154 | *  | 
            ||
| 155 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to edit  | 
            ||
| 156 | * @return array  | 
            ||
| 157 | */  | 
            ||
| 158 | public function editAction(Inventory $inventory)  | 
            ||
| 172 | |||
| 173 | /**  | 
            ||
| 174 | * Edits an existing Inventory entity.  | 
            ||
| 175 | *  | 
            ||
| 176 |      * @Route("/{id}/update", name="inventory_update", requirements={"id"="\d+"}) | 
            ||
| 177 |      * @Method("PUT") | 
            ||
| 178 |      * @Template("AppBundle:Inventory:edit.html.twig") | 
            ||
| 179 | *  | 
            ||
| 180 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to update  | 
            ||
| 181 | * @param \Symfony\Component\HttpFoundation\Request $request Form request  | 
            ||
| 182 | * @return array  | 
            ||
| 183 | */  | 
            ||
| 184 | View Code Duplication | public function updateAction(Inventory $inventory, Request $request)  | 
            |
| 205 | |||
| 206 | /**  | 
            ||
| 207 | * Displays a form to valid an existing Inventory entity.  | 
            ||
| 208 | *  | 
            ||
| 209 |      * @Route("/{id}/valid", name="inventory_valid", requirements={"id"="\d+"}) | 
            ||
| 210 |      * @Method("GET") | 
            ||
| 211 | * @Template()  | 
            ||
| 212 | *  | 
            ||
| 213 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to validate  | 
            ||
| 214 | * @return array  | 
            ||
| 215 | */  | 
            ||
| 216 | public function validAction(Inventory $inventory)  | 
            ||
| 230 | |||
| 231 | /**  | 
            ||
| 232 | * Close an existing Inventory entity.  | 
            ||
| 233 | *  | 
            ||
| 234 |      * @Route("/{id}/close", name="inventory_close", requirements={"id"="\d+"}) | 
            ||
| 235 |      * @Method("PUT") | 
            ||
| 236 |      * @Template("AppBundle:Inventory:valid.html.twig") | 
            ||
| 237 | *  | 
            ||
| 238 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to close  | 
            ||
| 239 | * @param \Symfony\Component\HttpFoundation\Request $request Form request  | 
            ||
| 240 | * @return array|\Symfony\Component\HttpFoundation\RedirectResponse  | 
            ||
| 241 | */  | 
            ||
| 242 | public function closeAction(Inventory $inventory, Request $request)  | 
            ||
| 275 | |||
| 276 | /**  | 
            ||
| 277 | * Deletes a Inventory entity.  | 
            ||
| 278 | *  | 
            ||
| 279 |      * @Route("/{id}/delete", name="inventory_delete", requirements={"id"="\d+"}) | 
            ||
| 280 |      * @Method("DELETE") | 
            ||
| 281 | *  | 
            ||
| 282 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to delete  | 
            ||
| 283 | * @param \Symfony\Component\HttpFoundation\Request $request Form request  | 
            ||
| 284 | * @return \Symfony\Component\HttpFoundation\RedirectResponse  | 
            ||
| 285 | */  | 
            ||
| 286 | public function deleteAction(Inventory $inventory, Request $request)  | 
            ||
| 298 | |||
| 299 | /**  | 
            ||
| 300 | * Print the current inventory.<br />Creating a `PDF` file for viewing on paper  | 
            ||
| 301 | *  | 
            ||
| 302 |      * @Route("/{id}/print/", name="inventory_print", requirements={"id"="\d+"}) | 
            ||
| 303 |      * @Method("GET") | 
            ||
| 304 | * @Template()  | 
            ||
| 305 | *  | 
            ||
| 306 | * @param \AppBundle\Entity\Inventory $inventory Inventory item to print  | 
            ||
| 307 | * @return \Symfony\Component\HttpFoundation\Response  | 
            ||
| 308 | */  | 
            ||
| 309 | public function printAction(Inventory $inventory)  | 
            ||
| 329 | |||
| 330 | /**  | 
            ||
| 331 | * Print the preparation of inventory.<br />Creating a `PDF` file for viewing on paper  | 
            ||
| 332 | *  | 
            ||
| 333 |      * @Route("/{id}/print/prepare", name="inventory_print_prepare", requirements={"id"="\d+"}) | 
            ||
| 334 |      * @Method("GET") | 
            ||
| 335 | * @Template()  | 
            ||
| 336 | *  | 
            ||
| 337 | * @param \AppBundle\Entity\Inventory $inventory  | 
            ||
| 338 | * @return \Symfony\Component\HttpFoundation\Response  | 
            ||
| 339 | */  | 
            ||
| 340 | public function prepareDataAction(Inventory $inventory)  | 
            ||
| 362 | }  | 
            ||
| 363 | 
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.