Code Duplication    Length = 25-25 lines in 2 locations

src/api/user.php 1 location

@@ 143-167 (lines=25) @@
140
        return (!empty($this->id));
141
    }
142
143
    public function update()
144
    {
145
        if (empty($this->id) || !mgd_is_guid($this->guid)) {
146
            exception::invalid_property_value();
147
            return false;
148
        }
149
        if (!$this->is_unique()) {
150
            exception::duplicate();
151
            return false;
152
        }
153
        try {
154
            $om = new objectmanager(connection::get_em());
155
            $om->update($this);
156
        } catch (\Exception $e) {
157
            exception::internal($e);
158
            return false;
159
        }
160
        midgard_connection::get_instance()->set_error(MGD_ERR_OK);
161
        return true;
162
    }
163
164
    public function delete()
165
    {
166
        if (!mgd_is_guid($this->guid)) {
167
            exception::invalid_property_value();
168
            return false;
169
        }
170

src/api/mgdobject.php 1 location

@@ 209-233 (lines=25) @@
206
    /**
207
     * @return boolean
208
     */
209
    public function update()
210
    {
211
        if (empty($this->id)) {
212
            midgard_connection::get_instance()->set_error(MGD_ERR_INTERNAL);
213
            return false;
214
        }
215
        if (!$this->check_fields()) {
216
            return false;
217
        }
218
        try {
219
            $om = new objectmanager(connection::get_em());
220
            $om->update($this);
221
        } catch (\Exception $e) {
222
            exception::internal($e);
223
            return false;
224
        }
225
        midgard_connection::get_instance()->set_error(MGD_ERR_OK);
226
227
        return true;
228
    }
229
230
    /**
231
     * @todo: Tests indicate that $check_dependencies is ignored in the mgd2 extension,
232
     * so we might consider ignoring it, too
233
     *
234
     * @return boolean
235
     */
236
    public function delete($check_dependencies = true)