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/object.php 1 location

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