Code Duplication    Length = 20-22 lines in 2 locations

src/Query/LaravelQuery.php 2 locations

@@ 306-327 (lines=22) @@
303
     *
304
     * @return object|null The new resource value if it is assignable or throw exception for null.
305
     */
306
    public function updateResource(
307
        ResourceSet $sourceResourceSet,
308
        $sourceEntityInstance,
309
        KeyDescriptor $keyDescriptor,
310
        $data,
311
        $shouldUpdate = false
312
    ) {
313
        if (!(null == $sourceEntityInstance || $sourceEntityInstance instanceof Model)) {
314
            throw new InvalidArgumentException('Source entity must either be null or an Eloquent model.');
315
        }
316
        $verb = 'update';
317
        $class = $sourceResourceSet->getResourceType()->getInstanceType()->name;
318
319
        $data = $this->createUpdateDeleteCore($sourceEntityInstance, $data, $class, $verb);
320
321
        $success = isset($data['id']);
322
323
        if ($success) {
324
            return $class::findOrFail($data['id']);
325
        }
326
        throw new ODataException('Target model not successfully updated', 422);
327
    }
328
    /**
329
     * Delete resource from a resource set.
330
     * @param ResourceSet|null $sourceResourceSet
@@ 363-382 (lines=20) @@
360
     *
361
     * returns object|null returns the newly created model if sucessful or null if model creation failed.
362
     */
363
    public function createResourceforResourceSet(
364
        ResourceSet $resourceSet,
365
        $sourceEntityInstance,
366
        $data
367
    ) {
368
        if (!(null == $sourceEntityInstance || $sourceEntityInstance instanceof Model)) {
369
            throw new InvalidArgumentException('Source entity must either be null or an Eloquent model.');
370
        }
371
        $verb = 'create';
372
        $class = $resourceSet->getResourceType()->getInstanceType()->name;
373
374
        $data = $this->createUpdateDeleteCore($sourceEntityInstance, $data, $class, $verb);
375
376
        $success = isset($data['id']);
377
378
        if ($success) {
379
            return $class::findOrFail($data['id']);
380
        }
381
        throw new ODataException('Target model not successfully created', 422);
382
    }
383
384
    /**
385
     * @param $sourceEntityInstance