RespondWithJsonJob::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 4
crap 1
1
<?php
2
3
namespace Anfischer\Foundation\Domains\Http\Jobs;
4
5
use Anfischer\Foundation\Job\Job;
6
use Illuminate\Contracts\Routing\ResponseFactory;
7
use Illuminate\Http\JsonResponse;
8
9
class RespondWithJsonJob extends Job
10
{
11
    protected $status;
12
    protected $content;
13
    protected $headers;
14
    protected $options;
15
16 4
    public function __construct($content = null, int $status = 200, array $headers = [], int $options = 0)
17
    {
18 4
        $this->content = $content;
19 4
        $this->status = $status;
20 4
        $this->headers = $headers;
21 4
        $this->options = $options;
22 4
    }
23
24 4
    public function handle(ResponseFactory $factory) : JsonResponse
25
    {
26
        $response = [
27 4
            'data' => $this->content,
28 4
            'status' => $this->status,
29
        ];
30
31 4
        return $factory->json($response, $this->status, $this->headers, $this->options);
32
    }
33
}
34