Code Duplication    Length = 13-14 lines in 2 locations

src/Models/Model.php 2 locations

@@ 357-370 (lines=14) @@
354
     * @param   Model   $model  The model to remove from the collection.
355
     * @return  self
356
     */
357
    public function remove($key, Model $model)
358
    {
359
        if (false === $this->isHasMany($key)) {
360
            return $this;
361
        }
362
        if (true === $this->isInverse($key)) {
363
            throw ModelException::cannotModifyInverse($this, $key);
364
        }
365
        $this->touch();
366
        $collection = $this->hasManyRelationships->get($key);
367
        $collection->remove($model);
368
        $this->doDirtyCheck();
369
        return $this;
370
    }
371
372
    /**
373
     * Sets a model property: an attribute value, a has-one model, or an entire has-many model collection.
@@ 452-464 (lines=13) @@
449
     * @param   Model|null  $model  The model to relate.
450
     * @return  self
451
     */
452
    protected function setHasOne($key, Model $model = null)
453
    {
454
        if (true === $this->isInverse($key)) {
455
            throw ModelException::cannotModifyInverse($this, $key);
456
        }
457
        if (null !== $model) {
458
            $this->validateRelSet($key, $model->getType());
459
        }
460
        $this->touch();
461
        $this->hasOneRelationships->set($key, $model);
462
        $this->doDirtyCheck();
463
        return $this;
464
    }
465
466
    /**
467
     * Validates that the model type (from a Model or Collection instance) can be set to the relationship field.