SlugifyAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 2
b 0
f 0
dl 0
loc 12
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use App\Helper\StringHelper;
0 ignored issues
show
Bug introduced by
The type App\Helper\StringHelper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
11
use Symfony\Component\Routing\Attribute\Route;
12
13
/**
14
 * This is an action implementing the ADR pattern.
15
 *
16
 * @see SlugifyActionTest
17
 * @see https://symfony.com/doc/current/controller/service.html#invokable-controllers
18
 */
19
final class SlugifyAction extends AbstractController
20
{
21
    /**
22
     * Simple API endpoint returning JSON. For a more serious API, please use API Platform 🕸.
23
     * We can use the MapQueryParameter attribute to inject GET parameters.
24
     *
25
     * @see https://api-platform.com/
26
     */
27 1
    #[Route(path: '/api/slugify', name: self::class)]
28
    public function __invoke(StringHelper $stringHelper, #[MapQueryParameter] string $title): Response
29
    {
30 1
        return $this->json(['slug' => $stringHelper->slugify($title)]);
31
    }
32
}
33