Item::item()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 12
ccs 0
cts 11
cp 0
crap 6
rs 10
1
<?php
2
3
namespace App\Controller\Frontend;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\Routing\Annotation\Route;
8
use App\Repository\ItemRepository;
9
use Ramsey\Uuid\Uuid;
10
11
class Item extends AbstractController
12
{
13
    /**
14
     * @var ItemRepository
15
     */
16
    private $repository;
17
18
    /**
19
     * @param ItemRepository $repository
20
     */
21
    public function __construct(
22
        ItemRepository $repository
23
    )
24
    {
25
        $this->repository = $repository;
26
    }
27
28
    /**
29
     * @Route("/item/{id}/{slug}", name="item", methods={"GET"})
30
     * @param string $id
31
     * @param string $slug
32
     * @return Response
33
     */
34
    public function item(string $id, string $slug): Response
0 ignored issues
show
Unused Code introduced by
The parameter $slug is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
    public function item(string $id, /** @scrutinizer ignore-unused */ string $slug): Response

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
        try {
37
            $uuid = Uuid::fromString($id);
38
            $item = $this->repository->getItem($uuid);
39
        } catch (\Exception $e) {
40
                $error = $e->getMessage();
41
        }
42
43
        return $this->render('frontend/item.html.twig', [
44
            'item' => $item ?? null,
45
            'error' => $error ?? null
46
        ]);
47
    }
48
}
49