Code Duplication    Length = 25-25 lines in 2 locations

src/api/user.php 1 location

@@ 157-181 (lines=25) @@
154
        return (!empty($this->id));
155
    }
156
157
    public function update()
158
    {
159
        if (empty($this->id) || !mgd_is_guid($this->guid))
160
        {
161
            exception::invalid_property_value();
162
            return false;
163
        }
164
        if (!$this->is_unique())
165
        {
166
            exception::duplicate();
167
            return false;
168
        }
169
        try
170
        {
171
            $om = new objectmanager(connection::get_em());
172
            $om->update($this);
173
        }
174
        catch (\Exception $e)
175
        {
176
            exception::internal($e);
177
            return false;
178
        }
179
        midgard_connection::get_instance()->set_error(MGD_ERR_OK);
180
        return true;
181
    }
182
183
    public function delete()
184
    {

src/api/object.php 1 location

@@ 224-248 (lines=25) @@
221
        return ($this->id != 0);
222
    }
223
224
    public function update()
225
    {
226
        if (empty($this->id))
227
        {
228
            midgard_connection::get_instance()->set_error(MGD_ERR_INTERNAL);
229
            return false;
230
        }
231
        if (!$this->check_fields())
232
        {
233
            return false;
234
        }
235
        try
236
        {
237
            $om = new objectmanager(connection::get_em());
238
            $om->update($this);
239
        }
240
        catch (\Exception $e)
241
        {
242
            exception::internal($e);
243
            return false;
244
        }
245
        midgard_connection::get_instance()->set_error(MGD_ERR_OK);
246
247
        return true;
248
    }
249
250
    /**
251
     * @todo: Tests indicate that $check_dependencies is ignored in the mgd2 extension,