Code Duplication    Length = 25-25 lines in 2 locations

src/api/object.php 1 location

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

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