Code Duplication    Length = 22-22 lines in 2 locations

lib/Mongo/MongoCollection.php 1 location

@@ 716-737 (lines=22) @@
713
     * @param array|object $document_or_id Object to which to create a reference.
714
     * @return array Returns a database reference array.
715
     */
716
    public function createDBRef($document_or_id)
717
    {
718
        if ($document_or_id instanceof \MongoId) {
719
            $id = $document_or_id;
720
        } elseif (is_object($document_or_id)) {
721
            if (! isset($document_or_id->_id)) {
722
                return null;
723
            }
724
725
            $id = $document_or_id->_id;
726
        } elseif (is_array($document_or_id)) {
727
            if (! isset($document_or_id['_id'])) {
728
                return null;
729
            }
730
731
            $id = $document_or_id['_id'];
732
        } else {
733
            $id = $document_or_id;
734
        }
735
736
        return MongoDBRef::create($this->name, $id);
737
    }
738
739
    /**
740
     * Fetches the document pointed to by a database reference

lib/Mongo/MongoDB.php 1 location

@@ 320-341 (lines=22) @@
317
     * @param mixed $document_or_id
318
     * @return array Returns a database reference array.
319
     */
320
    public function createDBRef($collection, $document_or_id)
321
    {
322
        if ($document_or_id instanceof \MongoId) {
323
            $id = $document_or_id;
324
        } elseif (is_object($document_or_id)) {
325
            if (! isset($document_or_id->_id)) {
326
                return null;
327
            }
328
329
            $id = $document_or_id->_id;
330
        } elseif (is_array($document_or_id)) {
331
            if (! isset($document_or_id['_id'])) {
332
                return null;
333
            }
334
335
            $id = $document_or_id['_id'];
336
        } else {
337
            $id = $document_or_id;
338
        }
339
340
        return MongoDBRef::create($collection, $id, $this->name);
341
    }
342
343
344
    /**