Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
10 | 3 | public function getIdName(string $entityClass): string |
|
11 | { |
||
12 | 3 | $ids = array_keys(array_filter( |
|
13 | 3 | ClassMetadata::getRawConfig($entityClass), |
|
14 | 3 | function (array $values) { |
|
15 | 3 | return !empty($values[Id::KEY_NAME]); |
|
16 | 3 | } |
|
17 | )); |
||
18 | |||
19 | 3 | if (count($ids) !== 1) { |
|
20 | 2 | throw new Exception(sprintf( |
|
21 | 2 | 'No or more than one identifier specified for entity "%s". Every entity must have one identifier', |
|
22 | $entityClass |
||
23 | )); |
||
24 | } |
||
25 | |||
26 | 1 | return reset($ids); |
|
27 | } |
||
28 | |||
34 |