LaravelResponseFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 4 1
1
<?php
2
3
namespace Flugg\Responder\Http\Responses\Factories;
4
5
use Flugg\Responder\Contracts\ResponseFactory;
6
use Illuminate\Contracts\Routing\ResponseFactory as BaseLaravelResponseFactory;
7
use Illuminate\Http\JsonResponse;
8
9
/**
10
 * A factory class for creating JSON responses utilizing Laravel.
11
 *
12
 * @package flugger/laravel-responder
13
 * @author  Alexander Tømmerås <[email protected]>
14
 * @license The MIT License
15
 */
16
class LaravelResponseFactory implements ResponseFactory
17
{
18
    /**
19
     * The Laravel factory for making responses.
20
     *
21
     * @var \Illuminate\Contracts\Routing\ResponseFactory
22
     */
23
    protected $factory;
24
25
    /**
26
     * Construct the factory class.
27
     *
28
     * @param \Illuminate\Contracts\Routing\ResponseFactory $factory
29
     */
30 56
    public function __construct(BaseLaravelResponseFactory $factory)
31
    {
32 56
        $this->factory = $factory;
33 56
    }
34
35
    /**
36
     * Generate a JSON response.
37
     *
38
     * @param  array $data
39
     * @param  int   $status
40
     * @param  array $headers
41
     * @return \Illuminate\Http\JsonResponse
42
     */
43 56
    public function make(array $data, int $status, array $headers = []): JsonResponse
44
    {
45 56
        return $this->factory->json($data, $status, $headers);
46
    }
47
}