Completed
Push — to-be-a-hat-or-not-to-be-kuhwa ( 7c7f7b...b72886 )
by Kamil
20:35
created

ProductSlugController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateAction() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\ProductBundle\Controller;
13
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
18
/**
19
 * @author Mateusz Zalewski <[email protected]>
20
 */
21
class ProductSlugController extends Controller
22
{
23
    /**
24
     * @param Request $request
25
     *
26
     * @return JsonResponse
27
     */
28
    public function generateAction(Request $request)
29
    {
30
        $name = $request->query->get('name');
31
32
        return new JsonResponse([
33
            'slug' => $this->get('sylius.generator.slug')->generate($name),
34
        ]);
35
    }
36
}
37