Code Duplication    Length = 8-11 lines in 2 locations

source/Spiral/ODM/Document.php 1 location

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

source/Spiral/ORM/Record.php 1 location

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