Code Duplication    Length = 23-23 lines in 3 locations

src/Doctrine/Rest/Response/FractalResponse.php 3 locations

@@ 93-115 (lines=23) @@
90
     *
91
     * @return RestResponse
92
     */
93
    public function show(RestRequestAbstract $request, $entity)
94
    {
95
        $headers = [];
96
        $resourceKey = null;
97
98
        if ($entity instanceof JsonApiResource) {
99
            $resourceKey = $entity->getResourceKey();
100
101
            if ($request->isAcceptJsonApi()) {
102
                $headers['Location'] = $this->linkJsonApiResource($entity);
103
                $headers['Content-Type'] = static::JSON_API_CONTENT_TYPE;
104
            }
105
        }
106
107
        return $this->response(
108
            $this->fractal($request)
109
                ->parseFieldsets($request->getFields())
110
                ->createData(new Item($entity, $this->transformer(), $resourceKey ?? null))
111
                ->toArray(),
112
            RestResponse::HTTP_OK,
113
            $headers
114
        );
115
    }
116
117
    /**
118
     * @param RestRequestAbstract   $request
@@ 123-145 (lines=23) @@
120
     *
121
     * @return RestResponse
122
     */
123
    public function create(RestRequestAbstract $request, $entity)
124
    {
125
        $headers = [];
126
        $resourceKey = null;
127
128
        if ($entity instanceof JsonApiResource) {
129
            $resourceKey = $entity->getResourceKey();
130
131
            if ($request->isAcceptJsonApi()) {
132
                $headers['Location'] = $this->linkJsonApiResource($entity);
133
                $headers['Content-Type'] = static::JSON_API_CONTENT_TYPE;
134
            }
135
        }
136
137
        return $this->response(
138
            $this->fractal($request)
139
                ->parseFieldsets($request->getFields())
140
                ->createData(new Item($entity, $this->transformer(), $resourceKey))
141
                ->toArray(),
142
            Response::HTTP_CREATED,
143
            $headers
144
        );
145
    }
146
147
    /**
148
     * @param RestRequestAbstract $request
@@ 153-175 (lines=23) @@
150
     *
151
     * @return RestResponse
152
     */
153
    public function update(RestRequestAbstract $request, $entity)
154
    {
155
        $headers = [];
156
        $resourceKey = null;
157
158
        if ($entity instanceof JsonApiResource) {
159
            $resourceKey = $entity->getResourceKey();
160
161
            if ($request->isAcceptJsonApi()) {
162
                $headers['Location'] = $this->linkJsonApiResource($entity);
163
                $headers['Content-Type'] = static::JSON_API_CONTENT_TYPE;
164
            }
165
        }
166
167
        return $this->response(
168
            $this->fractal($request)
169
                ->parseFieldsets($request->getFields())
170
                ->createData(new Item($entity, $this->transformer(), $resourceKey))
171
                ->toArray(),
172
            Response::HTTP_OK,
173
            $headers
174
        );
175
    }
176
177
    /**
178
     * @param RestRequestAbstract $request