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 |
||
12 | class CRUDController extends BaseCRUDController |
||
13 | { |
||
14 | /** |
||
15 | * @return \Symfony\Component\HttpFoundation\Response |
||
16 | */ |
||
17 | 13 | public function createAction() |
|
18 | { |
||
19 | 13 | if (!$this->getRequest()->get('provider') && $this->getRequest()->isMethod('get')) { |
|
20 | 1 | return $this->render( |
|
|
|||
21 | 1 | '@MediaMonksSonataMedia/CRUD/select_provider.html.twig', |
|
22 | [ |
||
23 | 1 | 'providers' => $this->get('mediamonks.sonata_media.provider.pool')->getProviders(), |
|
24 | 1 | 'base_template' => $this->getBaseTemplate(), |
|
25 | 1 | 'admin' => $this->admin, |
|
26 | 1 | 'action' => 'create', |
|
27 | ] |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | 12 | return parent::createAction(); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param Request $request |
||
36 | * @param $id |
||
37 | * @return StreamedResponse |
||
38 | */ |
||
39 | 1 | View Code Duplication | public function downloadAction(Request $request, $id) |
47 | |||
48 | /** |
||
49 | * @param Request $request |
||
50 | * @param int $id |
||
51 | * @return RedirectResponse |
||
52 | */ |
||
53 | 4 | View Code Duplication | public function imageAction(Request $request, $id, $width, $height) |
61 | } |
||
62 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.