Code Duplication    Length = 15-15 lines in 2 locations

src/SMG/ManagerBundle/Controller/ManagersController.php 1 location

@@ 221-235 (lines=15) @@
218
     *
219
     * @throws BadRequestHttpException
220
     */
221
    private function requestIsJsonWithKeysOrThrow(
222
        Request $request,
223
        array $keys,
224
        $message = 'bst.json.field_missing'
225
    ) {
226
        $json = json_decode($request->getContent(), true);
227
228
        foreach ($keys as $key) {
229
            if (empty($json[$key])) {
230
                throw new BadRequestHttpException($message);
231
            }
232
        }
233
234
        return $json;
235
    }
236
237
    private function isCurrentUserAdmin()
238
    {

src/SMG/UserBundle/Controller/UsersController.php 1 location

@@ 372-386 (lines=15) @@
369
     *
370
     * @return array
371
     */
372
    private function requestIsJsonWithKeysOrThrow(
373
        Request $request,
374
        array $keys,
375
        $message = 'bst.json.field_missing'
376
    ) {
377
        $json = json_decode($request->getContent(), true);
378
379
        foreach ($keys as $key) {
380
            if (empty($json[$key])) {
381
                throw new BadRequestHttpException($message);
382
            }
383
        }
384
385
        return $json;
386
    }
387
388
    /**
389
     * /!\ This method does not validate the input