Code Duplication    Length = 16-17 lines in 2 locations

src/Models/Model.php 2 locations

@@ 123-138 (lines=16) @@
120
     *
121
     * Overloaded to support relationships.
122
     */
123
    public function clear($key)
124
    {
125
        if (true === $this->isHasOne($key)) {
126
            return $this->setHasOne($key, null);
127
        }
128
        if (true === $this->isInverse($key)) {
129
            throw ModelException::cannotModifyInverse($this, $key);
130
        }
131
        if (true === $this->isHasMany($key)) {
132
            $collection = $this->hasManyRelationships->get($key);
133
            $collection->clear();
134
            $this->doDirtyCheck();
135
            return $this;
136
        }
137
        return parent::clear($key);
138
    }
139
140
    /**
141
     * Enables or disables has-many collection auto-initialization from the database.
@@ 363-379 (lines=17) @@
360
     * @param   Model   $model
361
     * @return  self
362
     */
363
    public function push($key, Model $model)
364
    {
365
        if (true === $this->isHasOne($key)) {
366
            return $this->setHasOne($key, $model);
367
        }
368
        if (false === $this->isHasMany($key)) {
369
            return $this;
370
        }
371
        if (true === $this->isInverse($key)) {
372
            throw ModelException::cannotModifyInverse($this, $key);
373
        }
374
        $this->touch();
375
        $collection = $this->hasManyRelationships->get($key);
376
        $collection->push($model);
377
        $this->doDirtyCheck();
378
        return $this;
379
    }
380
381
    /**
382
     * Reloads the model from the database.