Code Duplication    Length = 15-16 lines in 2 locations

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

@@ 388-403 (lines=16) @@
385
            if ( ! class_exists($namespace . '\\' . $hydratorClassName)) {
386
                eval(substr($code, 5));
387
            }
388
        } else {
389
            $parentDirectory = dirname($fileName);
390
391
            if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
392
                throw HydratorException::hydratorDirectoryNotWritable();
393
            }
394
395
            if ( ! is_writable($parentDirectory)) {
396
                throw HydratorException::hydratorDirectoryNotWritable();
397
            }
398
399
            $tmpFileName = $fileName . '.' . uniqid('', true);
400
            file_put_contents($tmpFileName, $code);
401
            rename($tmpFileName, $fileName);
402
            chmod($fileName, 0664);
403
        }
404
    }
405
406
    /**

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

@@ 148-162 (lines=15) @@
145
            if ( ! class_exists($targetFqcn)) {
146
                eval(substr($code, 5));
147
            }
148
        } else {
149
            $parentDirectory = dirname($fileName);
150
151
            if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
152
                throw PersistentCollectionException::directoryNotWritable();
153
            }
154
155
            if ( ! is_writable($parentDirectory)) {
156
                throw PersistentCollectionException::directoryNotWritable();
157
            }
158
159
            $tmpFileName = $fileName . '.' . uniqid('', true);
160
            file_put_contents($tmpFileName, $code);
161
            rename($tmpFileName, $fileName);
162
        }
163
    }
164
165
    private function generateMethod(\ReflectionMethod $method)