Code Duplication    Length = 15-16 lines in 2 locations

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

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

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

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