SaasClientController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createClientAction() 0 15 3
1
<?php
2
3
/*
4
 * This file is part of the SaasProviderBundle package.
5
 * (c) Fluxter <http://fluxter.net/>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Fluxter\SaasProviderBundle\Controller;
11
12
use Fluxter\SaasProviderBundle\Form\CreateClientType;
13
use Fluxter\SaasProviderBundle\Model\SaasClientInterface;
14
use Fluxter\SaasProviderBundle\Service\SaasClientService;
15
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
use Symfony\Component\HttpFoundation\Request;
18
19
class SaasClientController extends AbstractController
20
{
21
    /** @var SaasClientService */
22
    private $clientService;
23
24
    private $clientEntity;
25
26
    public function __construct(SaasClientService $clientService, ContainerInterface $container)
27
    {
28
        $this->clientService = $clientService;
29
        $this->clientEntity = $container->getParameter('saas_provider.client_entity');
30
    }
31
32
    public function createClientAction(Request $request, string $apikey)
0 ignored issues
show
Unused Code introduced by
The parameter $apikey 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

32
    public function createClientAction(Request $request, /** @scrutinizer ignore-unused */ string $apikey)

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...
33
    {
34
        // Todo check the apikey
35
36
        /** @var SaasClientInterface $client */
37
        $client = new $this->clientEntity();
38
        $form = $this->createForm(CreateClientType::class, $client);
39
        $form->handleRequest($request);
40
        if (!$form->isSubmitted() || !$form->isValid()) {
41
            return $this->json($form, 400);
42
        }
43
44
        $this->clientService->createClient($form->get('parameters')->getData());
45
46
        return $this->json(['success' => true]);
47
    }
48
}
49