Code Duplication    Length = 22-22 lines in 2 locations

lib/Mongo/MongoCollection.php 1 location

@@ 670-691 (lines=22) @@
667
     * @param array|object $document_or_id Object to which to create a reference.
668
     * @return array Returns a database reference array.
669
     */
670
    public function createDBRef($document_or_id)
671
    {
672
        if ($document_or_id instanceof \MongoId) {
673
            $id = $document_or_id;
674
        } elseif (is_object($document_or_id)) {
675
            if (! isset($document_or_id->_id)) {
676
                return null;
677
            }
678
679
            $id = $document_or_id->_id;
680
        } elseif (is_array($document_or_id)) {
681
            if (! isset($document_or_id['_id'])) {
682
                return null;
683
            }
684
685
            $id = $document_or_id['_id'];
686
        } else {
687
            $id = $document_or_id;
688
        }
689
690
        return MongoDBRef::create($this->name, $id);
691
    }
692
693
    /**
694
     * Fetches the document pointed to by a database reference

lib/Mongo/MongoDB.php 1 location

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