Code Duplication    Length = 8-11 lines in 2 locations

source/Spiral/ODM/Document.php 1 location

@@ 155-162 (lines=8) @@
152
            $collection->insert($this->fields = $this->serializeData());
153
154
            $this->dispatch('saved', new EntityEvent($this));
155
        } elseif ($this->isSolid() || $this->hasUpdates()) {
156
            $this->dispatch('updating', new EntityEvent($this));
157
158
            //Update existed document
159
            $collection->update(['_id' => $this->primaryKey()], $this->buildAtomics());
160
161
            $this->dispatch('updated', new EntityEvent($this));
162
        }
163
164
        $this->flushUpdates();
165

source/Spiral/ORM/Record.php 1 location

@@ 79-89 (lines=11) @@
76
            //Saving record to entity cache if we have space for that
77
            $this->orm->rememberEntity($this, false);
78
79
        } elseif ($this->isSolid() || $this->hasUpdates()) {
80
            $this->dispatch('updating', new EntityEvent($this));
81
82
            //Updating changed/all field based on model criteria (in usual case primaryKey)
83
            $this->sourceTable()->update(
84
                $this->compileUpdates(),
85
                $this->stateCriteria()
86
            )->run();
87
88
            $this->dispatch('updated', new EntityEvent($this));
89
        }
90
91
        $this->flushUpdates();
92
        $this->saveRelations($validate);