AssignedIdGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 8 2
1
<?php
2
3
namespace Doctrine\ODM\CouchDB\Id;
4
5
use Doctrine\ODM\CouchDB\DocumentManager;
6
use Doctrine\ODM\CouchDB\Mapping\ClassMetadata;
7
use Doctrine\ODM\CouchDB\CouchDBException;
8
9
class AssignedIdGenerator extends IdGenerator
10
{
11
    /**
12
     * @param object $document
13
     * @param ClassMetadata $cm
14
     * @param DocumentManager $dm
15
     * @return array
16
     * @throws CouchDBException
17
     */
18
    public function generate($document, ClassMetadata $cm, DocumentManager $dm)
19
    {
20
        $id = $cm->getIdentifierValue($document);
21
        if (!$id) {
22
            throw CouchDBException::assignedIdGeneratorNoIdFound($cm->name);
23
        }
24
        return $id;
25
    }
26
}
27