Completed
Push — master ( 2cb995...b7feec )
by Philipp
02:41
created

buildErrorRedirectResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 4
crap 2
1
<?php
2
3
namespace Phisch\OAuth\Server\Response;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpFoundation\Response;
7
8
class HttpFoundationResponseBuilder extends AbstractResponseBuilder
9
{
10
    /**
11
     * @param array $data
12
     * @param int $status
13
     * @return Response
14
     */
15
    public function buildErrorResponse(array $data, $status)
16
    {
17
        return new Response(
18
            json_encode($data),
19
            $status,
20
            [
21
                'Content-Type' => 'application/json'
22
            ]
23
        );
24
    }
25
26
    /**
27
     * @param $redirectionUri
28
     * @param $error
29
     * @param $description
30
     * @param $errorUri
31
     * @return RedirectResponse
32
     */
33
    public function buildErrorRedirectResponse($redirectionUri, $error, $description, $errorUri)
34
    {
35
        return new RedirectResponse('/', 302);
36
    }
37
38
    /**
39
     * @param array $data
40
     * @param int $status
41
     * @return Response
42
     */
43
    public function buildSuccessResponse(array $data, $status)
44
    {
45
        return new Response(
46
            json_encode($data),
47
            $status,
48
            [
49
                'Content-Type' => 'application/json'
50
            ]
51
        );
52
    }
53
}
54