Conditions | 8 |
Paths | 11 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public function handleHasOneType($class, $data, $dataField, $config, $dbField) |
||
37 | { |
||
38 | if (!array_key_exists('relation', $config) || !is_array($config['relation'])) { |
||
39 | return preg_match('/ID$/', $dbField) ? 0 : null; |
||
40 | } |
||
41 | |||
42 | $relationConfig = $config['relation']; |
||
43 | $relatedClass = array_key_first($relationConfig); |
||
44 | |||
45 | foreach ($this->owner->yieldKeyVal($relationConfig[$relatedClass]) as $dbField => $salsifyField) { |
||
46 | if ($this->owner->handleShouldSkip($class, $dbField, $salsifyField, $data)) { |
||
47 | return false; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | $object = $this->owner->mapToObject($relatedClass, $relationConfig[$relatedClass], $data); |
||
52 | $objectID = $object ? $object->ID : 0; |
||
53 | return preg_match('/ID$/', $dbField) ? $objectID : $object; |
||
54 | } |
||
56 |