HttpFoundationResponseBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 46
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
ccs 0
cts 24
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildErrorResponse() 0 10 1
A buildErrorRedirectResponse() 0 4 1
A buildSuccessResponse() 0 10 1
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