Completed
Push — master ( 707688...6da863 )
by Mike
04:47 queued 02:08
created

lib/Doctrine/ODM/CouchDB/Id/IdGenerator.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Doctrine\ODM\CouchDB\Id;
4
5
use Doctrine\ODM\CouchDB\DocumentManager;
6
use Doctrine\ODM\CouchDB\Mapping\ClassMetadata;
7
8
/**
9
 * Used to abstract ID generation
10
 *
11
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
12
 * @link        www.doctrine-project.com
13
 * @since       1.0
14
 * @author      Benjamin Eberlei <[email protected]>
15
 * @author      Lukas Kahwe Smith <[email protected]>
16
 */
17
abstract class IdGenerator
18
{
19
    /**
20
     * @param int $generatorType
21
     *
22
     * @return IdGenerator
23
     * @throws \Exception
24
     */
25
    static public function create($generatorType)
0 ignored issues
show
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
26
    {
27
        switch ($generatorType) {
28
            case ClassMetadata::IDGENERATOR_ASSIGNED:
29
                $instance = new AssignedIdGenerator();
30
                break;
31
            case ClassMetadata::IDGENERATOR_UUID:
32
                $instance = new CouchUUIDGenerator();
33
                break;
34
            default:
35
                throw new \Exception("ID Generator does not exist!");
36
        }
37
        return $instance;
38
    }
39
40
    /**
41
     * @param object $document
42
     * @param ClassMetadata $cm
43
     * @param DocumentManager $dm
44
     */
45
    abstract public function generate($document, ClassMetadata $cm, DocumentManager $dm);
46
}
47