Code Duplication    Length = 15-16 lines in 2 locations

lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php 1 location

@@ 165-179 (lines=15) @@
162
            if ( ! class_exists($targetFqcn)) {
163
                eval(substr($code, 5));
164
            }
165
        } else {
166
            $parentDirectory = dirname($fileName);
167
168
            if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
169
                throw PersistentCollectionException::directoryNotWritable();
170
            }
171
172
            if ( ! is_writable($parentDirectory)) {
173
                throw PersistentCollectionException::directoryNotWritable();
174
            }
175
176
            $tmpFileName = $fileName . '.' . uniqid('', true);
177
            file_put_contents($tmpFileName, $code);
178
            rename($tmpFileName, $fileName);
179
        }
180
    }
181
182
    private function generateMethod(\ReflectionMethod $method)

lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php 1 location

@@ 405-420 (lines=16) @@
402
            if ( ! class_exists($namespace . '\\' . $hydratorClassName)) {
403
                eval(substr($code, 5));
404
            }
405
        } else {
406
            $parentDirectory = dirname($fileName);
407
408
            if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
409
                throw HydratorException::hydratorDirectoryNotWritable();
410
            }
411
412
            if ( ! is_writable($parentDirectory)) {
413
                throw HydratorException::hydratorDirectoryNotWritable();
414
            }
415
416
            $tmpFileName = $fileName . '.' . uniqid('', true);
417
            file_put_contents($tmpFileName, $code);
418
            rename($tmpFileName, $fileName);
419
            chmod($fileName, 0664);
420
        }
421
    }
422
423
    /**