Conditions | 5 |
Paths | 7 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
32 | 3 | public function getRecordIdentifier(DataBagInterface $dataBag): array |
|
33 | { |
||
34 | 3 | $identifiers = []; |
|
35 | 3 | $indices = $this->utility->getUniqueKeys($this->table); |
|
36 | 3 | foreach ($indices as $index) { |
|
37 | 3 | foreach ($index->getColumns() as $column) { |
|
38 | 3 | if (isset($dataBag[$column])) { |
|
39 | 3 | $identifiers[$column] = $dataBag[$column]; |
|
40 | } else { |
||
41 | // if one of the columns is empty, this index can not be used |
||
42 | 1 | $identifiers = []; |
|
43 | 3 | break; |
|
44 | } |
||
45 | } |
||
46 | // If we have already found something to identify the record with, skip other keys |
||
47 | 3 | if (!empty($identifiers)) { |
|
48 | 3 | break; |
|
49 | } |
||
50 | } |
||
51 | 3 | return $identifiers; |
|
52 | } |
||
53 | } |
||
54 |