These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Symfony-Util package. |
||
5 | * |
||
6 | * (c) Jean-Bernard Addor |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace SymfonyUtil\Controller; |
||
13 | |||
14 | use Symfony\Component\HttpFoundation\Response; |
||
15 | use Symfony\Component\Templating\EngineInterface; |
||
16 | |||
17 | View Code Duplication | class TemplatingController |
|
0 ignored issues
–
show
|
|||
18 | { |
||
19 | const TEMPLATE = 'index.html.twig'; |
||
20 | protected $templating; |
||
21 | protected $template; |
||
22 | |||
23 | 4 | public function __construct(EngineInterface $templating, $template = self::TEMPLATE) |
|
24 | { |
||
25 | 4 | $this->templating = $templating; |
|
26 | 4 | $this->template = $template; |
|
27 | 4 | } |
|
28 | |||
29 | 2 | public function __invoke() |
|
30 | { |
||
31 | 2 | return new Response($this->templating->render($this->template)); |
|
32 | } |
||
33 | } |
||
34 |
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.