Completed
Pull Request — master (#80)
by John
07:39 queued 04:25
created

SimpleErrorResponseFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Response\ErrorResponseFactory;
10
11
use KleijnWeb\SwaggerBundle\Response\Error\HttpError;
12
use KleijnWeb\SwaggerBundle\Response\ErrorResponseFactory;
13
use Symfony\Component\HttpFoundation\JsonResponse;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * @author John Kleijn <[email protected]>
18
 */
19
class SimpleErrorResponseFactory implements ErrorResponseFactory
20
{
21
    /**
22
     * @param HttpError $error
23
     *
24
     * @return Response
25
     */
26
    public function create(HttpError $error): Response
27
    {
28
        return new JsonResponse(['message' => $error->getMessage()], $error->getStatusCode());
29
    }
30
}
31