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

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