Code Duplication    Length = 25-25 lines in 2 locations

src/Http/Controllers/Api/Jobs/GetResponse.php 1 location

@@ 20-44 (lines=25) @@
17
use Illuminate\Contracts\Support\Responsable as ResponsableContract;
18
use Illuminate\Http\JsonResponse;
19
20
final class GetResponse implements ResponsableContract
21
{
22
    private $job;
23
24
    public function __construct(JobContract $job)
25
    {
26
        $this->job = $job;
27
    }
28
29
    /**
30
     * Create an HTTP response that represents the object.
31
     *
32
     * @param  \Illuminate\Http\Request $request
33
     * @return \Symfony\Component\HttpFoundation\Response
34
     */
35
    public function toResponse($request)
36
    {
37
        return $this->toJson();
38
    }
39
40
    private function toJson(): JsonResponse
41
    {
42
        return response()->json($this->job->toArray());
43
    }
44
}
45

src/Http/Controllers/Api/Jobs/PostResponse.php 1 location

@@ 20-44 (lines=25) @@
17
use Illuminate\Contracts\Support\Responsable as ResponsableContract;
18
use Illuminate\Http\JsonResponse;
19
20
final class PostResponse implements ResponsableContract
21
{
22
    private $job;
23
24
    public function __construct(JobContract $job)
25
    {
26
        $this->job = $job;
27
    }
28
29
    /**
30
     * Create an HTTP response that represents the object.
31
     *
32
     * @param \Illuminate\Http\Request $request
33
     * @return \Symfony\Component\HttpFoundation\Response
34
     */
35
    public function toResponse($request)
36
    {
37
        return $this->toJson();
38
    }
39
40
    private function toJson(): JsonResponse
41
    {
42
        return response()->json($this->job->toArray(), 201);
43
    }
44
}
45