Conditions | 3 |
Paths | 3 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
29 | 4 | public function init() |
|
30 | { |
||
31 | // Set primaryKey value on type |
||
32 | 4 | $type = $this->getMeta()->type(); |
|
33 | /* @var $type DocumentTypeMeta */ |
||
34 | 4 | $name = $this->getEntity()->name; |
|
35 | // If key is already defined it means that it is composite |
||
36 | 4 | if ($type->primaryKey) |
|
37 | { |
||
38 | // If it is array then add field |
||
39 | 3 | if (is_array($type->primaryKey)) |
|
40 | { |
||
41 | 1 | $type->primaryKey[] = $name; |
|
42 | } |
||
43 | else |
||
44 | { |
||
45 | // it is not array so create composite from existing |
||
46 | // field and add new field to definition |
||
47 | 3 | $type->primaryKey = [$type->primaryKey, $name]; |
|
48 | } |
||
49 | } |
||
50 | else |
||
51 | { |
||
52 | // Simple primary key |
||
53 | 4 | $type->primaryKey = $name; |
|
54 | } |
||
55 | 4 | } |
|
56 | |||
58 |