Code Duplication    Length = 5-8 lines in 2 locations

src/api/object.php 1 location

@@ 258-265 (lines=8) @@
255
        $qb = connection::get_em()->createQueryBuilder();
256
        $qb->from(get_class($this), 'c');
257
        $conditions = $qb->expr()->andX();
258
        if ($this->id) {
259
            $parameters = array(
260
                'id' => $this->id
261
            );
262
            $conditions->add($qb->expr()->neq('c.id', ':id'));
263
        }
264
        $found = false;
265
        foreach ($this->cm->midgard['unique_fields'] as $field) {
266
            if (empty($this->$field)) {
267
                //empty names automatically pass according to Midgard logic
268
                continue;

src/api/user.php 1 location

@@ 198-202 (lines=5) @@
195
            'authtype' => $this->authtype
196
        );
197
198
        if ($this->id) {
199
            $parameters['id'] = $this->id;
200
            $conditions->add($qb->expr()->neq('c.id', ':id'));
201
        }
202
        $conditions->add($qb->expr()->eq('c.login', ':login'));
203
        $conditions->add($qb->expr()->eq('c.authtype', ':authtype'));
204
205
        $qb->where($conditions)