Completed
Push — master ( 84502e...b265bb )
by Sergey
02:22
created

AppController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 6
c 4
b 0
f 2
lcom 0
cbo 7
dl 0
loc 32
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerUserAction() 0 4 1
A registerUserCustomAction() 0 4 1
A withErrorResponseAction() 0 4 1
A contextDependingRequestAction() 0 4 1
A noCustomRequestAction() 0 4 1
A validationResultsAction() 0 4 1
1
<?php
2
3
namespace Fesor\RequestObject\Examples\App;
4
5
use Fesor\RequestObject\Examples\Request\ContextDependingRequest;
6
use Fesor\RequestObject\Examples\Request\ExtendedRegisterUserRequest;
7
use Fesor\RequestObject\Examples\Request\RegisterUserRequest;
8
use Fesor\RequestObject\Examples\Request\ResponseProvidingRequest;
9
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\Validator\ConstraintViolationList;
13
14
class AppController extends Controller
15
{
16
    public function registerUserAction(RegisterUserRequest $request)
17
    {
18
        return new JsonResponse($request->all(), 201);
19
    }
20
    
21
    public function registerUserCustomAction(ExtendedRegisterUserRequest $request)
22
    {
23
        return new JsonResponse($request->all(), 201);
24
    }
25
26
    public function withErrorResponseAction(ResponseProvidingRequest $request)
27
    {
28
        return new JsonResponse($request->all(), 201);
29
    }
30
31
    public function contextDependingRequestAction(ContextDependingRequest $request)
32
    {
33
        return new JsonResponse($request->all(), 201);
34
    }
35
    
36
    public function noCustomRequestAction($foo = '')
0 ignored issues
show
Unused Code introduced by
The parameter $foo is not used and could be removed.

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

Loading history...
37
    {
38
        return new Response(null, 204);
39
    }
40
41
    public function validationResultsAction(RegisterUserRequest $request, ConstraintViolationList $errors)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

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

Loading history...
42
    {
43
        return new Response(count($errors), 200, ['Content-Type' => 'text/plain']);
44
    }
45
}