Completed
Pull Request — master (#49)
by John
05:45
created

VndValidationErrorFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
1
<?php
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;
10
11
use KleijnWeb\SwaggerBundle\Exception\InvalidParametersException;
12
use Ramsey\VndError\VndError;
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * @author John Kleijn <[email protected]>
17
 */
18
class VndValidationErrorFactory
19
{
20
    const DEFAULT_MESSAGE = 'Input Validation Failure';
21
22
23
    /**
24
     * @param Request                    $request
25
     * @param InvalidParametersException $exception
26
     *
27
     * @param string|null                $logRef
28
     *
29
     * @return VndError
30
     */
31
    public function create(Request $request, InvalidParametersException $exception, $logRef)
32
    {
33
        $vndError = new VndError(self::DEFAULT_MESSAGE, $logRef);
34
        $vndError->addLink('help', $request->attributes->get('_resource'), ['title' => 'Error Information']);
35
        $vndError->addLink('about', $request->getUri(), ['title' => 'Error Information']);
36
        var_dump($exception->getValidationErrors());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($exception->getValidationErrors()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
37
38
        return $vndError;
39
    }
40
}
41