Code Duplication    Length = 22-22 lines in 2 locations

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
    /**

lib/Mongo/MongoCollection.php 1 location

@@ 730-751 (lines=22) @@
727
     * @param array|object $document_or_id Object to which to create a reference.
728
     * @return array Returns a database reference array.
729
     */
730
    public function createDBRef($document_or_id)
731
    {
732
        if ($document_or_id instanceof \MongoId) {
733
            $id = $document_or_id;
734
        } elseif (is_object($document_or_id)) {
735
            if (! isset($document_or_id->_id)) {
736
                return null;
737
            }
738
739
            $id = $document_or_id->_id;
740
        } elseif (is_array($document_or_id)) {
741
            if (! isset($document_or_id['_id'])) {
742
                return null;
743
            }
744
745
            $id = $document_or_id['_id'];
746
        } else {
747
            $id = $document_or_id;
748
        }
749
750
        return MongoDBRef::create($this->name, $id);
751
    }
752
753
    /**
754
     * Fetches the document pointed to by a database reference